Skip to content

Commit 43482d3

Browse files
committed
Start wallet nonce from 0
1 parent 3ec8d7a commit 43482d3

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

scorex-basics/src/main/scala/scorex/wallet/Wallet.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class Wallet(walletFileOpt: Option[File], password: String, seedOpt: Option[Arra
8383
} else false
8484

8585
if (created) {
86-
log.info("Added account #" + (nonce + 2))
86+
log.info("Added account #" + privateKeyAccounts().size)
8787
Some(account)
8888
} else None
8989
}
@@ -119,7 +119,7 @@ class Wallet(walletFileOpt: Option[File], password: String, seedOpt: Option[Arra
119119
def nonce(): Int = Option(noncePersistence.get(NonceFieldName)).getOrElse(0)
120120

121121
def getAndIncrementNonce(): Int = synchronized {
122-
noncePersistence.put(NonceFieldName, nonce() + 1) - 1
122+
noncePersistence.put(NonceFieldName, nonce() + 1)
123123
}
124124

125125
}

src/test/scala/scorex/lagonaki/unit/WalletSpecification.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class WalletSpecification extends FunSuite with Matchers {
1515
w.generateNewAccounts(walletSize)
1616

1717
w.privateKeyAccounts().size shouldBe walletSize
18-
w.privateKeyAccounts().map(_.address) shouldBe Seq("3Mb4mR4taeYS3wci78SntztFwLoaS6Wbg81", "3MkcXZiczXxqEQYVVhRqkUnVaTfzaeMs15e", "3MoFqpXVnxVpMwN1egMj2yH6EEWWYVruvfn", "3MjLQqH3cU6DZ4yFC6SAPmXkHf3ajWmV3LK", "3MbWTyn6Tg7zL6XbdN8TLcFMfhWX77hKcmc", "3MUc8z9WMuMbRR93NU8Jxh1DgwCkfHr78Fu", "3Mo4k51wnV4EYmCmneh4fqDdfKYxcgZgCUT", "3MiSmwnRGJtLmZeNLYg75bje6StYhCEKCrX", "3MjQ5FJEBGggnwBWBNjZtgcwyrYTn4r4shg", "3MkjMybqczyo6SyouuaSniTuSiZqTsMhQQx")
18+
w.privateKeyAccounts().map(_.address) shouldBe Seq("3Mb4mR4taeYS3wci78SntztFwLoaS6Wbg81", "3MkcXZiczXxqEQYVVhRqkUnVaTfzaeMs15e", "3MoFqpXVnxVpMwN1egMj2yH6EEWWYVruvfn", "3MjLQqH3cU6DZ4yFC6SAPmXkHf3ajWmV3LK", "3MXTTi9tjPSjossb4Tx5nokg895tCfroWLB", "3MUc8z9WMuMbRR93NU8Jxh1DgwCkfHr78Fu", "3Mo4k51wnV4EYmCmneh4fqDdfKYxcgZgCUT", "3MiSmwnRGJtLmZeNLYg75bje6StYhCEKCrX", "3MjQ5FJEBGggnwBWBNjZtgcwyrYTn4r4shg", "3MkjMybqczyo6SyouuaSniTuSiZqTsMhQQx")
1919

2020
}
2121

0 commit comments

Comments
 (0)