extend bip32 tests to cover Base58c/CExtKey decode
This commit is contained in:
parent
7cb1f9f7eb
commit
8d2af54ecc
1 changed files with 11 additions and 0 deletions
|
@ -88,12 +88,23 @@ void RunTest(const TestVector &test) {
|
||||||
unsigned char data[74];
|
unsigned char data[74];
|
||||||
key.Encode(data);
|
key.Encode(data);
|
||||||
pubkey.Encode(data);
|
pubkey.Encode(data);
|
||||||
|
|
||||||
// Test private key
|
// Test private key
|
||||||
CBitcoinExtKey b58key; b58key.SetKey(key);
|
CBitcoinExtKey b58key; b58key.SetKey(key);
|
||||||
BOOST_CHECK(b58key.ToString() == derive.prv);
|
BOOST_CHECK(b58key.ToString() == derive.prv);
|
||||||
|
|
||||||
|
CBitcoinExtKey b58keyDecodeCheck(derive.prv);
|
||||||
|
CExtKey checkKey = b58keyDecodeCheck.GetKey();
|
||||||
|
assert(checkKey == key); //ensure a base58 decoded key also matches
|
||||||
|
|
||||||
// Test public key
|
// Test public key
|
||||||
CBitcoinExtPubKey b58pubkey; b58pubkey.SetKey(pubkey);
|
CBitcoinExtPubKey b58pubkey; b58pubkey.SetKey(pubkey);
|
||||||
BOOST_CHECK(b58pubkey.ToString() == derive.pub);
|
BOOST_CHECK(b58pubkey.ToString() == derive.pub);
|
||||||
|
|
||||||
|
CBitcoinExtPubKey b58PubkeyDecodeCheck(derive.pub);
|
||||||
|
CExtPubKey checkPubKey = b58PubkeyDecodeCheck.GetKey();
|
||||||
|
assert(checkPubKey == pubkey); //ensure a base58 decoded pubkey also matches
|
||||||
|
|
||||||
// Derive new keys
|
// Derive new keys
|
||||||
CExtKey keyNew;
|
CExtKey keyNew;
|
||||||
BOOST_CHECK(key.Derive(keyNew, derive.nChild));
|
BOOST_CHECK(key.Derive(keyNew, derive.nChild));
|
||||||
|
|
Loading…
Reference in a new issue