Use CBitcoinAddress wrappers in Zcash-specific code
This commit is contained in:
@@ -502,10 +502,10 @@ std::string CChainParams::GetFoundersRewardAddressAtHeight(int nHeight) const {
|
||||
CScript CChainParams::GetFoundersRewardScriptAtHeight(int nHeight) const {
|
||||
assert(nHeight > 0 && nHeight <= consensus.GetLastFoundersRewardBlockHeight());
|
||||
|
||||
CBitcoinAddress address(GetFoundersRewardAddressAtHeight(nHeight).c_str());
|
||||
assert(address.IsValid());
|
||||
assert(address.IsScript());
|
||||
CScriptID scriptID = boost::get<CScriptID>(address.Get()); // Get() returns a boost variant
|
||||
CTxDestination address = DecodeDestination(GetFoundersRewardAddressAtHeight(nHeight).c_str());
|
||||
assert(IsValidDestination(address));
|
||||
assert(boost::get<CScriptID>(&address) != nullptr);
|
||||
CScriptID scriptID = boost::get<CScriptID>(address); // address is a boost variant
|
||||
CScript script = CScript() << OP_HASH160 << ToByteVector(scriptID) << OP_EQUAL;
|
||||
return script;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ TEST(founders_reward_test, create_testnet_2of3multisig) {
|
||||
pWallet->AddCScript(result);
|
||||
pWallet->SetAddressBook(innerID, "", "receive");
|
||||
|
||||
std::string address = CBitcoinAddress(innerID).ToString();
|
||||
std::string address = EncodeDestination(innerID);
|
||||
addresses.push_back(address);
|
||||
}
|
||||
|
||||
|
||||
@@ -1079,8 +1079,8 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
|
||||
#ifdef ENABLE_MINING
|
||||
if (mapArgs.count("-mineraddress")) {
|
||||
CBitcoinAddress addr;
|
||||
if (!addr.SetString(mapArgs["-mineraddress"])) {
|
||||
CTxDestination addr = DecodeDestination(mapArgs["-mineraddress"]);
|
||||
if (!IsValidDestination(addr)) {
|
||||
return InitError(strprintf(
|
||||
_("Invalid address for -mineraddress=<addr>: '%s' (must be a transparent address)"),
|
||||
mapArgs["-mineraddress"]));
|
||||
@@ -1717,9 +1717,8 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
bool minerAddressInLocalWallet = false;
|
||||
if (pwalletMain) {
|
||||
// Address has alreday been validated
|
||||
CBitcoinAddress addr(mapArgs["-mineraddress"]);
|
||||
CKeyID keyID;
|
||||
addr.GetKeyID(keyID);
|
||||
CTxDestination addr = DecodeDestination(mapArgs["-mineraddress"]);
|
||||
CKeyID keyID = boost::get<CKeyID>(addr);
|
||||
minerAddressInLocalWallet = pwalletMain->HaveKey(keyID);
|
||||
}
|
||||
if (GetBoolArg("-minetolocalwallet", true) && !minerAddressInLocalWallet) {
|
||||
|
||||
@@ -395,9 +395,9 @@ boost::optional<CScript> GetMinerScriptPubKey()
|
||||
#endif
|
||||
{
|
||||
CKeyID keyID;
|
||||
CBitcoinAddress addr;
|
||||
if (addr.SetString(GetArg("-mineraddress", ""))) {
|
||||
addr.GetKeyID(keyID);
|
||||
CTxDestination addr = DecodeDestination(GetArg("-mineraddress", ""));
|
||||
if (IsValidDestination(addr)) {
|
||||
keyID = boost::get<CKeyID>(addr);
|
||||
} else {
|
||||
#ifdef ENABLE_WALLET
|
||||
CPubKey pubkey;
|
||||
|
||||
@@ -55,7 +55,7 @@ void dumpKeyInfo(uint256 privkey)
|
||||
key.SetSecret(secret, fCompressed);
|
||||
vector<unsigned char> vchPubKey = key.GetPubKey();
|
||||
printf(" * pubkey (hex): %s\n", HexStr(vchPubKey).c_str());
|
||||
printf(" * address (base58): %s\n", CBitcoinAddress(vchPubKey).ToString().c_str());
|
||||
printf(" * address (base58): %s\n", EncodeDestination(vchPubKey).c_str());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -68,18 +68,18 @@ BOOST_AUTO_TEST_CASE(rpc_addmultisig)
|
||||
const char address2Hex[] = "0388c2037017c62240b6b72ac1a2a5f94da790596ebd06177c8572752922165cb4";
|
||||
|
||||
UniValue v;
|
||||
CBitcoinAddress address;
|
||||
CTxDestination address;
|
||||
BOOST_CHECK_NO_THROW(v = addmultisig(createArgs(1, address1Hex), false));
|
||||
address.SetString(v.get_str());
|
||||
BOOST_CHECK(address.IsValid() && address.IsScript());
|
||||
address = DecodeDestination(v.get_str());
|
||||
BOOST_CHECK(IsValidDestination(address) && boost::get<CScriptID>(&address) != nullptr);
|
||||
|
||||
BOOST_CHECK_NO_THROW(v = addmultisig(createArgs(1, address1Hex, address2Hex), false));
|
||||
address.SetString(v.get_str());
|
||||
BOOST_CHECK(address.IsValid() && address.IsScript());
|
||||
address = DecodeDestination(v.get_str());
|
||||
BOOST_CHECK(IsValidDestination(address) && boost::get<CScriptID>(&address) != nullptr);
|
||||
|
||||
BOOST_CHECK_NO_THROW(v = addmultisig(createArgs(2, address1Hex, address2Hex), false));
|
||||
address.SetString(v.get_str());
|
||||
BOOST_CHECK(address.IsValid() && address.IsScript());
|
||||
address = DecodeDestination(v.get_str());
|
||||
BOOST_CHECK(IsValidDestination(address) && boost::get<CScriptID>(&address) != nullptr);
|
||||
|
||||
BOOST_CHECK_THROW(addmultisig(createArgs(0), false), runtime_error);
|
||||
BOOST_CHECK_THROW(addmultisig(createArgs(1), false), runtime_error);
|
||||
@@ -103,7 +103,7 @@ BOOST_AUTO_TEST_CASE(rpc_wallet)
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
|
||||
CPubKey demoPubkey = pwalletMain->GenerateNewKey();
|
||||
CBitcoinAddress demoAddress = CBitcoinAddress(CTxDestination(demoPubkey.GetID()));
|
||||
CTxDestination demoAddress(CTxDestination(demoPubkey.GetID()));
|
||||
UniValue retValue;
|
||||
string strAccount = "";
|
||||
string strPurpose = "receive";
|
||||
@@ -116,14 +116,14 @@ BOOST_AUTO_TEST_CASE(rpc_wallet)
|
||||
});
|
||||
|
||||
CPubKey setaccountDemoPubkey = pwalletMain->GenerateNewKey();
|
||||
CBitcoinAddress setaccountDemoAddress = CBitcoinAddress(CTxDestination(setaccountDemoPubkey.GetID()));
|
||||
CTxDestination setaccountDemoAddress(CTxDestination(setaccountDemoPubkey.GetID()));
|
||||
|
||||
/*********************************
|
||||
* setaccount
|
||||
*********************************/
|
||||
BOOST_CHECK_NO_THROW(CallRPC("setaccount " + setaccountDemoAddress.ToString() + " \"\""));
|
||||
BOOST_CHECK_NO_THROW(CallRPC("setaccount " + EncodeDestination(setaccountDemoAddress) + " \"\""));
|
||||
/* Accounts are disabled */
|
||||
BOOST_CHECK_THROW(CallRPC("setaccount " + setaccountDemoAddress.ToString() + " nullaccount"), runtime_error);
|
||||
BOOST_CHECK_THROW(CallRPC("setaccount " + EncodeDestination(setaccountDemoAddress) + " nullaccount"), runtime_error);
|
||||
/* t1VtArtnn1dGPiD2WFfMXYXW5mHM3q1GpgV is not owned by the test wallet. */
|
||||
BOOST_CHECK_THROW(CallRPC("setaccount t1VtArtnn1dGPiD2WFfMXYXW5mHM3q1GpgV nullaccount"), runtime_error);
|
||||
BOOST_CHECK_THROW(CallRPC("setaccount"), runtime_error);
|
||||
@@ -135,7 +135,7 @@ BOOST_AUTO_TEST_CASE(rpc_wallet)
|
||||
* getbalance
|
||||
*********************************/
|
||||
BOOST_CHECK_NO_THROW(CallRPC("getbalance"));
|
||||
BOOST_CHECK_THROW(CallRPC("getbalance " + demoAddress.ToString()), runtime_error);
|
||||
BOOST_CHECK_THROW(CallRPC("getbalance " + EncodeDestination(demoAddress)), runtime_error);
|
||||
|
||||
/*********************************
|
||||
* listunspent
|
||||
@@ -177,10 +177,10 @@ BOOST_AUTO_TEST_CASE(rpc_wallet)
|
||||
* listtransactions
|
||||
*********************************/
|
||||
BOOST_CHECK_NO_THROW(CallRPC("listtransactions"));
|
||||
BOOST_CHECK_NO_THROW(CallRPC("listtransactions " + demoAddress.ToString()));
|
||||
BOOST_CHECK_NO_THROW(CallRPC("listtransactions " + demoAddress.ToString() + " 20"));
|
||||
BOOST_CHECK_NO_THROW(CallRPC("listtransactions " + demoAddress.ToString() + " 20 0"));
|
||||
BOOST_CHECK_THROW(CallRPC("listtransactions " + demoAddress.ToString() + " not_int"), runtime_error);
|
||||
BOOST_CHECK_NO_THROW(CallRPC("listtransactions " + EncodeDestination(demoAddress)));
|
||||
BOOST_CHECK_NO_THROW(CallRPC("listtransactions " + EncodeDestination(demoAddress) + " 20"));
|
||||
BOOST_CHECK_NO_THROW(CallRPC("listtransactions " + EncodeDestination(demoAddress) + " 20 0"));
|
||||
BOOST_CHECK_THROW(CallRPC("listtransactions " + EncodeDestination(demoAddress) + " not_int"), runtime_error);
|
||||
|
||||
/*********************************
|
||||
* listlockunspent
|
||||
@@ -217,33 +217,33 @@ BOOST_AUTO_TEST_CASE(rpc_wallet)
|
||||
/* Accounts are deprecated */
|
||||
BOOST_CHECK_THROW(CallRPC("getaccountaddress accountThatDoesntExists"), runtime_error);
|
||||
BOOST_CHECK_NO_THROW(retValue = CallRPC("getaccountaddress " + strAccount));
|
||||
BOOST_CHECK(CBitcoinAddress(retValue.get_str()).Get() == demoAddress.Get());
|
||||
BOOST_CHECK(DecodeDestination(retValue.get_str()) == demoAddress);
|
||||
|
||||
/*********************************
|
||||
* getaccount
|
||||
*********************************/
|
||||
BOOST_CHECK_THROW(CallRPC("getaccount"), runtime_error);
|
||||
BOOST_CHECK_NO_THROW(CallRPC("getaccount " + demoAddress.ToString()));
|
||||
BOOST_CHECK_NO_THROW(CallRPC("getaccount " + EncodeDestination(demoAddress)));
|
||||
|
||||
/*********************************
|
||||
* signmessage + verifymessage
|
||||
*********************************/
|
||||
BOOST_CHECK_NO_THROW(retValue = CallRPC("signmessage " + demoAddress.ToString() + " mymessage"));
|
||||
BOOST_CHECK_NO_THROW(retValue = CallRPC("signmessage " + EncodeDestination(demoAddress) + " mymessage"));
|
||||
BOOST_CHECK_THROW(CallRPC("signmessage"), runtime_error);
|
||||
/* Should throw error because this address is not loaded in the wallet */
|
||||
BOOST_CHECK_THROW(CallRPC("signmessage t1h8SqgtM3QM5e2M8EzhhT1yL2PXXtA6oqe mymessage"), runtime_error);
|
||||
|
||||
/* missing arguments */
|
||||
BOOST_CHECK_THROW(CallRPC("verifymessage " + demoAddress.ToString()), runtime_error);
|
||||
BOOST_CHECK_THROW(CallRPC("verifymessage " + demoAddress.ToString() + " " + retValue.get_str()), runtime_error);
|
||||
BOOST_CHECK_THROW(CallRPC("verifymessage " + EncodeDestination(demoAddress)), runtime_error);
|
||||
BOOST_CHECK_THROW(CallRPC("verifymessage " + EncodeDestination(demoAddress) + " " + retValue.get_str()), runtime_error);
|
||||
/* Illegal address */
|
||||
BOOST_CHECK_THROW(CallRPC("verifymessage t1VtArtnn1dGPiD2WFfMXYXW5mHM3q1Gpg " + retValue.get_str() + " mymessage"), runtime_error);
|
||||
/* wrong address */
|
||||
BOOST_CHECK(CallRPC("verifymessage t1VtArtnn1dGPiD2WFfMXYXW5mHM3q1GpgV " + retValue.get_str() + " mymessage").get_bool() == false);
|
||||
/* Correct address and signature but wrong message */
|
||||
BOOST_CHECK(CallRPC("verifymessage " + demoAddress.ToString() + " " + retValue.get_str() + " wrongmessage").get_bool() == false);
|
||||
BOOST_CHECK(CallRPC("verifymessage " + EncodeDestination(demoAddress) + " " + retValue.get_str() + " wrongmessage").get_bool() == false);
|
||||
/* Correct address, message and signature*/
|
||||
BOOST_CHECK(CallRPC("verifymessage " + demoAddress.ToString() + " " + retValue.get_str() + " mymessage").get_bool() == true);
|
||||
BOOST_CHECK(CallRPC("verifymessage " + EncodeDestination(demoAddress) + " " + retValue.get_str() + " mymessage").get_bool() == true);
|
||||
|
||||
/*********************************
|
||||
* getaddressesbyaccount
|
||||
@@ -254,7 +254,7 @@ BOOST_AUTO_TEST_CASE(rpc_wallet)
|
||||
BOOST_CHECK_EQUAL(4, arr.size());
|
||||
bool notFound = true;
|
||||
for (auto a : arr.getValues()) {
|
||||
notFound &= CBitcoinAddress(a.get_str()).Get() != demoAddress.Get();
|
||||
notFound &= DecodeDestination(a.get_str()) != demoAddress;
|
||||
}
|
||||
BOOST_CHECK(!notFound);
|
||||
|
||||
|
||||
@@ -73,8 +73,8 @@ AsyncRPCOperation_mergetoaddress::AsyncRPCOperation_mergetoaddress(
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Recipient parameter missing");
|
||||
}
|
||||
|
||||
toTaddr_ = CBitcoinAddress(std::get<0>(recipient));
|
||||
isToTaddr_ = toTaddr_.IsValid();
|
||||
toTaddr_ = DecodeDestination(std::get<0>(recipient));
|
||||
isToTaddr_ = IsValidDestination(toTaddr_);
|
||||
isToZaddr_ = false;
|
||||
|
||||
if (!isToTaddr_) {
|
||||
@@ -246,7 +246,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl()
|
||||
rawTx.vin.push_back(in);
|
||||
}
|
||||
if (isToTaddr_) {
|
||||
CScript scriptPubKey = GetScriptForDestination(toTaddr_.Get());
|
||||
CScript scriptPubKey = GetScriptForDestination(toTaddr_);
|
||||
CTxOut out(sendAmount, scriptPubKey);
|
||||
rawTx.vout.push_back(out);
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ private:
|
||||
MergeToAddressRecipient recipient_;
|
||||
bool isToTaddr_;
|
||||
bool isToZaddr_;
|
||||
CBitcoinAddress toTaddr_;
|
||||
CTxDestination toTaddr_;
|
||||
PaymentAddress toPaymentAddress_;
|
||||
|
||||
uint256 joinSplitPubKey_;
|
||||
|
||||
@@ -74,8 +74,8 @@ AsyncRPCOperation_sendmany::AsyncRPCOperation_sendmany(
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "No recipients");
|
||||
}
|
||||
|
||||
fromtaddr_ = CBitcoinAddress(fromAddress);
|
||||
isfromtaddr_ = fromtaddr_.IsValid();
|
||||
fromtaddr_ = DecodeDestination(fromAddress);
|
||||
isfromtaddr_ = IsValidDestination(fromtaddr_);
|
||||
isfromzaddr_ = false;
|
||||
|
||||
if (!isfromtaddr_) {
|
||||
@@ -829,7 +829,8 @@ void AsyncRPCOperation_sendmany::sign_send_raw_transaction(UniValue obj)
|
||||
|
||||
|
||||
bool AsyncRPCOperation_sendmany::find_utxos(bool fAcceptCoinbase=false) {
|
||||
set<CBitcoinAddress> setAddress = {fromtaddr_};
|
||||
std::set<CTxDestination> destinations;
|
||||
destinations.insert(fromtaddr_);
|
||||
vector<COutput> vecOutputs;
|
||||
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
@@ -845,13 +846,13 @@ bool AsyncRPCOperation_sendmany::find_utxos(bool fAcceptCoinbase=false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (setAddress.size()) {
|
||||
if (destinations.size()) {
|
||||
CTxDestination address;
|
||||
if (!ExtractDestination(out.tx->vout[out.i].scriptPubKey, address)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!setAddress.count(address)) {
|
||||
if (!destinations.count(address)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -1101,12 +1102,12 @@ void AsyncRPCOperation_sendmany::add_taddr_outputs_to_tx() {
|
||||
std::string outputAddress = std::get<0>(r);
|
||||
CAmount nAmount = std::get<1>(r);
|
||||
|
||||
CBitcoinAddress address(outputAddress);
|
||||
if (!address.IsValid()) {
|
||||
CTxDestination address = DecodeDestination(outputAddress);
|
||||
if (!IsValidDestination(address)) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid output address, not a valid taddr.");
|
||||
}
|
||||
|
||||
CScript scriptPubKey = GetScriptForDestination(address.Get());
|
||||
CScript scriptPubKey = GetScriptForDestination(address);
|
||||
|
||||
CTxOut out(nAmount, scriptPubKey);
|
||||
rawTx.vout.push_back(out);
|
||||
|
||||
@@ -79,7 +79,7 @@ private:
|
||||
std::string fromaddress_;
|
||||
bool isfromtaddr_;
|
||||
bool isfromzaddr_;
|
||||
CBitcoinAddress fromtaddr_;
|
||||
CTxDestination fromtaddr_;
|
||||
PaymentAddress frompaymentaddress_;
|
||||
SpendingKey spendingkey_;
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ UniValue importprivkey(const UniValue& params, bool fHelp)
|
||||
|
||||
// Don't throw error in case a key is already there
|
||||
if (pwalletMain->HaveKey(vchAddress)) {
|
||||
return CBitcoinAddress(vchAddress).ToString();
|
||||
return EncodeDestination(vchAddress);
|
||||
}
|
||||
|
||||
pwalletMain->mapKeyMetadata[vchAddress].nCreateTime = 1;
|
||||
@@ -145,7 +145,7 @@ UniValue importprivkey(const UniValue& params, bool fHelp)
|
||||
}
|
||||
}
|
||||
|
||||
return CBitcoinAddress(vchAddress).ToString();
|
||||
return EncodeDestination(vchAddress);
|
||||
}
|
||||
|
||||
UniValue importaddress(const UniValue& params, bool fHelp)
|
||||
|
||||
@@ -3138,16 +3138,16 @@ UniValue z_listaddresses(const UniValue& params, bool fHelp)
|
||||
}
|
||||
|
||||
CAmount getBalanceTaddr(std::string transparentAddress, int minDepth=1, bool ignoreUnspendable=true) {
|
||||
set<CBitcoinAddress> setAddress;
|
||||
std::set<CTxDestination> destinations;
|
||||
vector<COutput> vecOutputs;
|
||||
CAmount balance = 0;
|
||||
|
||||
if (transparentAddress.length() > 0) {
|
||||
CBitcoinAddress taddr = CBitcoinAddress(transparentAddress);
|
||||
if (!taddr.IsValid()) {
|
||||
CTxDestination taddr = DecodeDestination(transparentAddress);
|
||||
if (!IsValidDestination(taddr)) {
|
||||
throw std::runtime_error("invalid transparent address");
|
||||
}
|
||||
setAddress.insert(taddr);
|
||||
destinations.insert(taddr);
|
||||
}
|
||||
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
@@ -3163,13 +3163,13 @@ CAmount getBalanceTaddr(std::string transparentAddress, int minDepth=1, bool ign
|
||||
continue;
|
||||
}
|
||||
|
||||
if (setAddress.size()) {
|
||||
if (destinations.size()) {
|
||||
CTxDestination address;
|
||||
if (!ExtractDestination(out.tx->vout[out.i].scriptPubKey, address)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!setAddress.count(address)) {
|
||||
if (!destinations.count(address)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -3297,8 +3297,8 @@ UniValue z_getbalance(const UniValue& params, bool fHelp)
|
||||
// Check that the from address is valid.
|
||||
auto fromaddress = params[0].get_str();
|
||||
bool fromTaddr = false;
|
||||
CBitcoinAddress taddr(fromaddress);
|
||||
fromTaddr = taddr.IsValid();
|
||||
CTxDestination taddr = DecodeDestination(fromaddress);
|
||||
fromTaddr = IsValidDestination(taddr);
|
||||
libzcash::PaymentAddress zaddr;
|
||||
if (!fromTaddr) {
|
||||
CZCPaymentAddress address(fromaddress);
|
||||
@@ -3531,8 +3531,8 @@ UniValue z_sendmany(const UniValue& params, bool fHelp)
|
||||
// Check that the from address is valid.
|
||||
auto fromaddress = params[0].get_str();
|
||||
bool fromTaddr = false;
|
||||
CBitcoinAddress taddr(fromaddress);
|
||||
fromTaddr = taddr.IsValid();
|
||||
CTxDestination taddr = DecodeDestination(fromaddress);
|
||||
fromTaddr = IsValidDestination(taddr);
|
||||
libzcash::PaymentAddress zaddr;
|
||||
if (!fromTaddr) {
|
||||
CZCPaymentAddress address(fromaddress);
|
||||
@@ -3577,8 +3577,8 @@ UniValue z_sendmany(const UniValue& params, bool fHelp)
|
||||
|
||||
string address = find_value(o, "address").get_str();
|
||||
bool isZaddr = false;
|
||||
CBitcoinAddress taddr(address);
|
||||
if (!taddr.IsValid()) {
|
||||
CTxDestination taddr = DecodeDestination(address);
|
||||
if (!IsValidDestination(taddr)) {
|
||||
try {
|
||||
CZCPaymentAddress zaddr(address);
|
||||
zaddr.Get();
|
||||
@@ -3752,10 +3752,10 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp)
|
||||
// Validate the from address
|
||||
auto fromaddress = params[0].get_str();
|
||||
bool isFromWildcard = fromaddress == "*";
|
||||
CBitcoinAddress taddr;
|
||||
CTxDestination taddr;
|
||||
if (!isFromWildcard) {
|
||||
taddr = CBitcoinAddress(fromaddress);
|
||||
if (!taddr.IsValid()) {
|
||||
taddr = DecodeDestination(fromaddress);
|
||||
if (!IsValidDestination(taddr)) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid from address, should be a taddr or \"*\".");
|
||||
}
|
||||
}
|
||||
@@ -3800,9 +3800,9 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp)
|
||||
size_t mempoolLimit = (nLimit != 0) ? nLimit : (overwinterActive ? 0 : (size_t)GetArg("-mempooltxinputlimit", 0));
|
||||
|
||||
// Set of addresses to filter utxos by
|
||||
set<CBitcoinAddress> setAddress = {};
|
||||
std::set<CTxDestination> destinations = {};
|
||||
if (!isFromWildcard) {
|
||||
setAddress.insert(taddr);
|
||||
destinations.insert(taddr);
|
||||
}
|
||||
|
||||
// Get available utxos
|
||||
@@ -3820,7 +3820,7 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp)
|
||||
continue;
|
||||
}
|
||||
// If taddr is not wildcard "*", filter utxos
|
||||
if (setAddress.size()>0 && !setAddress.count(address)) {
|
||||
if (destinations.size() > 0 && !destinations.count(address)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -3832,8 +3832,7 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp)
|
||||
CAmount nValue = out.tx->vout[out.i].nValue;
|
||||
|
||||
if (!maxedOutFlag) {
|
||||
CBitcoinAddress ba(address);
|
||||
size_t increase = (ba.IsScript()) ? CTXIN_SPEND_P2SH_SIZE : CTXIN_SPEND_DUST_SIZE;
|
||||
size_t increase = (boost::get<CScriptID>(&address) != nullptr) ? CTXIN_SPEND_P2SH_SIZE : CTXIN_SPEND_DUST_SIZE;
|
||||
if (estimatedTxSize + increase >= MAX_TX_SIZE ||
|
||||
(mempoolLimit > 0 && utxoCounter > mempoolLimit))
|
||||
{
|
||||
@@ -3976,7 +3975,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp)
|
||||
bool useAny = false;
|
||||
bool useAnyUTXO = false;
|
||||
bool useAnyNote = false;
|
||||
std::set<CBitcoinAddress> taddrs = {};
|
||||
std::set<CTxDestination> taddrs = {};
|
||||
std::set<libzcash::PaymentAddress> zaddrs = {};
|
||||
|
||||
UniValue addresses = params[0].get_array();
|
||||
@@ -3999,8 +3998,8 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp)
|
||||
} else if (address == "ANY_ZADDR") {
|
||||
useAnyNote = true;
|
||||
} else {
|
||||
CBitcoinAddress taddr(address);
|
||||
if (taddr.IsValid()) {
|
||||
CTxDestination taddr = DecodeDestination(address);
|
||||
if (IsValidDestination(taddr)) {
|
||||
// Ignore any listed t-addrs if we are using all of them
|
||||
if (!(useAny || useAnyUTXO)) {
|
||||
taddrs.insert(taddr);
|
||||
@@ -4028,8 +4027,8 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp)
|
||||
// Validate the destination address
|
||||
auto destaddress = params[1].get_str();
|
||||
bool isToZaddr = false;
|
||||
CBitcoinAddress taddr(destaddress);
|
||||
if (!taddr.IsValid()) {
|
||||
CTxDestination taddr = DecodeDestination(destaddress);
|
||||
if (!IsValidDestination(taddr)) {
|
||||
try {
|
||||
CZCPaymentAddress zaddr(destaddress);
|
||||
zaddr.Get();
|
||||
@@ -4125,8 +4124,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp)
|
||||
CAmount nValue = out.tx->vout[out.i].nValue;
|
||||
|
||||
if (!maxedOutUTXOsFlag) {
|
||||
CBitcoinAddress ba(address);
|
||||
size_t increase = (ba.IsScript()) ? CTXIN_SPEND_P2SH_SIZE : CTXIN_SPEND_DUST_SIZE;
|
||||
size_t increase = (boost::get<CScriptID>(&address) != nullptr) ? CTXIN_SPEND_P2SH_SIZE : CTXIN_SPEND_DUST_SIZE;
|
||||
if (estimatedTxSize + increase >= MAX_TX_SIZE ||
|
||||
(mempoolLimit > 0 && utxoCounter > mempoolLimit))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user