diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2013-07-15 01:05:25 +0200 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2013-07-15 01:05:25 +0200 |
commit | eb2c999050cc17f8926bfa7a3dad74801c7ac4af (patch) | |
tree | c5adba99014c72f7f465f4732b137309fb11bf58 /src/base58.h | |
parent | 8388289eb6dfc9add233f8f8b536f84caf771fa6 (diff) |
BIP32 derivation implementation
Diffstat (limited to 'src/base58.h')
-rw-r--r-- | src/base58.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/base58.h b/src/base58.h index 1d4c3ee294..aabae8de88 100644 --- a/src/base58.h +++ b/src/base58.h @@ -390,4 +390,30 @@ public: } }; + +template<typename K, int Size, CChainParams::Base58Type Type> class CBitcoinExtKeyBase : public CBase58Data +{ +public: + void SetKey(const K &key) { + unsigned char vch[Size]; + key.Encode(vch); + SetData(Params().Base58Prefix(Type), vch, vch+Size); + } + + K GetKey() { + K ret; + ret.Decode(&vchData[0], &vchData[Size]); + return ret; + } + + CBitcoinExtKeyBase(const K &key) { + SetKey(key); + } + + CBitcoinExtKeyBase() {} +}; + +typedef CBitcoinExtKeyBase<CExtKey, 74, CChainParams::EXT_SECRET_KEY> CBitcoinExtKey; +typedef CBitcoinExtKeyBase<CExtPubKey, 74, CChainParams::EXT_PUBLIC_KEY> CBitcoinExtPubKey; + #endif // BITCOIN_BASE58_H |