-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Prepare for non-Base58 addresses #11117
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
Conversation
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.
There is this pattern
DecodeDestination();
if (!IsValidDestination()) {
What about:
CTxDestination dest;
if (!DecodeDestination(str, dest)) {
Also, to avoid more usages of CBitcoinAddress
, add commit to move it to base58.cpp
?
src/bitcoin-tx.cpp
Outdated
// build standard output script via GetScriptForDestination() | ||
CScript scriptPubKey = GetScriptForDestination(addr.Get()); | ||
CTxDestination destination = DecodeDestination(strAddr); | ||
if (!IsValidDestination(destination)) throw std::runtime_error("invalid TX output address"); |
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.
Block instead?
if (...) {
throw ...;
}
src/rpc/rawtransaction.cpp
Outdated
if (setAddress.count(address)) | ||
throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid parameter, duplicated address: ")+name_); | ||
setAddress.insert(address); | ||
if (destinations.count(destination)) { |
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.
Change to
if (!destinations.insert(destination).second) {
if (pwallet->mapAddressBook.count(address.Get())) { | ||
std::string strOldAccount = pwallet->mapAddressBook[address.Get()].name; | ||
if (address == GetAccountAddress(pwallet, strOldAccount)) { | ||
if (pwallet->mapAddressBook.count(dest)) { |
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, kind of unrelated, use .find()
to avoid 2nd lookup below.
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.
Trying to keep this as much of a straightforward change as possible, as it may need backporting.
CBitcoinAddress address(request.params[0].get_str()); | ||
if (!address.IsValid()) | ||
CTxDestination dest = DecodeDestination(request.params[0].get_str()); | ||
if (!IsValidDestination(dest)) { | ||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address"); |
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.
Follow up, should the error message be Invalid destination address
?
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.
An address is just the string-encoded form of a CTxDestination, so no. I think the "destination" name should be internal.
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.
Off topic, just Invalid address
as it seems irrelevant to have Bitcoin
in the error message?
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.
Oh, sure!
src/wallet/rpcwallet.cpp
Outdated
if (!IsValidDestination(dest)) { | ||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Bitcoin address: ") + input.get_str()); | ||
} | ||
if (destinations.count(dest)) { |
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.
Replace with .insert().second
like above.
There are plenty of cases where the result of decoding can just be passed to something else, and The current pattern is indeed a bit verbose, but once we rewrite |
36eb9f2
to
8363a2c
Compare
@sipa sure, I just wanted to question that "style" because it's used elsewhere. ACK 8363a2c. |
utACK 8363a2ccaffba793068db4f97184121730707104 |
Added 0.15.1 milestone |
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.
utACK 8363a2ccaffba793068db4f97184121730707104
LGTM. I skipped over QT stuff as I don't know it very well.
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.
utACK other than the keyID issue.
@@ -82,14 +82,14 @@ class AddressTablePriv | |||
LOCK(wallet->cs_wallet); | |||
for (const std::pair<CTxDestination, CAddressBookData>& item : wallet->mapAddressBook) | |||
{ | |||
const CBitcoinAddress& address = item.first; |
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've stared at this for 5 min now. What trickery made this work before?
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.
It was creating a temporary of type CBitcoinAddress by converting the CTxDestination initializer, using the implicit CBitcoinAddress(const CTxDestination &dest)
constructor. That temporary's lifetime was then extended by taking a reference to it, named address
.
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.
Interesting, I didn't know an implicit conversion could be done when extending the lifetime of a const ref. Scary!
src/qt/signverifymessagedialog.cpp
Outdated
if (!addr.GetKeyID(keyID)) | ||
{ | ||
const CKeyID* keyID = boost::get<CKeyID>(&destination); | ||
if (keyID) { |
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.
!keyID
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.
Good catch.
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.
Wow, thanks :S
@@ -317,3 +317,7 @@ CScript GetScriptForWitness(const CScript& redeemscript) | |||
ret << OP_0 << ToByteVector(hash); | |||
return ret; | |||
} | |||
|
|||
bool IsValidDestination(const CTxDestination& dest) { | |||
return dest.which() != 0; |
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.
Maybe add a quick comment that this is CNoDestination so it comes up when grepping for future changes.
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.
Could use !(operator==)
instead?
*/ | ||
typedef boost::variant<CNoDestination, CKeyID, CScriptID> CTxDestination; | ||
|
||
/** Check whether a CTxDestination is a CNoDestination. */ |
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.
got it. ignore last nit.
addressInfo.push_back(ValueFromAmount(balances[address])); | ||
{ | ||
if (pwallet->mapAddressBook.find(CBitcoinAddress(address).Get()) != pwallet->mapAddressBook.end()) { |
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.
heh.
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.
It took me a while to figure out what this CBitcoinAddress
was doing. Answer: nothing at all.
8363a2c
to
7e7a025
Compare
7e7a025
to
4bc71a6
Compare
Removed |
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.
Since this is the base for Bech32, maybe move everything related to CTxDestination
out of base58, including tests, to a new place. Also move CTxDestination
definition and related functions from src/script/standard.h
?
At least should be done in a follow up?
src/base58.cpp
Outdated
@@ -12,6 +12,7 @@ | |||
#include <string.h> | |||
#include <vector> | |||
#include <string> | |||
#include <algorithm> |
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, sort.
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.
Fixed.
src/qt/sendcoinsdialog.cpp
Outdated
|
||
if (text.isEmpty()) // Nothing entered | ||
{ | ||
ui->labelCoinControlChangeLabel->setText(""); | ||
} | ||
else if (!addr.IsValid()) // Invalid address | ||
else if (!IsValidDestination(destination)) // Invalid address |
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, fix braces.
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.
Not going to reflow this entire function in a PR intended for backporting.
|
||
UniValue ret(UniValue::VOBJ); | ||
ret.push_back(Pair("isvalid", isValid)); | ||
if (isValid) | ||
{ | ||
CTxDestination dest = address.Get(); | ||
std::string currentAddress = address.ToString(); | ||
std::string currentAddress = EncodeDestination(dest); |
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.
Could use currentAddress = request.params[0].get_str();
?
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.
There may be reasons not to do that. Bech32 addresses (added in a later PR) can be uppercase or lowercase, but we always want to store and look up in lowercase form. This is an easy way of doing that, and we should probably check that it's done consistently elsewhere too.
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.
Agree, I'm +1 for clear data validation and/or sanitization. Although encode(decode(data))
is a obscure way of doing it, not to mention encode(decode(data))
should equal data
?
f77636b
to
3144af1
Compare
Yes, read the PR description. I plan to do this, but not in a patch that's intended for backporting.
Why? To where? |
3144af1
to
87d5c28
Compare
utACK 87d5c28 though I do not know the QT stuff well. |
@promag Yes, I removed it again. This PR is just the part that is likely to break easily and need non-trivial rebasing. |
src/qt/transactiondesc.cpp
Outdated
{ | ||
CTxDestination address = CBitcoinAddress(rec->address).Get(); | ||
if (IsValidDestination(rec->address)) { | ||
CTxDestination address = DecodeDestination(rec->address); |
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.
This incur in a double decoding since above IsValidDestination
also decodes. Maybe swap:
CTxDestination address = DecodeDestination(rec->address);
if (IsValidDestination(address)) {
This is how it's done multiples times in this PR.
Not sure if we support this version, but I get the following compile error with clang 3.5.0:
Then a lot of note: candidate function not viable like:
Edit: Ok, to answer my own question @morcos, the 0.13.0 release notes mention:
So yes we should try to support 3.5. |
I confirm that @JeremyRubin's workaround makes it compile. Edit: after discussion it seems likely that this is due to a boost version difference, not a compiler difference. |
87d5c28
to
8dc36db
Compare
Refactor t-address encoding Includes code cherry-picked from the following upstream PRs: - bitcoin/bitcoin#11117 - bitcoin/bitcoin#11259 - Only the second commit (first is for QT code) - bitcoin/bitcoin#11167 - Only the first commit (the rest are not part of the t-address encoding refactor). Part of zcash#3058. Precursor to zcash#3202.
Refactor t-address encoding Includes code cherry-picked from the following upstream PRs: - bitcoin/bitcoin#11117 - bitcoin/bitcoin#11259 - Only the second commit (first is for QT code) - bitcoin/bitcoin#11167 - Only the first commit (the rest are not part of the t-address encoding refactor). Part of zcash#3058. Precursor to zcash#3202.
864cd27 Move CBitcoinAddress to base58.cpp (Pieter Wuille) 5c8ff0d Introduce wrappers around CBitcoinAddress (Pieter Wuille) Pull request description: This patch removes the need for the intermediary Base58 type `CBitcoinAddress`, by providing {`Encode`,`Decode`,`IsValid`}`Destination` functions that directly operate on the conversion between `std::string`s and `CTxDestination`. As a side, it also fixes a number of indentation issues, and removes probably several unnecessary implicit `CTxDestination`<->`CBitcoinAddress` conversions. This change is far from complete. In follow-ups I'd like to: * Split off the specific address and key encoding logic from base58.h, and move it to a address.h or so. * Replace `CTxDestination` with a non-`boost::variant` version (which can be more efficient as `boost::variant` allocates everything on the heap, and remove the need for `boost::get<...>` and `IsValidDestination` calls everywhere). * Do the same for `CBitcoinSecret`, `CBitcoinExtKey`, and `CBitcoinExtPubKey`. However, I've tried to keep this patch to be minimally invasive, but still enough to support non-Base58 addresses. Perhaps a smaller patch is possible to hack Bech32 support into `CBitcoinAddress`, but I would consider that a move in the wrong direction. Tree-SHA512: c2c77ffb57caeadf2429b1c2562ce60e8c7be8aa9f8e51b591f354b6b441162625b2efe14c023a1ae485cf2ed417263afa35c892891dfaa7844e7fbabccab85e
864cd27 Move CBitcoinAddress to base58.cpp (Pieter Wuille) 5c8ff0d Introduce wrappers around CBitcoinAddress (Pieter Wuille) Pull request description: This patch removes the need for the intermediary Base58 type `CBitcoinAddress`, by providing {`Encode`,`Decode`,`IsValid`}`Destination` functions that directly operate on the conversion between `std::string`s and `CTxDestination`. As a side, it also fixes a number of indentation issues, and removes probably several unnecessary implicit `CTxDestination`<->`CBitcoinAddress` conversions. This change is far from complete. In follow-ups I'd like to: * Split off the specific address and key encoding logic from base58.h, and move it to a address.h or so. * Replace `CTxDestination` with a non-`boost::variant` version (which can be more efficient as `boost::variant` allocates everything on the heap, and remove the need for `boost::get<...>` and `IsValidDestination` calls everywhere). * Do the same for `CBitcoinSecret`, `CBitcoinExtKey`, and `CBitcoinExtPubKey`. However, I've tried to keep this patch to be minimally invasive, but still enough to support non-Base58 addresses. Perhaps a smaller patch is possible to hack Bech32 support into `CBitcoinAddress`, but I would consider that a move in the wrong direction. Tree-SHA512: c2c77ffb57caeadf2429b1c2562ce60e8c7be8aa9f8e51b591f354b6b441162625b2efe14c023a1ae485cf2ed417263afa35c892891dfaa7844e7fbabccab85e
Based on: - bitcoin#11117 - bitcoin#11167 Related to: - https://github.com/bitcoin/bitcoin/pull/11372/filesDecodeBase58Check
Based on: - bitcoin#11117 - bitcoin#11167 Related to: - https://github.com/bitcoin/bitcoin/pull/11372/filesDecodeBase58Check
Based on: - bitcoin#11117 - bitcoin#11167 Related to: - https://github.com/bitcoin/bitcoin/pull/11372/filesDecodeBase58Check
Based on: - bitcoin#11117 - bitcoin#11167 Related to: - https://github.com/bitcoin/bitcoin/pull/11372/filesDecodeBase58Check
Based on: - bitcoin#11117 - bitcoin#11167 Related to: - https://github.com/bitcoin/bitcoin/pull/11372/filesDecodeBase58Check
Based on: - bitcoin#11117 - bitcoin#11167 Related to: - https://github.com/bitcoin/bitcoin/pull/11372/filesDecodeBase58Check
864cd27 Move CBitcoinAddress to base58.cpp (Pieter Wuille) 5c8ff0d Introduce wrappers around CBitcoinAddress (Pieter Wuille) Pull request description: This patch removes the need for the intermediary Base58 type `CBitcoinAddress`, by providing {`Encode`,`Decode`,`IsValid`}`Destination` functions that directly operate on the conversion between `std::string`s and `CTxDestination`. As a side, it also fixes a number of indentation issues, and removes probably several unnecessary implicit `CTxDestination`<->`CBitcoinAddress` conversions. This change is far from complete. In follow-ups I'd like to: * Split off the specific address and key encoding logic from base58.h, and move it to a address.h or so. * Replace `CTxDestination` with a non-`boost::variant` version (which can be more efficient as `boost::variant` allocates everything on the heap, and remove the need for `boost::get<...>` and `IsValidDestination` calls everywhere). * Do the same for `CBitcoinSecret`, `CBitcoinExtKey`, and `CBitcoinExtPubKey`. However, I've tried to keep this patch to be minimally invasive, but still enough to support non-Base58 addresses. Perhaps a smaller patch is possible to hack Bech32 support into `CBitcoinAddress`, but I would consider that a move in the wrong direction. Tree-SHA512: c2c77ffb57caeadf2429b1c2562ce60e8c7be8aa9f8e51b591f354b6b441162625b2efe14c023a1ae485cf2ed417263afa35c892891dfaa7844e7fbabccab85e
* Merge bitcoin#11117: Prepare for non-Base58 addresses 864cd27 Move CBitcoinAddress to base58.cpp (Pieter Wuille) 5c8ff0d Introduce wrappers around CBitcoinAddress (Pieter Wuille) Pull request description: This patch removes the need for the intermediary Base58 type `CBitcoinAddress`, by providing {`Encode`,`Decode`,`IsValid`}`Destination` functions that directly operate on the conversion between `std::string`s and `CTxDestination`. As a side, it also fixes a number of indentation issues, and removes probably several unnecessary implicit `CTxDestination`<->`CBitcoinAddress` conversions. This change is far from complete. In follow-ups I'd like to: * Split off the specific address and key encoding logic from base58.h, and move it to a address.h or so. * Replace `CTxDestination` with a non-`boost::variant` version (which can be more efficient as `boost::variant` allocates everything on the heap, and remove the need for `boost::get<...>` and `IsValidDestination` calls everywhere). * Do the same for `CBitcoinSecret`, `CBitcoinExtKey`, and `CBitcoinExtPubKey`. However, I've tried to keep this patch to be minimally invasive, but still enough to support non-Base58 addresses. Perhaps a smaller patch is possible to hack Bech32 support into `CBitcoinAddress`, but I would consider that a move in the wrong direction. Tree-SHA512: c2c77ffb57caeadf2429b1c2562ce60e8c7be8aa9f8e51b591f354b6b441162625b2efe14c023a1ae485cf2ed417263afa35c892891dfaa7844e7fbabccab85e * CBitcoinAddress -> EncodeDestination in providertx.h Signed-off-by: Pasta <pasta@dashboost.org> * more CBitcoinAddress -> EncodeDestination in providertx.h Signed-off-by: Pasta <pasta@dashboost.org> * more CBitcoinAddress -> EncodeDestination in providertx.h Signed-off-by: Pasta <pasta@dashboost.org> * more CBitcoinAddress -> EncodeDestination in providertx.h Signed-off-by: Pasta <pasta@dashboost.org> * fix CBitcoinAddress GetKeyID check Signed-off-by: Pasta <pasta@dashboost.org> * fix providertx.cpp Signed-off-by: Pasta <pasta@dashboost.org> * hopefully fix governance-classes.cpp Signed-off-by: Pasta <pasta@dashboost.org> * partially fix governance-validators.cpp, unable to resolve "address.IsScript()" Signed-off-by: Pasta <pasta@dashboost.org> * partially fix governance-classes.cpp, unable to resolve "address.IsScript()" Signed-off-by: Pasta <pasta@dashboost.org> * fix governance-classes.h Signed-off-by: Pasta <pasta@dashboost.org> * DecodeTransaction -> DecodeDestination, fix governance-validators.cpp Signed-off-by: Pasta <pasta@dashboost.org> * More fixes for 3294 * Move GetIndexKey into rpc/misc.cpp near getAddressesFromParams No need to have it in base58.cpp anymore as this is only used in getAddressesFromParams Co-authored-by: Wladimir J. van der Laan <laanwj@gmail.com> Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com> Co-authored-by: Alexander Block <ablock84@gmail.com>
86e6dd4 Remove duplicate destination decoding (João Barbosa) 8d0041e Remove unused GetKeyID and IsScript methods from CBitcoinAddress (João Barbosa) Pull request description: Follow up of bitcoin#11117, this patch removes an extra unnecessary destination decoding that was identified while reviewing bitcoin#11117. It is also the only case where `IsValidDestinationString` is called before `DecodeDestination`. For reference see [comment](bitcoin#11117 (comment)). Tree-SHA512: f5ff5cb28a576ccd819a058f102188bde55654f30618520cc680c91d2f6e536fe038fc7220dd2d2dd64c6175fcb23f89b94b48444521e11ddec0b2f8ef2c05dd
86e6dd4 Remove duplicate destination decoding (João Barbosa) 8d0041e Remove unused GetKeyID and IsScript methods from CBitcoinAddress (João Barbosa) Pull request description: Follow up of bitcoin#11117, this patch removes an extra unnecessary destination decoding that was identified while reviewing bitcoin#11117. It is also the only case where `IsValidDestinationString` is called before `DecodeDestination`. For reference see [comment](bitcoin#11117 (comment)). Tree-SHA512: f5ff5cb28a576ccd819a058f102188bde55654f30618520cc680c91d2f6e536fe038fc7220dd2d2dd64c6175fcb23f89b94b48444521e11ddec0b2f8ef2c05dd
86e6dd4 Remove duplicate destination decoding (João Barbosa) 8d0041e Remove unused GetKeyID and IsScript methods from CBitcoinAddress (João Barbosa) Pull request description: Follow up of bitcoin#11117, this patch removes an extra unnecessary destination decoding that was identified while reviewing bitcoin#11117. It is also the only case where `IsValidDestinationString` is called before `DecodeDestination`. For reference see [comment](bitcoin#11117 (comment)). Tree-SHA512: f5ff5cb28a576ccd819a058f102188bde55654f30618520cc680c91d2f6e536fe038fc7220dd2d2dd64c6175fcb23f89b94b48444521e11ddec0b2f8ef2c05dd
86e6dd4b6 Remove duplicate destination decoding (João Barbosa) 8d0041e60 Remove unused GetKeyID and IsScript methods from CBitcoinAddress (João Barbosa) Pull request description: Follow up of #11117, this patch removes an extra unnecessary destination decoding that was identified while reviewing #11117. It is also the only case where `IsValidDestinationString` is called before `DecodeDestination`. For reference see [comment](bitcoin/bitcoin#11117 (comment)). Tree-SHA512: f5ff5cb28a576ccd819a058f102188bde55654f30618520cc680c91d2f6e536fe038fc7220dd2d2dd64c6175fcb23f89b94b48444521e11ddec0b2f8ef2c05dd
ac99512 [Model] Do not return a Destination if getNewAddress fails. (furszy) cba200c CBitcoinAddress replacement for CTxDestionation encoding in RPC files. (furszy) e319981 GUI CBitcoinAddress moved to the CTxDestination abstraction. (furszy) 6e29c1d Tier two related CBitcoinAddress moved to the CTxDestination abstraction (furszy) 8436183 getNewAddress moved to CTxDestination and Destination wrapper connected to the GUI (furszy) fd5bd3d Destination wrapper class + DestinationFor method created. (furszy) 849c03a Introduce wrappers around CBitcoinAddress (furszy) Pull request description: This patch removes the need for the intermediary Base58 type CBitcoinAddress, by providing {Encode,Decode,IsValid} Destination functions that directly operate on the conversion between std::strings and CTxDestination. As a side, it also fixes a number of indentation issues, and removes probably several unnecessary implicit CTxDestination<->CBitcoinAddress conversions. It's not a small change but it will give us much more flexibility once it's fully done over every current and new address type. The first commit is coming from upstream partially ([11117](bitcoin#11117)), the rest is purely tackling our code (we have so so many more places using the CBitcoinAddress class). And finally, have implemented a second abstraction (`Destination` wrapper) on top of the base58 address to {Encode,Decode,IsValid} Staking addresses as well. **Note:** This migration is not fully complete. It's first step, we still have places using the CBitcoinAddress object instead of the CTxDestination abstraction. ACKs for top commit: Fuzzbawls: ACK ac99512 random-zebra: ACK ac99512 and merging... Tree-SHA512: 94388eb487948b4600749047fd4b63d651c2da3dc34a01746a50d0ae73e4d851e1a9afe4f1a371936581368b174de178e8a0f77032ba6606657339473513f904
e07286d Remove possibly confusing IsValidDestinationString(str) (furszy) a7bafa1 Implement {Encode,Decode}Destination without CBitcoinAddress (furszy) 7d3ba5d Remove unused GetKeyID and IsScript methods from CBitcoinAddress (furszy) e7c5d9a Move CBitcoinAddress to base58.cpp (furszy) 548f828 Final migration from CBitcoinAddress to the destionation wrapper (furszy) Pull request description: Finished the complete removal of the base58 address class from the sources, migrated to the destination wrapper. Plus includes bitcoin#11117 - last commit - and bitcoin#11259 as an extra. ACKs for top commit: random-zebra: utACK e07286d Fuzzbawls: utACK e07286d Tree-SHA512: b2bf4c5ed10f863f0de7ab57a87610fddab1bbe21a1f585006e5c370ba3c04635fb1314a9d9a80b2c15a66d5bfe34fd9590dc113f0d91d93d33eb37344c7f8fe
Based on: - bitcoin#11117 - bitcoin#11167 Related to: - https://github.com/bitcoin/bitcoin/pull/11372/filesDecodeBase58Check
An overview of commits that implement an initial switch from using CBitcoinAddress to CTxDestination using bech32 (in line with Bitcoin's implementation). A 80% implementation (not cleaned up) can be found in our archives: - cevap/ion-old-v3@3b30fd0 - cevap/ion-old-v3@f8ee3a8 - cevap/ion-old-v3@7f87033 - cevap/ion-old-v3@f0d2206 - cevap/ion-old-v3@dbddc7b - cevap/ion-old-v3@e834f27 - cevap/ion-old-v3@2c467e1 - cevap/ion-old-v3@ef36201 - cevap/ion-old-v3@3d6e391 Implementing this switch in full is future work, which needs: - bitcoin#11117 - bitcoin#11167 - bitcoin#11372
Based on: - bitcoin#11117 - bitcoin#11167 Related to: - https://github.com/bitcoin/bitcoin/pull/11372/filesDecodeBase58Check
An overview of commits that implement an initial switch from using CBitcoinAddress to CTxDestination using bech32 (in line with Bitcoin's implementation). A 80% implementation (not cleaned up) can be found in our archives: - cevap/ion-old-v3@3b30fd0 - cevap/ion-old-v3@f8ee3a8 - cevap/ion-old-v3@7f87033 - cevap/ion-old-v3@f0d2206 - cevap/ion-old-v3@dbddc7b - cevap/ion-old-v3@e834f27 - cevap/ion-old-v3@2c467e1 - cevap/ion-old-v3@ef36201 - cevap/ion-old-v3@3d6e391 Implementing this switch in full is future work, which needs: - bitcoin#11117 - bitcoin#11167 - bitcoin#11372
* Merge bitcoin#11117: Prepare for non-Base58 addresses 864cd27 Move CBitcoinAddress to base58.cpp (Pieter Wuille) 5c8ff0d Introduce wrappers around CBitcoinAddress (Pieter Wuille) Pull request description: This patch removes the need for the intermediary Base58 type `CBitcoinAddress`, by providing {`Encode`,`Decode`,`IsValid`}`Destination` functions that directly operate on the conversion between `std::string`s and `CTxDestination`. As a side, it also fixes a number of indentation issues, and removes probably several unnecessary implicit `CTxDestination`<->`CBitcoinAddress` conversions. This change is far from complete. In follow-ups I'd like to: * Split off the specific address and key encoding logic from base58.h, and move it to a address.h or so. * Replace `CTxDestination` with a non-`boost::variant` version (which can be more efficient as `boost::variant` allocates everything on the heap, and remove the need for `boost::get<...>` and `IsValidDestination` calls everywhere). * Do the same for `CBitcoinSecret`, `CBitcoinExtKey`, and `CBitcoinExtPubKey`. However, I've tried to keep this patch to be minimally invasive, but still enough to support non-Base58 addresses. Perhaps a smaller patch is possible to hack Bech32 support into `CBitcoinAddress`, but I would consider that a move in the wrong direction. Tree-SHA512: c2c77ffb57caeadf2429b1c2562ce60e8c7be8aa9f8e51b591f354b6b441162625b2efe14c023a1ae485cf2ed417263afa35c892891dfaa7844e7fbabccab85e * CBitcoinAddress -> EncodeDestination in providertx.h Signed-off-by: Pasta <pasta@dashboost.org> * more CBitcoinAddress -> EncodeDestination in providertx.h Signed-off-by: Pasta <pasta@dashboost.org> * more CBitcoinAddress -> EncodeDestination in providertx.h Signed-off-by: Pasta <pasta@dashboost.org> * more CBitcoinAddress -> EncodeDestination in providertx.h Signed-off-by: Pasta <pasta@dashboost.org> * fix CBitcoinAddress GetKeyID check Signed-off-by: Pasta <pasta@dashboost.org> * fix providertx.cpp Signed-off-by: Pasta <pasta@dashboost.org> * hopefully fix governance-classes.cpp Signed-off-by: Pasta <pasta@dashboost.org> * partially fix governance-validators.cpp, unable to resolve "address.IsScript()" Signed-off-by: Pasta <pasta@dashboost.org> * partially fix governance-classes.cpp, unable to resolve "address.IsScript()" Signed-off-by: Pasta <pasta@dashboost.org> * fix governance-classes.h Signed-off-by: Pasta <pasta@dashboost.org> * DecodeTransaction -> DecodeDestination, fix governance-validators.cpp Signed-off-by: Pasta <pasta@dashboost.org> * More fixes for 3294 * Move GetIndexKey into rpc/misc.cpp near getAddressesFromParams No need to have it in base58.cpp anymore as this is only used in getAddressesFromParams Co-authored-by: Wladimir J. van der Laan <laanwj@gmail.com> Co-authored-by: UdjinM6 <UdjinM6@users.noreply.github.com> Co-authored-by: Alexander Block <ablock84@gmail.com>
This patch removes the need for the intermediary Base58 type
CBitcoinAddress
, by providing {Encode
,Decode
,IsValid
}Destination
functions that directly operate on the conversion betweenstd::string
s andCTxDestination
.As a side, it also fixes a number of indentation issues, and removes probably several unnecessary implicit
CTxDestination
<->CBitcoinAddress
conversions.This change is far from complete. In follow-ups I'd like to:
CTxDestination
with a non-boost::variant
version (which can be more efficient asboost::variant
allocates everything on the heap, and remove the need forboost::get<...>
andIsValidDestination
calls everywhere).CBitcoinSecret
,CBitcoinExtKey
, andCBitcoinExtPubKey
.However, I've tried to keep this patch to be minimally invasive, but still enough to support non-Base58 addresses. Perhaps a smaller patch is possible to hack Bech32 support into
CBitcoinAddress
, but I would consider that a move in the wrong direction.