Browse Source

Update ticker symbol from NANO to XNO

xno
codesoap 8 months ago
parent
commit
f7a5e3838e
  1. 4
      README.md
  2. 6
      account_info.go
  3. 6
      cmd/atto-safesign/README.md
  4. 14
      cmd/atto-safesign/util.go
  5. 4
      cmd/atto/main.go
  6. 12
      cmd/atto/util.go

4
README.md

@ -46,7 +46,7 @@ $ # The balance command will receive pending funds automatically. @@ -46,7 +46,7 @@ $ # The balance command will receive pending funds automatically.
$ pass nano | atto balance
Creating receive block for 1.025 from nano_34ymtnmhwseiex4eqf7nnf5wcyg44kknuuen5wwurm18ma91msf6e1pqo8hx... done
Creating receive block for 0.1 from nano_39nd8eksw1ia6aokn96z4uthocke47hfsx9gr31othm1nrfwnzmmaeehiccq... done
1.337 NANO
1.337 XNO
$ # Choosing a representative is important for keeping the network
$ # decentralized.
@ -56,7 +56,7 @@ Creating change block... done @@ -56,7 +56,7 @@ Creating change block... done
$ # To avoid accidental loss of funds, the send command requires
$ # confirmation, unless the -y flag is given:
$ pass nano | atto send 0.1 nano_11zdqnjpisos53uighoaw95satm4ptdruck7xujbjcs44pbkkbw1h3zomns5
Send 0.1 NANO to nano_11zdqnjpisos53uighoaw95satm4ptdruck7xujbjcs44pbkkbw1h3zomns5? [y/N]: y
Send 0.1 XNO to nano_11zdqnjpisos53uighoaw95satm4ptdruck7xujbjcs44pbkkbw1h3zomns5? [y/N]: y
Creating send block... done
$ atto -h

6
account_info.go

@ -22,7 +22,7 @@ type AccountInfo struct { @@ -22,7 +22,7 @@ type AccountInfo struct {
// Send creates a send block, which will still be missing its signature
// and work. The Frontier and Balance of the AccountInfo will be
// updated. The amount is interpreted as Nano, not raw!
// updated. The amount is interpreted as XNO, not raw!
func (i *AccountInfo) Send(amount, toAddr string) (Block, error) {
balance, err := getBalanceAfterSend(i.Balance, amount)
if err != nil {
@ -57,14 +57,14 @@ func getBalanceAfterSend(oldBalance string, amount string) (*big.Int, error) { @@ -57,14 +57,14 @@ func getBalanceAfterSend(oldBalance string, amount string) (*big.Int, error) {
err := fmt.Errorf("cannot parse '%s' as an integer", oldBalance)
return nil, err
}
amountRaw, err := nanoToRaw(amount)
amountRaw, err := xnoToRaw(amount)
if err != nil {
return nil, err
}
return balance.Sub(balance, amountRaw), nil
}
func nanoToRaw(amountString string) (*big.Int, error) {
func xnoToRaw(amountString string) (*big.Int, error) {
i := strings.Index(amountString, ".")
missingZerosUntilRaw := 30
if i > -1 {

6
cmd/atto-safesign/README.md

@ -35,9 +35,9 @@ online$ echo $MY_ADDRESS | atto-safesign test.atto representative nano_3up3y8cd3 @@ -35,9 +35,9 @@ online$ echo $MY_ADDRESS | atto-safesign test.atto representative nano_3up3y8cd3
offline$ # The sign subcommand can then be used on an offline computer:
offline$ pass nano | atto-safesign test.atto sign
Sign block that sets balance to 0.1 NANO and representative to nano_18shbirtzhmkf7166h39nowj9c9zrpufeg75bkbyoobqwf1iu3srfm9eo3pz? [y/N]: y
Sign block that sets balance to 0.232 NANO and representative to nano_18shbirtzhmkf7166h39nowj9c9zrpufeg75bkbyoobqwf1iu3srfm9eo3pz? [y/N]: y
Sign block that sets balance to 0.232 NANO and representative to nano_3up3y8cd3hhs7zdpmkpssgb1iyjpke3xwmgqy8rg58z1hwryqpjqnkuqayps? [y/N]: y
Sign block that sets balance to 0.1 XNO and representative to nano_18shbirtzhmkf7166h39nowj9c9zrpufeg75bkbyoobqwf1iu3srfm9eo3pz? [y/N]: y
Sign block that sets balance to 0.232 XNO and representative to nano_18shbirtzhmkf7166h39nowj9c9zrpufeg75bkbyoobqwf1iu3srfm9eo3pz? [y/N]: y
Sign block that sets balance to 0.232 XNO and representative to nano_3up3y8cd3hhs7zdpmkpssgb1iyjpke3xwmgqy8rg58z1hwryqpjqnkuqayps? [y/N]: y
online$ # Back at the online computer, the now signed blocks can be submitted:
online$ echo $MY_ADDRESS | atto-safesign test.atto submit

14
cmd/atto-safesign/util.go

@ -88,19 +88,19 @@ func appendLineToFile(in []byte) error { @@ -88,19 +88,19 @@ func appendLineToFile(in []byte) error {
return err
}
func rawToNanoString(raw *big.Int) string {
rawPerNano, _ := big.NewInt(0).SetString("1000000000000000000000000000000", 10)
func rawToXNO(raw *big.Int) string {
rawPerXNO, _ := big.NewInt(0).SetString("1000000000000000000000000000000", 10)
absRaw := big.NewInt(0).Abs(raw)
integerDigits, fractionalDigits := big.NewInt(0).QuoRem(absRaw, rawPerNano, big.NewInt(0))
integerDigits, fractionalDigits := big.NewInt(0).QuoRem(absRaw, rawPerXNO, big.NewInt(0))
res := integerDigits.String()
if fractionalDigits.Sign() != 0 {
fractionalDigitsString := fmt.Sprintf("%030s", fractionalDigits.String())
res += "." + strings.TrimRight(fractionalDigitsString, "0")
}
if raw.Sign() < 0 {
return "-" + res + " NANO"
return "-" + res + " XNO"
}
return res + " NANO"
return res + " XNO"
}
func letUserVerifyBlock(block atto.Block) (err error) {
@ -109,9 +109,9 @@ func letUserVerifyBlock(block atto.Block) (err error) { @@ -109,9 +109,9 @@ func letUserVerifyBlock(block atto.Block) (err error) {
if !ok {
return fmt.Errorf("cannot parse '%s' as an integer", block.Balance)
}
balanceNano := rawToNanoString(balanceInt)
balanceXNO := rawToXNO(balanceInt)
txt := "Sign block that sets balance to %s and representative to %s? [y/N]: "
fmt.Fprintf(os.Stderr, txt, balanceNano, block.Representative)
fmt.Fprintf(os.Stderr, txt, balanceXNO, block.Representative)
// Explicitly openning /dev/tty or CONIN$ ensures function, even if
// the standard input is not a terminal.

4
cmd/atto/main.go

@ -150,7 +150,7 @@ func printBalance() error { @@ -150,7 +150,7 @@ func printBalance() error {
if !ok {
return fmt.Errorf("cannot parse '%s' as an integer", pending.Amount)
}
fmt.Fprintf(os.Stderr, txt, rawToNanoString(amount), pending.Source)
fmt.Fprintf(os.Stderr, txt, rawToXNO(amount), pending.Source)
var block atto.Block
if firstReceive {
fmt.Fprintf(os.Stderr, "opening account... ")
@ -177,7 +177,7 @@ func printBalance() error { @@ -177,7 +177,7 @@ func printBalance() error {
if !ok {
return fmt.Errorf("cannot parse '%s' as an integer", info.Balance)
}
fmt.Println(rawToNanoString(newBalance))
fmt.Println(rawToXNO(newBalance))
return nil
}

12
cmd/atto/util.go

@ -19,24 +19,24 @@ func getSeed() (string, error) { @@ -19,24 +19,24 @@ func getSeed() (string, error) {
return strings.TrimSpace(firstLine), nil
}
func rawToNanoString(raw *big.Int) string {
rawPerNano, _ := big.NewInt(0).SetString("1000000000000000000000000000000", 10)
func rawToXNO(raw *big.Int) string {
rawPerXNO, _ := big.NewInt(0).SetString("1000000000000000000000000000000", 10)
absRaw := big.NewInt(0).Abs(raw)
integerDigits, fractionalDigits := big.NewInt(0).QuoRem(absRaw, rawPerNano, big.NewInt(0))
integerDigits, fractionalDigits := big.NewInt(0).QuoRem(absRaw, rawPerXNO, big.NewInt(0))
res := integerDigits.String()
if fractionalDigits.Sign() != 0 {
fractionalDigitsString := fmt.Sprintf("%030s", fractionalDigits.String())
res += "." + strings.TrimRight(fractionalDigitsString, "0")
}
if raw.Sign() < 0 {
return "-" + res + " NANO"
return "-" + res + " XNO"
}
return res + " NANO"
return res + " XNO"
}
func letUserVerifySend(amount, recipient string) (err error) {
if !yFlag {
fmt.Printf("Send %s NANO to %s? [y/N]: ", amount, recipient)
fmt.Printf("Send %s XNO to %s? [y/N]: ", amount, recipient)
// Explicitly openning /dev/tty or CONIN$ ensures function, even if
// the standard input is not a terminal.

Loading…
Cancel
Save