Search in sources :

Example 16 with ChildNumber

use of com.sparrowwallet.drongo.crypto.ChildNumber in project drongo by sparrowwallet.

the class PaymentCodeTest method testFromSeed.

@Test
public void testFromSeed() throws MnemonicException {
    DeterministicSeed aliceSeed = new DeterministicSeed("response seminar brave tip suit recall often sound stick owner lottery motion", "", 0, DeterministicSeed.Type.BIP39);
    Keystore aliceKeystore = Keystore.fromSeed(aliceSeed, List.of(new ChildNumber(47, true), ChildNumber.ZERO_HARDENED, ChildNumber.ZERO_HARDENED));
    DeterministicKey bip47PubKey = aliceKeystore.getExtendedPublicKey().getKey();
    PaymentCode alicePaymentCode = new PaymentCode(bip47PubKey.getPubKey(), bip47PubKey.getChainCode());
    Assert.assertEquals("PM8TJTLJbPRGxSbc8EJi42Wrr6QbNSaSSVJ5Y3E4pbCYiTHUskHg13935Ubb7q8tx9GVbh2UuRnBc3WSyJHhUrw8KhprKnn9eDznYGieTzFcwQRya4GA", alicePaymentCode.toString());
}
Also used : ChildNumber(com.sparrowwallet.drongo.crypto.ChildNumber) DeterministicKey(com.sparrowwallet.drongo.crypto.DeterministicKey) Test(org.junit.Test)

Example 17 with ChildNumber

use of com.sparrowwallet.drongo.crypto.ChildNumber in project drongo by sparrowwallet.

the class WalletTest method testHighDerivationPath.

@Test
public void testHighDerivationPath() {
    Wallet wallet = new Wallet();
    wallet.setPolicyType(PolicyType.SINGLE);
    wallet.setScriptType(ScriptType.P2WPKH);
    Keystore keystore = new Keystore();
    keystore.setKeyDerivation(new KeyDerivation("ffffffff", "m/84'/0'/2147483646'"));
    ExtendedKey extendedKey = ExtendedKey.fromDescriptor("ypub6WxQGZTrBdeYSD6ZnSxopCGnuS7dhbqc72S3sbjdFjxf8eBR3EJDB3iDMhny2tKogZnpaJcjoHC6zF5Cz1jSMrFFR1wrqfA1MFsWP3ACotd");
    keystore.setExtendedPublicKey(extendedKey);
    wallet.getKeystores().add(keystore);
    List<ChildNumber> derivation = List.of(keystore.getExtendedPublicKey().getKeyChildNumber(), new ChildNumber(0));
    Assert.assertEquals("027ecc656f4b91b92881b6f07cf876cd2e42b20df7acc4df54fc3315fbb2d13e1c", Utils.bytesToHex(extendedKey.getKey(derivation).getPubKey()));
    WalletNode receive0 = new WalletNode(wallet, KeyPurpose.RECEIVE, 0);
    Assert.assertEquals("bc1qarzeu6ncapyvjzdeayjq8vnzp6uvcn4eaeuuqq", receive0.getAddress().toString());
}
Also used : KeyDerivation(com.sparrowwallet.drongo.KeyDerivation) ChildNumber(com.sparrowwallet.drongo.crypto.ChildNumber) ExtendedKey(com.sparrowwallet.drongo.ExtendedKey) Test(org.junit.Test)

Aggregations

ChildNumber (com.sparrowwallet.drongo.crypto.ChildNumber)17 ECKey (com.sparrowwallet.drongo.crypto.ECKey)4 Test (org.junit.Test)4 DeterministicKey (com.sparrowwallet.drongo.crypto.DeterministicKey)3 ArrayList (java.util.ArrayList)3 Wallet (com.sparrowwallet.drongo.wallet.Wallet)2 Insets (javafx.geometry.Insets)2 HBox (javafx.scene.layout.HBox)2 ValidationSupport (org.controlsfx.validation.ValidationSupport)2 StyleClassValidationDecoration (org.controlsfx.validation.decoration.StyleClassValidationDecoration)2 ExtendedKey (com.sparrowwallet.drongo.ExtendedKey)1 KeyDerivation (com.sparrowwallet.drongo.KeyDerivation)1 Address (com.sparrowwallet.drongo.address.Address)1 ScriptType (com.sparrowwallet.drongo.protocol.ScriptType)1 Keystore (com.sparrowwallet.drongo.wallet.Keystore)1 MnemonicException (com.sparrowwallet.drongo.wallet.MnemonicException)1 WalletImportEvent (com.sparrowwallet.sparrow.event.WalletImportEvent)1 ImportException (com.sparrowwallet.sparrow.io.ImportException)1 ElectrumServer (com.sparrowwallet.sparrow.net.ElectrumServer)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1