From 910dfcdeb15af7befbe02d3be652ae96c2ab120d Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Thu, 7 May 2020 14:36:37 +0200 Subject: [PATCH] bip39 keystore import --- drongo | 2 +- .../java/com/sparrowwallet/sparrow/io/Bip39.java | 15 +++++++-------- .../sparrow/io/KeystoreMnemonicImport.java | 4 ++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/drongo b/drongo index c5042cf1..d394c25a 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit c5042cf130457233955aa4c72b1ad543bdfcb171 +Subproject commit d394c25a3c05c02d984b1f709623a311c2afb7a1 diff --git a/src/main/java/com/sparrowwallet/sparrow/io/Bip39.java b/src/main/java/com/sparrowwallet/sparrow/io/Bip39.java index 742b4d79..8b039609 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/Bip39.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/Bip39.java @@ -1,6 +1,6 @@ package com.sparrowwallet.sparrow.io; -import com.sparrowwallet.drongo.protocol.ScriptType; +import com.sparrowwallet.drongo.crypto.ChildNumber; import com.sparrowwallet.drongo.wallet.Bip39Calculator; import com.sparrowwallet.drongo.wallet.Keystore; import com.sparrowwallet.drongo.wallet.WalletModel; @@ -8,12 +8,9 @@ import com.sparrowwallet.drongo.wallet.WalletModel; import java.util.List; public class Bip39 implements KeystoreMnemonicImport { - @Override - public Keystore getKeystore(ScriptType scriptType, List mnemonicWords, String passphrase) throws ImportException { - Bip39Calculator bip39Calculator = new Bip39Calculator(); - - return null; + public String getName() { + return "Mnemonic Words (BIP39)"; } @Override @@ -27,7 +24,9 @@ public class Bip39 implements KeystoreMnemonicImport { } @Override - public String getName() { - return null; + public Keystore getKeystore(List derivation, List mnemonicWords, String passphrase) throws ImportException { + Bip39Calculator bip39Calculator = new Bip39Calculator(); + byte[] seed = bip39Calculator.getSeed(mnemonicWords, passphrase); + return Keystore.fromSeed(seed, derivation); } } diff --git a/src/main/java/com/sparrowwallet/sparrow/io/KeystoreMnemonicImport.java b/src/main/java/com/sparrowwallet/sparrow/io/KeystoreMnemonicImport.java index dcc6db55..d12aaafb 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/KeystoreMnemonicImport.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/KeystoreMnemonicImport.java @@ -1,10 +1,10 @@ package com.sparrowwallet.sparrow.io; -import com.sparrowwallet.drongo.protocol.ScriptType; +import com.sparrowwallet.drongo.crypto.ChildNumber; import com.sparrowwallet.drongo.wallet.Keystore; import java.util.List; public interface KeystoreMnemonicImport extends KeystoreImport { - Keystore getKeystore(ScriptType scriptType, List mnemonicWords, String passphrase) throws ImportException; + Keystore getKeystore(List derivation, List mnemonicWords, String passphrase) throws ImportException; }