@@ -224,32 +224,39 @@ class CBitcoinAddressVisitor : public boost::static_visitor<bool>
224224{
225225private:
226226 CBitcoinAddress* addr;
227+ bool IsColdStakingAddr = false ;
227228
228229public:
229- CBitcoinAddressVisitor (CBitcoinAddress* addrIn) : addr(addrIn) {}
230+ CBitcoinAddressVisitor (CBitcoinAddress* addrIn, const bool fStakingAddr = false ) :
231+ addr (addrIn),
232+ IsColdStakingAddr (fStakingAddr ){};
230233
231- bool operator ()(const CKeyID& id) const { return addr->Set (id); }
232- bool operator ()(const CScriptID& id) const { return addr->Set (id); }
234+ bool operator ()(const CKeyID& id) const { return addr->Set (id, IsColdStakingAddr ); }
235+ bool operator ()(const CScriptID& id) const { return addr->Set (id, IsColdStakingAddr ); }
233236 bool operator ()(const CNoDestination& no) const { return false ; }
234237};
235238
236239} // anon namespace
237240
238- bool CBitcoinAddress::Set (const CKeyID& id)
241+ bool CBitcoinAddress::Set (const CKeyID& id, const bool fStakingAddr )
239242{
240- SetData (Params ().Base58Prefix (CChainParams::PUBKEY_ADDRESS), &id, 20 );
243+ if (fStakingAddr ) {
244+ SetData (Params ().Base58Prefix (CChainParams::STAKING_ADDRESS), &id, 20 );
245+ } else {
246+ SetData (Params ().Base58Prefix (CChainParams::PUBKEY_ADDRESS), &id, 20 );
247+ }
241248 return true ;
242249}
243250
244- bool CBitcoinAddress::Set (const CScriptID& id)
251+ bool CBitcoinAddress::Set (const CScriptID& id, const bool fStakingAddr )
245252{
246253 SetData (Params ().Base58Prefix (CChainParams::SCRIPT_ADDRESS), &id, 20 );
247254 return true ;
248255}
249256
250- bool CBitcoinAddress::Set (const CTxDestination& dest)
257+ bool CBitcoinAddress::Set (const CTxDestination& dest, const bool fStakingAddr )
251258{
252- return boost::apply_visitor (CBitcoinAddressVisitor (this ), dest);
259+ return boost::apply_visitor (CBitcoinAddressVisitor (this , fStakingAddr ), dest);
253260}
254261
255262bool CBitcoinAddress::IsValid () const
@@ -261,7 +268,8 @@ bool CBitcoinAddress::IsValid(const CChainParams& params) const
261268{
262269 bool fCorrectSize = vchData.size () == 20 ;
263270 bool fKnownVersion = vchVersion == params.Base58Prefix (CChainParams::PUBKEY_ADDRESS) ||
264- vchVersion == params.Base58Prefix (CChainParams::SCRIPT_ADDRESS);
271+ vchVersion == params.Base58Prefix (CChainParams::SCRIPT_ADDRESS) ||
272+ vchVersion == params.Base58Prefix (CChainParams::STAKING_ADDRESS);
265273 return fCorrectSize && fKnownVersion ;
266274}
267275
@@ -271,7 +279,8 @@ CTxDestination CBitcoinAddress::Get() const
271279 return CNoDestination ();
272280 uint160 id;
273281 memcpy (&id, &vchData[0 ], 20 );
274- if (vchVersion == Params ().Base58Prefix (CChainParams::PUBKEY_ADDRESS))
282+ if (vchVersion == Params ().Base58Prefix (CChainParams::PUBKEY_ADDRESS) ||
283+ vchVersion == Params ().Base58Prefix (CChainParams::STAKING_ADDRESS))
275284 return CKeyID (id);
276285 else if (vchVersion == Params ().Base58Prefix (CChainParams::SCRIPT_ADDRESS))
277286 return CScriptID (id);
@@ -281,7 +290,9 @@ CTxDestination CBitcoinAddress::Get() const
281290
282291bool CBitcoinAddress::GetKeyID (CKeyID& keyID) const
283292{
284- if (!IsValid () || vchVersion != Params ().Base58Prefix (CChainParams::PUBKEY_ADDRESS))
293+ if (!IsValid () ||
294+ (vchVersion != Params ().Base58Prefix (CChainParams::PUBKEY_ADDRESS) &&
295+ vchVersion != Params ().Base58Prefix (CChainParams::STAKING_ADDRESS)))
285296 return false ;
286297 uint160 id;
287298 memcpy (&id, &vchData[0 ], 20 );
@@ -294,6 +305,11 @@ bool CBitcoinAddress::IsScript() const
294305 return IsValid () && vchVersion == Params ().Base58Prefix (CChainParams::SCRIPT_ADDRESS);
295306}
296307
308+ bool CBitcoinAddress::IsStakingAddress () const
309+ {
310+ return IsValid () && vchVersion == Params ().Base58Prefix (CChainParams::STAKING_ADDRESS);
311+ }
312+
297313void CBitcoinSecret::SetKey (const CKey& vchSecret)
298314{
299315 assert (vchSecret.IsValid ());
0 commit comments