When I modified and ran the example of
examples/src/main/java/org/bitcoinj/examples/RestoreFromSeed.java, just
changing the seedcode, passphrase and creationtime, which are copied from
wallettemplate application, the first time it output the correct result,
public key, addresses and balance, same as the result of wallettemplate
application, logs are as following:
blockchain downloaded
Aug 18, 2018 3:21:41 PM org.bitcoinj.core.listeners.DownloadProgressTracker
progress
INFO: Chain download 100% done with 0 blocks to go, block date
2018-08-18T06:54:55Z
Wallet containing 1.049775 BTC (spendable: 1.049775 BTC) in:
0 pending transactions
1 unspent transactions
6 spent transactions
0 dead transactions
Last seen best block: 1384260 (2018-08-18T07:03:22Z):
000000000000001a63e9bf69a5856c3c77f06143654553376656464cab4e2f92
Keys:
Earliest creation time: 2018-08-14T16:00:00Z
Seed birthday: 1534262400 [2018-08-14T16:00:00Z]
Key to watch:
tpubD8oh4S7QFYNKSez4kbn6fU8T6kQSC7d1KBcm5baTkLDZMjtpaow2XQ1hq8J61NCj2aUYRgTCYvPpFmDLN9YQQJcvheqbq5cxGGVYA2ENkLf
addr:mnGSVS733XtbTU5M7mqviNVLvRnw1w5Lnx
hash160:4a0a2d957f4c78575d8175c382f0260bbd973662 (M)
addr:mtJGsALAfNETUHct4biRfmZ4RnABpxQtNr
hash160:8c33bad5f4f2ad968be8a887818239758b5c5a85 (M/0H)
addr:mzUhxsi4RXmG2CKd3NsL99pnTjKwiHGjCG
hash160:cffd98674e0c479c11a4639c1962926cd191c013 (M/0H/0)
addr:mkFDdroVjeaDo41YJk9AFr4nAdE1jPrYgx
hash160:33dec7aa9dc2d3b27ba648e0075359f70ae12b02 (M/0H/1)
addr:mgTxLgbRfyTYZ6WWYpfZvRarFXxoyeZuM9
hash160:0a66ea6e172a377b49b6d9394dbdb746420edf6b (M/0H/0/0)
addr:mxNvc45qSDAxRgDV5fC597cY2j5YurfwRb
hash160:b8f56671f2339198a551e39e43a6c0e65da5e14c (M/0H/0/1)
addr:mmup4jHJnjW66io7497ntoW4WLUqMB2jRS
hash160:462373b5ced276f39087a10e8b55e61931747f7c (M/0H/1/0)
addr:mqrhgCiVWYKEvVVdud6rB7Rpj9kiNGkpCF
hash160:716d5fddc774363661c528f8ddf4e0cc312fba21 (M/0H/1/1)
addr:n2BXVD1kZYUjeeLo9tn2gR2RHp8RPdT6A3
hash160:e2ae079eda7be6e3df8c521bb4727c0b9b1df6aa (M/0H/1/2)
addr:mfzxSV3SuiKY5drnENVJ6nLfHdJwMiZNh2
hash160:054bc4accfe8c537f643f9e088bf712b69506430 (M/0H/1/3)
However, after I modified something again and run, it failed to output the
correct result. I change anything back to that as the first time it worked
well, but still wrong result. The wrong output is like this:
blockchain downloaded
Aug 21, 2018 6:54:52 PM org.bitcoinj.core.listeners.DownloadProgressTracker
progress
INFO: Chain download 100% done with 0 blocks to go, block date
2018-08-21T10:40:09Z
Wallet containing 0.00 BTC (spendable: 0.00 BTC) in:
0 pending transactions
0 unspent transactions
0 spent transactions
0 dead transactions
Last seen best block: 1384795 (2018-08-21T10:47:18Z):
000000000000000df5ab2ebf1546def5eb15830a2c5517e8453be7a9eda5f2b2
Keys:
Earliest creation time: 2018-08-14T16:00:00Z
Seed birthday: 1534262400 [2018-08-14T16:00:00Z]
Key to watch:
tpubD9U6XhzR9tEALQghmu5d5nmDnxdCFJrdBEFhN96BZYm7fV4njrsVzGkSjPsfXp4XW4FV4QGq7gkHWBYQ6YHewLyPnULfa9y4EWiPFNiafjA
addr:mvUmiXzgD9ApEZ52XLnXsKUCSXC9kHVoLk
hash160:a420398efacf231c78ec1674064077201554a0fb (M)
addr:n416QD4W7onBV1AdpgWpeR8RcwYLi3Z34G
hash160:f6a52e4a19363ba775f0c178bdcf2fafc524670a (M/0H)
addr:mtzh6qeBwLgirUCRRh3bxV5bivrj4RHgPg
hash160:93d8996eb590bb34d60dd9fa676407d30a3348d9 (M/0H/0)
addr:moeLW9vCjQsXxRxNP4bcbnf53vm9ubdwSa
hash160:592674f30a1835a8d1490e7c197e2c6c236f6303 (M/0H/1)
My modification to RestoreFromSeed.java are just as following:
bo@ubuntu:/mnt/hgfs/work/src/bitcoinj$ git diff
examples/src/main/java/org/bitcoinj/examples/RestoreFromSeed.java
diff --git a/examples/src/main/java/org/bitcoinj/examples/RestoreFromSeed.java
b/examples/src/main/java/org/bitcoinj/examples/RestoreFromSeed.java
index 106cf6cc..94e11ac1 100644
--- a/examples/src/main/java/org/bitcoinj/examples/RestoreFromSeed.java
+++ b/examples/src/main/java/org/bitcoinj/examples/RestoreFromSeed.java
@@ -39,9 +39,10 @@ public class RestoreFromSeed {
// HD wallets allow you to restore your wallet simply from a root
seed. This seed can be represented using a short mnemonic sentence as described
in BIP 39: https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki
// Here we restore our wallet from a seed with no passphrase. Also
have a look at the BackupToMnemonicSeed.java example that shows how to backup a
wallet by creating a mnemonic sentence.
- String seedCode = "yard impulse luxury drive today throw farm pepper
survey wreck glass federal";
- String passphrase = "";
- Long creationtime = 1409478661L;
+// String seedCode = "yard impulse luxury drive today throw farm pepper
survey wreck glass federal";
+ String seedCode = "unknown rapid wrist rubber supply powder sock
course inform banana end plate";
+ String passphrase = "12345";
+ Long creationtime = 1534262400L; // 1409478661L;
DeterministicSeed seed = new DeterministicSeed(seedCode, null,
passphrase, creationtime);
The logs of the wallettemplate application are:
Wallet containing 1.049775 BTC (spendable: 1.049775 BTC) in:
0 pending transactions
1 unspent transactions
6 spent transactions
0 dead transactions
Last seen best block: 1384777 (2018-08-21T09:18:57Z):
0000000000000014ab1036d9385563bab8dd2d85425ab2ade14c2b43ca9d49db
Encryption: AES-256-CBC, Scrypt (N: 32768)
Keys:
Earliest creation time: 2018-08-14T11:55:00Z
Seed is encrypted
Seed birthday: 1534247700 [2018-08-14T11:55:00Z]
Key to watch:
tpubD8oh4S7QFYNKSez4kbn6fU8T6kQSC7d1KBcm5baTkLDZMjtpaow2XQ1hq8J61NCj2aUYRgTCYvPpFmDLN9YQQJcvheqbq5cxGGVYA2ENkLf
addr:mnGSVS733XtbTU5M7mqviNVLvRnw1w5Lnx
hash160:4a0a2d957f4c78575d8175c382f0260bbd973662 (M)
addr:mtJGsALAfNETUHct4biRfmZ4RnABpxQtNr
hash160:8c33bad5f4f2ad968be8a887818239758b5c5a85 (M/0H)
addr:mzUhxsi4RXmG2CKd3NsL99pnTjKwiHGjCG
hash160:cffd98674e0c479c11a4639c1962926cd191c013 (M/0H/0)
addr:mkFDdroVjeaDo41YJk9AFr4nAdE1jPrYgx
hash160:33dec7aa9dc2d3b27ba648e0075359f70ae12b02 (M/0H/1)
addr:mgTxLgbRfyTYZ6WWYpfZvRarFXxoyeZuM9
hash160:0a66ea6e172a377b49b6d9394dbdb746420edf6b (M/0H/0/0)
addr:mxNvc45qSDAxRgDV5fC597cY2j5YurfwRb
hash160:b8f56671f2339198a551e39e43a6c0e65da5e14c (M/0H/0/1)
addr:n2SinJhjCi9xaX9AmmhAn6aYxSE3yqSEJZ
hash160:e58db296d95d8aabc1e71fae9285badd74d213ca (M/0H/0/2)
addr:mmup4jHJnjW66io7497ntoW4WLUqMB2jRS
hash160:462373b5ced276f39087a10e8b55e61931747f7c (M/0H/1/0)
addr:mqrhgCiVWYKEvVVdud6rB7Rpj9kiNGkpCF
hash160:716d5fddc774363661c528f8ddf4e0cc312fba21 (M/0H/1/1)
addr:n2BXVD1kZYUjeeLo9tn2gR2RHp8RPdT6A3
hash160:e2ae079eda7be6e3df8c521bb4727c0b9b1df6aa (M/0H/1/2)
addr:mfzxSV3SuiKY5drnENVJ6nLfHdJwMiZNh2
hash160:054bc4accfe8c537f643f9e088bf712b69506430 (M/0H/1/3)
addr:n41J6T6J8Z52LobGf3GZ2TWeD7LpcFefPM
hash160:f6aef13cb52722501ed5097fdf8d9ac84e7b0c97 (M/0H/1/4)
So, why does this happen? Is it a bug of the wallet restore? or Just
something wrong in my test?
--
You received this message because you are subscribed to the Google Groups
"bitcoinj" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.