mirror of
https://github.com/sparrowwallet/hummingbird.git
synced 2024-11-02 18:46:45 +00:00
update as per hd key parent fingerprint change (issue #52)
This commit is contained in:
parent
7ad7545749
commit
a263d00e03
5 changed files with 46 additions and 32 deletions
|
@ -2,6 +2,8 @@ package com.sparrowwallet.hummingbird.registry;
|
|||
|
||||
import co.nstant.in.cbor.model.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class CryptoHDKey {
|
||||
public static final int IS_MASTER_KEY = 1;
|
||||
public static final int IS_PRIVATE_KEY = 2;
|
||||
|
@ -10,6 +12,7 @@ public class CryptoHDKey {
|
|||
public static final int USE_INFO_KEY = 5;
|
||||
public static final int ORIGIN_KEY = 6;
|
||||
public static final int CHILDREN_KEY = 7;
|
||||
public static final int PARENT_FINGERPRINT_KEY = 8;
|
||||
|
||||
private final boolean master;
|
||||
private final boolean privateKey;
|
||||
|
@ -18,6 +21,7 @@ public class CryptoHDKey {
|
|||
private final CryptoCoinInfo useInfo;
|
||||
private final CryptoKeypath origin;
|
||||
private final CryptoKeypath children;
|
||||
private final byte[] parentFingerprint;
|
||||
|
||||
public CryptoHDKey(byte[] key, byte[] chainCode) {
|
||||
this.master = true;
|
||||
|
@ -27,9 +31,10 @@ public class CryptoHDKey {
|
|||
this.useInfo = null;
|
||||
this.origin = null;
|
||||
this.children = null;
|
||||
this.parentFingerprint = null;
|
||||
}
|
||||
|
||||
public CryptoHDKey(boolean privateKey, byte[] key, byte[] chainCode, CryptoCoinInfo useInfo, CryptoKeypath origin, CryptoKeypath children) {
|
||||
public CryptoHDKey(boolean privateKey, byte[] key, byte[] chainCode, CryptoCoinInfo useInfo, CryptoKeypath origin, CryptoKeypath children, byte[] parentFingerprint) {
|
||||
this.master = false;
|
||||
this.privateKey = privateKey;
|
||||
this.key = key;
|
||||
|
@ -37,6 +42,7 @@ public class CryptoHDKey {
|
|||
this.useInfo = useInfo;
|
||||
this.origin = origin;
|
||||
this.children = children;
|
||||
this.parentFingerprint = parentFingerprint == null ? null : Arrays.copyOfRange(parentFingerprint, parentFingerprint.length - 4, parentFingerprint.length);
|
||||
}
|
||||
|
||||
public boolean isMaster() {
|
||||
|
@ -67,6 +73,10 @@ public class CryptoHDKey {
|
|||
return children;
|
||||
}
|
||||
|
||||
public byte[] getParentFingerprint() {
|
||||
return parentFingerprint;
|
||||
}
|
||||
|
||||
public static CryptoHDKey fromCbor(DataItem item) {
|
||||
boolean isMasterKey = false;
|
||||
boolean isPrivateKey = false;
|
||||
|
@ -75,6 +85,7 @@ public class CryptoHDKey {
|
|||
CryptoCoinInfo useInfo = null;
|
||||
CryptoKeypath origin = null;
|
||||
CryptoKeypath children = null;
|
||||
byte[] parentFingerprint = null;
|
||||
|
||||
Map map = (Map)item;
|
||||
for(DataItem key : map.getKeys()) {
|
||||
|
@ -94,6 +105,8 @@ public class CryptoHDKey {
|
|||
origin = CryptoKeypath.fromCbor(map.get(uintKey));
|
||||
} else if(intKey == CHILDREN_KEY) {
|
||||
children = CryptoKeypath.fromCbor(map.get(uintKey));
|
||||
} else if(intKey == PARENT_FINGERPRINT_KEY) {
|
||||
parentFingerprint = ((UnsignedInteger)map.get(uintKey)).getValue().toByteArray();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,7 +117,7 @@ public class CryptoHDKey {
|
|||
if(isMasterKey) {
|
||||
return new CryptoHDKey(keyData, chainCode);
|
||||
} else {
|
||||
return new CryptoHDKey(isPrivateKey, keyData, chainCode, useInfo, origin, children);
|
||||
return new CryptoHDKey(isPrivateKey, keyData, chainCode, useInfo, origin, children, parentFingerprint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,20 +9,20 @@ import java.util.StringJoiner;
|
|||
|
||||
public class CryptoKeypath {
|
||||
public static final int COMPONENTS_KEY = 1;
|
||||
public static final int PARENT_FINGERPRINT_KEY = 2;
|
||||
public static final int SOURCE_FINGERPRINT_KEY = 2;
|
||||
public static final int DEPTH_KEY = 3;
|
||||
|
||||
private final List<PathComponent> components;
|
||||
private final byte[] parentFingerprint;
|
||||
private final byte[] sourceFingerprint;
|
||||
private final Integer depth;
|
||||
|
||||
public CryptoKeypath(List<PathComponent> components, byte[] parentFingerprint) {
|
||||
this(components, parentFingerprint, 0);
|
||||
public CryptoKeypath(List<PathComponent> components, byte[] sourceFingerprint) {
|
||||
this(components, sourceFingerprint, 0);
|
||||
}
|
||||
|
||||
public CryptoKeypath(List<PathComponent> components, byte[] parentFingerprint, Integer depth) {
|
||||
public CryptoKeypath(List<PathComponent> components, byte[] sourceFingerprint, Integer depth) {
|
||||
this.components = components;
|
||||
this.parentFingerprint = parentFingerprint == null ? null : Arrays.copyOfRange(parentFingerprint, parentFingerprint.length - 4, parentFingerprint.length);
|
||||
this.sourceFingerprint = sourceFingerprint == null ? null : Arrays.copyOfRange(sourceFingerprint, sourceFingerprint.length - 4, sourceFingerprint.length);
|
||||
this.depth = depth;
|
||||
}
|
||||
|
||||
|
@ -42,8 +42,8 @@ public class CryptoKeypath {
|
|||
return joiner.toString();
|
||||
}
|
||||
|
||||
public byte[] getParentFingerprint() {
|
||||
return parentFingerprint;
|
||||
public byte[] getSourceFingerprint() {
|
||||
return sourceFingerprint;
|
||||
}
|
||||
|
||||
public Integer getDepth() {
|
||||
|
@ -52,7 +52,7 @@ public class CryptoKeypath {
|
|||
|
||||
public static CryptoKeypath fromCbor(DataItem item) {
|
||||
List<PathComponent> components = new ArrayList<>();
|
||||
byte[] parentFingerprint = null;
|
||||
byte[] sourceFingerprint = null;
|
||||
Integer depth = null;
|
||||
|
||||
Map map = (Map)item;
|
||||
|
@ -71,13 +71,13 @@ public class CryptoKeypath {
|
|||
components.add(new PathComponent(hardened));
|
||||
}
|
||||
}
|
||||
} else if(intKey == PARENT_FINGERPRINT_KEY) {
|
||||
parentFingerprint = ((UnsignedInteger)map.get(key)).getValue().toByteArray();
|
||||
} else if(intKey == SOURCE_FINGERPRINT_KEY) {
|
||||
sourceFingerprint = ((UnsignedInteger)map.get(key)).getValue().toByteArray();
|
||||
} else if(intKey == DEPTH_KEY) {
|
||||
depth = ((UnsignedInteger)map.get(key)).getValue().intValue();
|
||||
}
|
||||
}
|
||||
|
||||
return new CryptoKeypath(components, parentFingerprint, depth);
|
||||
return new CryptoKeypath(components, sourceFingerprint, depth);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import java.util.List;
|
|||
public class CryptoAccountTest {
|
||||
@Test
|
||||
public void testSeed() throws CborException {
|
||||
String hex = "A2011A37B5EED40286D90193D9012FA303582103EB3E2863911826374DE86C231A4B76F0B89DFA174AFB78D7F478199884D9DD320458206456A5DF2DB0F6D9AF72B2A1AF4B25F45200ED6FCC29C3440B311D4796B70B5B06D90130A20186182CF500F500F5021A99F9CDF7D90190D90194D9012FA303582102C7E4823730F6EE2CF864E2C352060A88E60B51A84E89E4C8C75EC22590AD6B690458209D2F86043276F9251A4A4F577166A5ABEB16B6EC61E226B5B8FA11038BFDA42D06D90130A201861831F500F500F5021AA80F7CDBD90194D9012FA303582103FD433450B6924B4F7EFDD5D1ED017D364BE95AB2B592DC8BDDB3B00C1C24F63F04582072EDE7334D5ACF91C6FDA622C205199C595A31F9218ED30792D301D5EE9E3A8806D90130A201861854F500F500F5021A0D5DE1D7D90190D9012FA3035821035CCD58B63A2CDC23D0812710603592E7457573211880CB59B1EF012E168E059A04582088D3299B448F87215D96B0C226235AFC027F9E7DC700284F3E912A34DAEB1A2306D90130A20182182DF5021A37B5EED4D90190D90191D9012FA3035821032C78EBFCABDAC6D735A0820EF8732F2821B4FB84CD5D6B26526938F90C0507110458207953EFE16A73E5D3F9F2D4C6E49BD88E22093BBD85BE5A7E862A4B98A16E0AB606D90130A201881830F500F500F501F5021A59B69B2AD90191D9012FA30358210260563EE80C26844621B06B74070BAF0E23FB76CE439D0237E87502EBBD3CA3460458202FA0E41C9DC43DC4518659BFCEF935BA8101B57DBC0812805DD983BC1D34B81306D90130A201881830F500F500F502F5021A59B69B2A";
|
||||
String hex = "A2011A37B5EED40286D90193D9012FA403582103EB3E2863911826374DE86C231A4B76F0B89DFA174AFB78D7F478199884D9DD320458206456A5DF2DB0F6D9AF72B2A1AF4B25F45200ED6FCC29C3440B311D4796B70B5B06D90130A10186182CF500F500F5081A99F9CDF7D90190D90194D9012FA403582102C7E4823730F6EE2CF864E2C352060A88E60B51A84E89E4C8C75EC22590AD6B690458209D2F86043276F9251A4A4F577166A5ABEB16B6EC61E226B5B8FA11038BFDA42D06D90130A101861831F500F500F5081AA80F7CDBD90194D9012FA403582103FD433450B6924B4F7EFDD5D1ED017D364BE95AB2B592DC8BDDB3B00C1C24F63F04582072EDE7334D5ACF91C6FDA622C205199C595A31F9218ED30792D301D5EE9E3A8806D90130A101861854F500F500F5081A0D5DE1D7D90190D9012FA4035821035CCD58B63A2CDC23D0812710603592E7457573211880CB59B1EF012E168E059A04582088D3299B448F87215D96B0C226235AFC027F9E7DC700284F3E912A34DAEB1A2306D90130A10182182DF5081A37B5EED4D90190D90191D9012FA4035821032C78EBFCABDAC6D735A0820EF8732F2821B4FB84CD5D6B26526938F90C0507110458207953EFE16A73E5D3F9F2D4C6E49BD88E22093BBD85BE5A7E862A4B98A16E0AB606D90130A101881830F500F500F501F5081A59B69B2AD90191D9012FA40358210260563EE80C26844621B06B74070BAF0E23FB76CE439D0237E87502EBBD3CA3460458202FA0E41C9DC43DC4518659BFCEF935BA8101B57DBC0812805DD983BC1D34B81306D90130A101881830F500F500F502F5081A59B69B2A";
|
||||
byte[] data = TestUtils.hexToBytes(hex);
|
||||
List<DataItem> items = CborDecoder.decode(data);
|
||||
CryptoAccount cryptoAccount = CryptoAccount.fromCbor(items.get(0));
|
||||
|
@ -25,7 +25,7 @@ public class CryptoAccountTest {
|
|||
Assert.assertEquals("03eb3e2863911826374de86c231a4b76f0b89dfa174afb78d7f478199884d9dd32", TestUtils.bytesToHex(cryptoOutput1.getHdKey().getKey()));
|
||||
Assert.assertEquals("6456a5df2db0f6d9af72b2a1af4b25f45200ed6fcc29c3440b311d4796b70b5b", TestUtils.bytesToHex(cryptoOutput1.getHdKey().getChainCode()));
|
||||
Assert.assertEquals("44'/0'/0'", cryptoOutput1.getHdKey().getOrigin().getPath());
|
||||
Assert.assertEquals("99f9cdf7", TestUtils.bytesToHex(cryptoOutput1.getHdKey().getOrigin().getParentFingerprint()));
|
||||
Assert.assertEquals("99f9cdf7", TestUtils.bytesToHex(cryptoOutput1.getHdKey().getParentFingerprint()));
|
||||
Assert.assertNull(cryptoOutput1.getHdKey().getChildren());
|
||||
|
||||
CryptoOutput cryptoOutput2 = cryptoAccount.getOutputDescriptors().get(1);
|
||||
|
@ -33,7 +33,7 @@ public class CryptoAccountTest {
|
|||
Assert.assertEquals("02c7e4823730f6ee2cf864e2c352060a88e60b51a84e89e4c8c75ec22590ad6b69", TestUtils.bytesToHex(cryptoOutput2.getHdKey().getKey()));
|
||||
Assert.assertEquals("9d2f86043276f9251a4a4f577166a5abeb16b6ec61e226b5b8fa11038bfda42d", TestUtils.bytesToHex(cryptoOutput2.getHdKey().getChainCode()));
|
||||
Assert.assertEquals("49'/0'/0'", cryptoOutput2.getHdKey().getOrigin().getPath());
|
||||
Assert.assertEquals("a80f7cdb", TestUtils.bytesToHex(cryptoOutput2.getHdKey().getOrigin().getParentFingerprint()));
|
||||
Assert.assertEquals("a80f7cdb", TestUtils.bytesToHex(cryptoOutput2.getHdKey().getParentFingerprint()));
|
||||
Assert.assertNull(cryptoOutput2.getHdKey().getChildren());
|
||||
|
||||
CryptoOutput cryptoOutput3 = cryptoAccount.getOutputDescriptors().get(2);
|
||||
|
@ -41,7 +41,7 @@ public class CryptoAccountTest {
|
|||
Assert.assertEquals("03fd433450b6924b4f7efdd5d1ed017d364be95ab2b592dc8bddb3b00c1c24f63f", TestUtils.bytesToHex(cryptoOutput3.getHdKey().getKey()));
|
||||
Assert.assertEquals("72ede7334d5acf91c6fda622c205199c595a31f9218ed30792d301d5ee9e3a88", TestUtils.bytesToHex(cryptoOutput3.getHdKey().getChainCode()));
|
||||
Assert.assertEquals("84'/0'/0'", cryptoOutput3.getHdKey().getOrigin().getPath());
|
||||
Assert.assertEquals("0d5de1d7", TestUtils.bytesToHex(cryptoOutput3.getHdKey().getOrigin().getParentFingerprint()));
|
||||
Assert.assertEquals("0d5de1d7", TestUtils.bytesToHex(cryptoOutput3.getHdKey().getParentFingerprint()));
|
||||
Assert.assertNull(cryptoOutput3.getHdKey().getChildren());
|
||||
|
||||
CryptoOutput cryptoOutput4 = cryptoAccount.getOutputDescriptors().get(3);
|
||||
|
@ -49,7 +49,7 @@ public class CryptoAccountTest {
|
|||
Assert.assertEquals("035ccd58b63a2cdc23d0812710603592e7457573211880cb59b1ef012e168e059a", TestUtils.bytesToHex(cryptoOutput4.getHdKey().getKey()));
|
||||
Assert.assertEquals("88d3299b448f87215d96b0c226235afc027f9e7dc700284f3e912a34daeb1a23", TestUtils.bytesToHex(cryptoOutput4.getHdKey().getChainCode()));
|
||||
Assert.assertEquals("45'", cryptoOutput4.getHdKey().getOrigin().getPath());
|
||||
Assert.assertEquals("37b5eed4", TestUtils.bytesToHex(cryptoOutput4.getHdKey().getOrigin().getParentFingerprint()));
|
||||
Assert.assertEquals("37b5eed4", TestUtils.bytesToHex(cryptoOutput4.getHdKey().getParentFingerprint()));
|
||||
Assert.assertNull(cryptoOutput4.getHdKey().getChildren());
|
||||
|
||||
CryptoOutput cryptoOutput5 = cryptoAccount.getOutputDescriptors().get(4);
|
||||
|
@ -57,7 +57,7 @@ public class CryptoAccountTest {
|
|||
Assert.assertEquals("032c78ebfcabdac6d735a0820ef8732f2821b4fb84cd5d6b26526938f90c050711", TestUtils.bytesToHex(cryptoOutput5.getHdKey().getKey()));
|
||||
Assert.assertEquals("7953efe16a73e5d3f9f2d4c6e49bd88e22093bbd85be5a7e862a4b98a16e0ab6", TestUtils.bytesToHex(cryptoOutput5.getHdKey().getChainCode()));
|
||||
Assert.assertEquals("48'/0'/0'/1'", cryptoOutput5.getHdKey().getOrigin().getPath());
|
||||
Assert.assertEquals("59b69b2a", TestUtils.bytesToHex(cryptoOutput5.getHdKey().getOrigin().getParentFingerprint()));
|
||||
Assert.assertEquals("59b69b2a", TestUtils.bytesToHex(cryptoOutput5.getHdKey().getParentFingerprint()));
|
||||
Assert.assertNull(cryptoOutput5.getHdKey().getChildren());
|
||||
|
||||
CryptoOutput cryptoOutput6 = cryptoAccount.getOutputDescriptors().get(5);
|
||||
|
@ -65,15 +65,15 @@ public class CryptoAccountTest {
|
|||
Assert.assertEquals("0260563ee80c26844621b06b74070baf0e23fb76ce439d0237e87502ebbd3ca346", TestUtils.bytesToHex(cryptoOutput6.getHdKey().getKey()));
|
||||
Assert.assertEquals("2fa0e41c9dc43dc4518659bfcef935ba8101b57dbc0812805dd983bc1d34b813", TestUtils.bytesToHex(cryptoOutput6.getHdKey().getChainCode()));
|
||||
Assert.assertEquals("48'/0'/0'/2'", cryptoOutput6.getHdKey().getOrigin().getPath());
|
||||
Assert.assertEquals("59b69b2a", TestUtils.bytesToHex(cryptoOutput6.getHdKey().getOrigin().getParentFingerprint()));
|
||||
Assert.assertEquals("59b69b2a", TestUtils.bytesToHex(cryptoOutput6.getHdKey().getParentFingerprint()));
|
||||
Assert.assertNull(cryptoOutput6.getHdKey().getChildren());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAccount() throws Exception {
|
||||
byte[] cbor = TestUtils.hexToBytes("A2011A37B5EED40286D90193D9012FA303582103EB3E2863911826374DE86C231A4B76F0B89DFA174AFB78D7F478199884D9DD320458206456A5DF2DB0F6D9AF72B2A1AF4B25F45200ED6FCC29C3440B311D4796B70B5B06D90130A20186182CF500F500F5021A99F9CDF7D90190D90194D9012FA303582102C7E4823730F6EE2CF864E2C352060A88E60B51A84E89E4C8C75EC22590AD6B690458209D2F86043276F9251A4A4F577166A5ABEB16B6EC61E226B5B8FA11038BFDA42D06D90130A201861831F500F500F5021AA80F7CDBD90194D9012FA303582103FD433450B6924B4F7EFDD5D1ED017D364BE95AB2B592DC8BDDB3B00C1C24F63F04582072EDE7334D5ACF91C6FDA622C205199C595A31F9218ED30792D301D5EE9E3A8806D90130A201861854F500F500F5021A0D5DE1D7D90190D9012FA3035821035CCD58B63A2CDC23D0812710603592E7457573211880CB59B1EF012E168E059A04582088D3299B448F87215D96B0C226235AFC027F9E7DC700284F3E912A34DAEB1A2306D90130A20182182DF5021A37B5EED4D90190D90191D9012FA3035821032C78EBFCABDAC6D735A0820EF8732F2821B4FB84CD5D6B26526938F90C0507110458207953EFE16A73E5D3F9F2D4C6E49BD88E22093BBD85BE5A7E862A4B98A16E0AB606D90130A201881830F500F500F501F5021A59B69B2AD90191D9012FA30358210260563EE80C26844621B06B74070BAF0E23FB76CE439D0237E87502EBBD3CA3460458202FA0E41C9DC43DC4518659BFCEF935BA8101B57DBC0812805DD983BC1D34B81306D90130A201881830F500F500F502F5021A59B69B2A");
|
||||
byte[] cbor = TestUtils.hexToBytes("A2011A37B5EED40286D90193D9012FA403582103EB3E2863911826374DE86C231A4B76F0B89DFA174AFB78D7F478199884D9DD320458206456A5DF2DB0F6D9AF72B2A1AF4B25F45200ED6FCC29C3440B311D4796B70B5B06D90130A10186182CF500F500F5081A99F9CDF7D90190D90194D9012FA403582102C7E4823730F6EE2CF864E2C352060A88E60B51A84E89E4C8C75EC22590AD6B690458209D2F86043276F9251A4A4F577166A5ABEB16B6EC61E226B5B8FA11038BFDA42D06D90130A101861831F500F500F5081AA80F7CDBD90194D9012FA403582103FD433450B6924B4F7EFDD5D1ED017D364BE95AB2B592DC8BDDB3B00C1C24F63F04582072EDE7334D5ACF91C6FDA622C205199C595A31F9218ED30792D301D5EE9E3A8806D90130A101861854F500F500F5081A0D5DE1D7D90190D9012FA4035821035CCD58B63A2CDC23D0812710603592E7457573211880CB59B1EF012E168E059A04582088D3299B448F87215D96B0C226235AFC027F9E7DC700284F3E912A34DAEB1A2306D90130A10182182DF5081A37B5EED4D90190D90191D9012FA4035821032C78EBFCABDAC6D735A0820EF8732F2821B4FB84CD5D6B26526938F90C0507110458207953EFE16A73E5D3F9F2D4C6E49BD88E22093BBD85BE5A7E862A4B98A16E0AB606D90130A101881830F500F500F501F5081A59B69B2AD90191D9012FA40358210260563EE80C26844621B06B74070BAF0E23FB76CE439D0237E87502EBBD3CA3460458202FA0E41C9DC43DC4518659BFCEF935BA8101B57DBC0812805DD983BC1D34B81306D90130A101881830F500F500F502F5081A59B69B2A");
|
||||
UR ur = new UR("crypto-account", cbor);
|
||||
String encoded = UREncoder.encode(ur);
|
||||
Assert.assertEquals("ur:crypto-account/oeadcyemrewytyaolntaadmutaaddlotaxhdclaxwmfmdeiamecsdsemgtvsjzcncygrkowtrontzschgezokstswkkscfmklrtauteyaahdcxiehfonurdppfyntapejpproypegrdawkgmaewejlsfdtsrfybdehcaflmtrlbdhpamtaaddyoeadlncsdwykaeykaeykaocynlytsnyltaadmhtaadmwtaaddlotaxhdclaostvelfemdyynwydwyaievosrgmambklovabdgypdglldvespsthysadamhpmjeinaahdcxntdllnaaeykoytdacygegwhgjsiyonpywmcmrpwphsvodsrerozsbyaxluzcoxdpamtaaddyoeadlncsehykaeykaeykaocypdbskeuytaadmwtaaddlotaxhdclaxzcfxeegdrpmogrgwkbzctlttweadkiengrwlhtprremouoluutqdpfbncedkynfhaahdcxjpwevdeogthttkmeswzcolcpsaahcfnshkhtehytclmnteatmoteadtlwynnftloamtaaddyoeadlncsghykaeykaeykaocybthlvytstaadmhtaaddlotaxhdclaxhhsnhdrpftdwuocntilydibehnecmovdfekpjkclcslasbhkpawsaddmcmmnahnyaahdcxlotedtndfymyltclhlmtpfsadscnhtztaolbnnkistaedegwfmmedreetnwmcycnamtaaddyoeadlfcsdpykaocyemrewytytaadmhtaadmetaaddlotaxhdclaxdwkswmztpytnswtsecnblfbayajkdldeclqzzolrsnhljedsgminetytbnahatbyaahdcxkkguwsvyimjkvwteytwztyswvendtpmncpasfrrylprnhtkblndrgrmkoyjtbkrpamtaaddyoeadlocsdyykaeykaeykadykaocyhkrpnddrtaadmetaaddlotaxhdclaohnhffmvsbndslrfgclpfjejyatbdpebacnzokotofxntaoemvskpaowmryfnotfgaahdcxdlnbvecentssfsssgylnhkrstoytecrdlyadrekirfaybglahltalsrfcaeerobwamtaaddyoeadlocsdyykaeykaeykaoykaocyhkrpnddrasqdckhh", encoded);
|
||||
Assert.assertEquals("ur:crypto-account/oeadcyemrewytyaolntaadmutaaddloxaxhdclaxwmfmdeiamecsdsemgtvsjzcncygrkowtrontzschgezokstswkkscfmklrtauteyaahdcxiehfonurdppfyntapejpproypegrdawkgmaewejlsfdtsrfybdehcaflmtrlbdhpamtaaddyoyadlncsdwykaeykaeykaycynlytsnyltaadmhtaadmwtaaddloxaxhdclaostvelfemdyynwydwyaievosrgmambklovabdgypdglldvespsthysadamhpmjeinaahdcxntdllnaaeykoytdacygegwhgjsiyonpywmcmrpwphsvodsrerozsbyaxluzcoxdpamtaaddyoyadlncsehykaeykaeykaycypdbskeuytaadmwtaaddloxaxhdclaxzcfxeegdrpmogrgwkbzctlttweadkiengrwlhtprremouoluutqdpfbncedkynfhaahdcxjpwevdeogthttkmeswzcolcpsaahcfnshkhtehytclmnteatmoteadtlwynnftloamtaaddyoyadlncsghykaeykaeykaycybthlvytstaadmhtaaddloxaxhdclaxhhsnhdrpftdwuocntilydibehnecmovdfekpjkclcslasbhkpawsaddmcmmnahnyaahdcxlotedtndfymyltclhlmtpfsadscnhtztaolbnnkistaedegwfmmedreetnwmcycnamtaaddyoyadlfcsdpykaycyemrewytytaadmhtaadmetaaddloxaxhdclaxdwkswmztpytnswtsecnblfbayajkdldeclqzzolrsnhljedsgminetytbnahatbyaahdcxkkguwsvyimjkvwteytwztyswvendtpmncpasfrrylprnhtkblndrgrmkoyjtbkrpamtaaddyoyadlocsdyykaeykaeykadykaycyhkrpnddrtaadmetaaddloxaxhdclaohnhffmvsbndslrfgclpfjejyatbdpebacnzokotofxntaoemvskpaowmryfnotfgaahdcxdlnbvecentssfsssgylnhkrstoytecrdlyadrekirfaybglahltalsrfcaeerobwamtaaddyoyadlocsdyykaeykaeykaoykaycyhkrpnddrgdaogykb", encoded);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public class CryptoHDKeyTest {
|
|||
|
||||
@Test
|
||||
public void testPublicTestnet() throws CborException {
|
||||
String hex = "A4035821026FE2355745BB2DB3630BBC80EF5D58951C963C841F54170BA6E5C12BE7FC12A6045820CED155C72456255881793514EDC5BD9447E7F74ABB88C6D6B6480FD016EE8C8505D90131A1020106D90130A2018A182CF501F501F500F401F4021AE9181CF3";
|
||||
String hex = "A5035821026FE2355745BB2DB3630BBC80EF5D58951C963C841F54170BA6E5C12BE7FC12A6045820CED155C72456255881793514EDC5BD9447E7F74ABB88C6D6B6480FD016EE8C8505D90131A1020106D90130A1018A182CF501F501F500F401F4081AE9181CF3";
|
||||
byte[] data = TestUtils.hexToBytes(hex);
|
||||
List<DataItem> items = CborDecoder.decode(data);
|
||||
CryptoHDKey cryptoHDKey = CryptoHDKey.fromCbor(items.get(0));
|
||||
|
@ -33,7 +33,7 @@ public class CryptoHDKeyTest {
|
|||
Assert.assertEquals("ced155c72456255881793514edc5bd9447e7f74abb88c6d6b6480fd016ee8c85", TestUtils.bytesToHex(cryptoHDKey.getChainCode()));
|
||||
Assert.assertEquals(cryptoHDKey.getUseInfo().getNetwork(), CryptoCoinInfo.Network.TESTNET);
|
||||
Assert.assertEquals("44'/1'/1'/0/1", cryptoHDKey.getOrigin().getPath());
|
||||
Assert.assertEquals("e9181cf3", TestUtils.bytesToHex(cryptoHDKey.getOrigin().getParentFingerprint()));
|
||||
Assert.assertEquals("e9181cf3", TestUtils.bytesToHex(cryptoHDKey.getParentFingerprint()));
|
||||
Assert.assertNull(cryptoHDKey.getChildren());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public class CryptoOutputTest {
|
|||
|
||||
@Test
|
||||
public void testP2PKH() throws CborException {
|
||||
String hex = "d90193d9012fa403582102d2b36900396c9282fa14628566582f206a5dd0bcc8d5e892611806cafb0301f0045820637807030d55d01f9a0cb3a7839515d796bd07706386a6eddf06cc29a65a0e2906d90130a20186182cf500f500f5021ad34db33f07d90130a1018401f480f4";
|
||||
String hex = "d90193d9012fa503582102d2b36900396c9282fa14628566582f206a5dd0bcc8d5e892611806cafb0301f0045820637807030d55d01f9a0cb3a7839515d796bd07706386a6eddf06cc29a65a0e2906d90130a20186182cf500f500f5021ad34db33f07d90130a1018401f480f4081a78412e3a";
|
||||
byte[] data = TestUtils.hexToBytes(hex);
|
||||
List<DataItem> items = CborDecoder.decode(data);
|
||||
CryptoOutput cryptoOutput = CryptoOutput.fromCbor(items.get(0));
|
||||
|
@ -57,9 +57,10 @@ public class CryptoOutputTest {
|
|||
Assert.assertEquals("02d2b36900396c9282fa14628566582f206a5dd0bcc8d5e892611806cafb0301f0", TestUtils.bytesToHex(cryptoOutput.getHdKey().getKey()));
|
||||
Assert.assertEquals("637807030d55d01f9a0cb3a7839515d796bd07706386a6eddf06cc29a65a0e29", TestUtils.bytesToHex(cryptoOutput.getHdKey().getChainCode()));
|
||||
Assert.assertEquals("44'/0'/0'", cryptoOutput.getHdKey().getOrigin().getPath());
|
||||
Assert.assertEquals("d34db33f", TestUtils.bytesToHex(cryptoOutput.getHdKey().getOrigin().getParentFingerprint()));
|
||||
Assert.assertEquals("d34db33f", TestUtils.bytesToHex(cryptoOutput.getHdKey().getOrigin().getSourceFingerprint()));
|
||||
Assert.assertEquals("78412e3a", TestUtils.bytesToHex(cryptoOutput.getHdKey().getParentFingerprint()));
|
||||
Assert.assertEquals("1/*", cryptoOutput.getHdKey().getChildren().getPath());
|
||||
Assert.assertNull(cryptoOutput.getHdKey().getChildren().getParentFingerprint());
|
||||
Assert.assertNull(cryptoOutput.getHdKey().getChildren().getSourceFingerprint());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -76,18 +77,18 @@ public class CryptoOutputTest {
|
|||
Assert.assertEquals("03cbcaa9c98c877a26977d00825c956a238e8dddfbd322cce4f74b0b5bd6ace4a7", TestUtils.bytesToHex(firstKey.getKey()));
|
||||
Assert.assertEquals("60499f801b896d83179a4374aeb7822aaeaceaa0db1f85ee3e904c4defbd9689", TestUtils.bytesToHex(firstKey.getChainCode()));
|
||||
Assert.assertNull(firstKey.getOrigin().getPath());
|
||||
Assert.assertNull(firstKey.getOrigin().getParentFingerprint());
|
||||
Assert.assertNull(firstKey.getOrigin().getSourceFingerprint());
|
||||
Assert.assertEquals(Integer.valueOf(0), firstKey.getOrigin().getDepth());
|
||||
Assert.assertEquals("1/0/*", firstKey.getChildren().getPath());
|
||||
Assert.assertNull(firstKey.getChildren().getParentFingerprint());
|
||||
Assert.assertNull(firstKey.getChildren().getSourceFingerprint());
|
||||
|
||||
CryptoHDKey secondKey = cryptoOutput.getMultiKey().getHdKeys().get(1);
|
||||
Assert.assertEquals("02fc9e5af0ac8d9b3cecfe2a888e2117ba3d089d8585886c9c826b6b22a98d12ea", TestUtils.bytesToHex(secondKey.getKey()));
|
||||
Assert.assertEquals("f0909affaa7ee7abe5dd4e100598d4dc53cd709d5a5c2cac40e7412f232f7c9c", TestUtils.bytesToHex(secondKey.getChainCode()));
|
||||
Assert.assertEquals("0", secondKey.getOrigin().getPath());
|
||||
Assert.assertEquals("bd16bee5", TestUtils.bytesToHex(secondKey.getOrigin().getParentFingerprint()));
|
||||
Assert.assertEquals("bd16bee5", TestUtils.bytesToHex(secondKey.getOrigin().getSourceFingerprint()));
|
||||
Assert.assertNull(secondKey.getOrigin().getDepth());
|
||||
Assert.assertEquals("0/0/*", secondKey.getChildren().getPath());
|
||||
Assert.assertNull(secondKey.getChildren().getParentFingerprint());
|
||||
Assert.assertNull(secondKey.getChildren().getSourceFingerprint());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue