public void DerivePubkeyTest() { ExtPubkey parent = new ExtPubkey("tpubDBwZbsX7C1m4tfHxHSFBvvuasqMxzMvSNM5yuAWz6kAfCATAgegvrtGdnxkqfr8wwRZi5d9fJHXqE8EFTSogTXd3xVx3GUFy9Xcg8dufREz"); ExtPubkey key = parent.DerivePubkey("0/44"); Assert.Equal("tpubDF7yNiHQHdfns9Mc3XM7PYcS2dqrPqcit3FLkebvHxS4atZxifANou2KTvpQQQP82ANDCkPc5MPQZ28pjYGgmDXGy1iyzaiX6MTBv8i4cua", key.ToString()); Assert.Equal("03f1e767c0555ce0105b2a76d0f8b19b6d33a147f82f75a05c4c09580c39694fd3", key.GetPubkey().ToHexString()); Assert.Equal("839fb0d66f1887db167cdc530ab98e871d8b017ebcb198568874b6c98516364e", key.GetChainCode().ToHexString()); Assert.Equal("043587cf", key.GetVersion().ToHexString()); Assert.Equal("a53a8ff3", key.GetFingerprint().ToHexString()); Assert.Equal((uint)44, key.GetChildNumber()); Assert.Equal((uint)4, key.GetDepth()); Assert.Equal(CfdNetworkType.Testnet, key.GetNetworkType()); Assert.True(key.IsValid()); ExtPubkey key1 = parent.DerivePubkey(0).DerivePubkey(44); ExtPubkey key2 = parent.DerivePubkey(new uint[] { 0, 44 }); Assert.Equal(key.ToString(), key1.ToString()); Assert.Equal(key.ToString(), key2.ToString()); Assert.True(key.Equals(key2)); }
public void DerivePubkeyTest() { ExtPrivkey parent = new ExtPrivkey("xprv9zt1onyw8BdEf7SQ6wUVH3bQQdGD9iy9QzXveQQRhX7i5iUN7jZgLbqFEe491LfjozztYa6bJAGZ65GmDCNcbjMdjZcgmdisPJwVjcfcDhV"); ExtPubkey key = parent.DerivePrivkey("0/44'").GetExtPubkey(); uint childNumber = 0x8000002c; Assert.Equal("xpub6JNQxQDHv2vcUQiXjggbaGYZg3nmxX6ojMcJPSs4KfLSLnMBCg8VbJUh5n4to2SwLWXdSXnHBkUQx1fVnJ9oKYjPPYAQehjWRpx6ErQyykX", key.ToString()); Assert.Equal(childNumber, key.GetChildNumber()); Assert.Equal((uint)6, key.GetDepth()); Assert.Equal(CfdNetworkType.Mainnet, key.GetNetworkType()); Assert.True(key.IsValid()); ExtPubkey key1 = parent.DerivePrivkey(0).DerivePrivkey(childNumber).GetExtPubkey(); ExtPubkey key2 = parent.DerivePrivkey(new uint[] { 0, childNumber }).GetExtPubkey(); Assert.Equal(key.ToString(), key1.ToString()); Assert.Equal(key.ToString(), key2.ToString()); Assert.True(key.Equals(key2)); }