-
Notifications
You must be signed in to change notification settings - Fork 37.8k
fix CBitcoinExtKeyBase template #6468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix CBitcoinExtKeyBase template #6468
Conversation
0739a38
to
c6ec07f
Compare
- fix Decode call (req. only one param) - add constructor for base58c->CExtKey
c6ec07f
to
8d2af54
Compare
ACK |
Added a tiny comment on top to prevent a crash when one tries to get a key from a |
@@ -146,7 +146,8 @@ template<typename K, int Size, CChainParams::Base58Type Type> class CBitcoinExtK | |||
|
|||
K GetKey() { | |||
K ret; | |||
ret.Decode(&vchData[0], &vchData[Size]); | |||
if (vchData.size() == 74) //if base58 encouded data not holds a ext key, return a !IsValid() key |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Indentation and space after begin of comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK I understand now why. ret.Decode takes a fixed-size object of 74 bytes.
In that case, please define a constant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't add a constant because fixing this is already covered in: #6215.
The Decode really expects 74 bytes (=hardcode check okay IMO)
93efc57
to
5c46b2b
Compare
Force push fixed @Diapolo nit. |
5c46b2b
to
5c6a28c
Compare
@@ -146,7 +146,8 @@ template<typename K, int Size, CChainParams::Base58Type Type> class CBitcoinExtK | |||
|
|||
K GetKey() { | |||
K ret; | |||
ret.Decode(&vchData[0], &vchData[Size]); | |||
if (vchData.size() == Size) //if base58 encouded data not holds a ext key, return a !IsValid() key |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replaced the magic 74
with the template var Size
ACK, apart from style nit. |
@sipa Let me ask, what is happening with our clang-format cleanup ;)? |
5c6a28c
to
6f8b6d3
Compare
Fixed @sipa 's nit. |
- fix Decode call (req. only one param) Github-Pull: bitcoin#6468 Partial-Rebased-From: 7cb1f9f
- fix Decode call (req. only one param) - add constructor for base58c->CExtKey Github-Pull: bitcoin#6468 Rebased-From: 7cb1f9f
Github-Pull: bitcoin#6468 Rebased-From: 8d2af54
Github-Pull: bitcoin#6468 Rebased-From: 6f8b6d3
- fix Decode call (req. only one param) Github-Pull: bitcoin#6468 Partial-Rebased-From: 7cb1f9f
- fix Decode call (req. only one param) - add constructor for base58c->CExtKey Github-Pull: bitcoin#6468 Rebased-From: 7cb1f9f
Github-Pull: bitcoin#6468 Rebased-From: 8d2af54
Github-Pull: bitcoin#6468 Rebased-From: 6f8b6d3
Bitcoin 0.12 misc PRs 1 Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#6198 - bitcoin/bitcoin#6206 - bitcoin/bitcoin#5927 - bitcoin/bitcoin#6213 - bitcoin/bitcoin#6061 - bitcoin/bitcoin#6283 (partial, remainder was pulled in #929) - bitcoin/bitcoin#6272 - bitcoin/bitcoin#6316 - bitcoin/bitcoin#6133 - bitcoin/bitcoin#6387 - bitcoin/bitcoin#6401 - bitcoin/bitcoin#6434 - bitcoin/bitcoin#6372 - bitcoin/bitcoin#6447 - bitcoin/bitcoin#6149 - bitcoin/bitcoin#6468 Part of #2074.
aa633c8 CBase58Data::SetString: cleanse the full vector (Kaz Wesley) 0b77f8a Improve readability of DecodeBase58Check(...) (practicalswift) dadadee Use prefix operator in for loop of DecodeBase58. (Jiaxing Wang) 305c382 base58: Improve DecodeBase58 performance. (Jiaxing Wang) 3cb418b Improve EncodeBase58 performance (João Barbosa) 4d17f71 don't try to decode invalid encoded ext keys (Jonas Schnelli) eef4ec6 extend bip32 tests to cover Base58c/CExtKey decode (furszy) 7239aaf fix and extend CBitcoinExtKeyBase template - fix Decode call (req. only one param) - add constructor for base58c->CExtKey (furszy) 13f09c3 remove unused inv from ConnectTip() (furszy) Pull request description: Coming from: * bitcoin#6468 . * bitcoin#7656 . * bitcoin#7922 * bitcoin#8736 . * bitcoin#10961 . ACKs for top commit: random-zebra: ACK aa633c8 Fuzzbawls: ACK aa633c8 Tree-SHA512: 3add3106a847b0b3d768df2c4ab5eae7d009e3820998fb5a4cd274169c64622e83ecd14dca51c31f3f6053199834129a1c6920b7ef1193632339297a041173d6
The current
Decode()
call with two parameters won't compile (not detected because the c++ temple never was evaluated).Also adds test coverage.