From 20266ac91112cf753a6c74b8b13d2d2c49540937 Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Wed, 29 Dec 2021 13:44:55 -0700 Subject: [PATCH] Remove uses of KeyIO::DecodeDestination --- qa/rpc-tests/wallet_shieldingcoinbase.py | 8 +- src/chainparams.cpp | 8 +- src/consensus/params.cpp | 29 ++- src/init.cpp | 15 +- .../asyncrpcoperation_mergetoaddress.cpp | 39 +++- src/wallet/asyncrpcoperation_sendmany.cpp | 38 +++- src/wallet/asyncrpcoperation_sendmany.h | 10 +- src/wallet/rpcwallet.cpp | 190 ++++++++++-------- src/wallet/test/rpc_wallet_tests.cpp | 17 +- 9 files changed, 216 insertions(+), 138 deletions(-) diff --git a/qa/rpc-tests/wallet_shieldingcoinbase.py b/qa/rpc-tests/wallet_shieldingcoinbase.py index 01f7ee8e6..129af7011 100755 --- a/qa/rpc-tests/wallet_shieldingcoinbase.py +++ b/qa/rpc-tests/wallet_shieldingcoinbase.py @@ -82,9 +82,11 @@ class WalletShieldingCoinbaseTest (BitcoinTestFramework): # Node 3 will test that watch only address utxos are not selected self.nodes[3].importaddress(mytaddr) recipients= [{"address":myzaddr, "amount": Decimal('1')}] - myopid = self.nodes[3].z_sendmany(mytaddr, recipients) - - wait_and_assert_operationid_status(self.nodes[3], myopid, "failed", "Insufficient transparent funds, no UTXOs found for taddr from address.", 10) + try: + myopid = self.nodes[3].z_sendmany(mytaddr, recipients) + except JSONRPCException as e: + errorString = e.error['message'] + assert_equal("Invalid from address: does not belong to this node, spending key not found.", errorString); # This send will fail because our wallet does not allow any change when shielding a coinbase utxo, # as it's currently not possible to specify a change address in z_sendmany. diff --git a/src/chainparams.cpp b/src/chainparams.cpp index d9a7cb182..d117db8ee 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -822,10 +822,10 @@ CScript CChainParams::GetFoundersRewardScriptAtHeight(int nHeight) const { assert(nHeight > 0 && nHeight <= consensus.GetLastFoundersRewardBlockHeight(nHeight)); KeyIO keyIO(*this); - CTxDestination address = keyIO.DecodeDestination(GetFoundersRewardAddressAtHeight(nHeight).c_str()); - assert(IsValidDestination(address)); - assert(IsScriptDestination(address)); - CScriptID scriptID = std::get(address); // address is a variant + auto address = keyIO.DecodePaymentAddress(GetFoundersRewardAddressAtHeight(nHeight).c_str()); + assert(address.has_value()); + assert(std::holds_alternative(address.value())); + CScriptID scriptID = std::get(address.value()); CScript script = CScript() << OP_HASH160 << ToByteVector(scriptID) << OP_EQUAL; return script; } diff --git a/src/consensus/params.cpp b/src/consensus/params.cpp index 58528b7b4..f1641e7aa 100644 --- a/src/consensus/params.cpp +++ b/src/consensus/params.cpp @@ -9,6 +9,7 @@ #include