mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
BIP32 derivation implementation
This commit is contained in:
26
src/base58.h
26
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
|
||||
|
||||
Reference in New Issue
Block a user