- fix Decode call (req. only one param)
- add constructor for base58c->CExtKey
The current Decode() call with two parameters won't compile (not detected because the c++ temple never was evaluated).
Also adds test coverage.
The current Decode() call with two parameters won't compile (not detected because the c++ temple never was evaluated).
Also adds test coverage.
- fix Decode call (req. only one param)
- add constructor for base58c->CExtKey
ACK
Added a tiny comment on top to prevent a crash when one tries to get a key from a CBitcoinExtKeyBase instance where no base58 decoded data is available.
145 | @@ -146,7 +146,8 @@ template<typename K, int Size, CChainParams::Base58Type Type> class CBitcoinExtK 146 | 147 | K GetKey() { 148 | K ret; 149 | - ret.Decode(&vchData[0], &vchData[Size]); 150 | + if (vchData.size() == 74) //if base58 encouded data not holds a ext key, return a !IsValid() key
Nit: Indentation and space after begin of comment.
I'm not sure that a fixed size check is a robust solution here (also, hardwiring 74 without any kind of constant) - doesn't the underlying decode function return an error if it couldn't decode?
OK I understand now why. ret.Decode takes a fixed-size object of 74 bytes. In that case, please define a constant.
I didn't add a constant because fixing this is already covered in: #6215. The Decode really expects 74 bytes (=hardcode check okay IMO)
Force push fixed @Diapolo nit.
145 | @@ -146,7 +146,8 @@ template<typename K, int Size, CChainParams::Base58Type Type> class CBitcoinExtK 146 | 147 | K GetKey() { 148 | K ret; 149 | - ret.Decode(&vchData[0], &vchData[Size]); 150 | + if (vchData.size() == Size) //if base58 encouded data not holds a ext key, return a !IsValid() key
replaced the magic 74 with the template var Size
ACK, apart from style nit.
Fixed @sipa 's nit.