Fix BIP39 implementation

This commit is contained in:
Devrandom
2014-07-07 17:11:41 -07:00
committed by Mike Hearn
parent 3420bdf8ac
commit 2fae12064c
10 changed files with 320 additions and 135 deletions

View File

@@ -853,8 +853,10 @@ public class WalletTool {
if (seedStr.contains(" ")) {
// Parse as mnemonic code.
final List<String> split = ImmutableList.copyOf(Splitter.on(" ").omitEmptyStrings().split(seedStr));
String passphrase = ""; // TODO allow user to specify a passphrase
seed = new DeterministicSeed(split, passphrase, creationTimeSecs);
try {
seed = new DeterministicSeed(split, creationTimeSecs);
seed.check();
} catch (MnemonicException.MnemonicLengthException e) {
System.err.println("The seed did not have 12 words in, perhaps you need quotes around it?");
return;
@@ -864,6 +866,9 @@ public class WalletTool {
} catch (MnemonicException.MnemonicChecksumException e) {
System.err.println("The seed did not pass checksumming, perhaps one of the words is wrong?");
return;
} catch (MnemonicException e) {
// not reached - all subclasses handled above
throw new RuntimeException(e);
}
} else {
// Parse as hex or base58

View File

@@ -12,4 +12,4 @@ if [ ! -e target/bitcoinj-tools-*.jar ] || [[ "$ALWAYS_BUILD_WALLETTOOL" != "" ]
mvn package -DskipTests
fi
java -jar target/bitcoinj-tools-*.jar $*
java -jar target/bitcoinj-tools-*.jar "$@"