Fix sendmany bug for Alright (#1336)

* fix sendmany bug, when sending to multiple address diffrent amounts would always use the first seen value.

* Possible fix for multi node musig. Needs to be tested. Was getting stuck at nonce stage, as reported by gcharang.
This commit is contained in:
blackjok3rtt
2019-03-18 15:22:20 +08:00
committed by jl777
parent 05977b8af6
commit d8d7463ea0
2 changed files with 5 additions and 9 deletions

View File

@@ -1457,24 +1457,19 @@ UniValue sendmany(const UniValue& params, bool fHelp)
if (params.size() > 4)
subtractFeeFromAmount = params[4].get_array();
std::set<CTxDestination> destinations;
std::vector<CRecipient> vecSend;
CAmount totalAmount = 0;
std::vector<std::string> keys = sendTo.getKeys();
int32_t i = 0;
for (const std::string& name_ : keys) {
CTxDestination dest = DecodeDestination(name_);
if (!IsValidDestination(dest)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Zcash address: ") + name_);
}
/*if (destinations.count(dest)) {
throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid parameter, duplicated address: ") + name_);
}*/
destinations.insert(dest);
CScript scriptPubKey = GetScriptForDestination(dest);
CAmount nAmount = AmountFromValue(sendTo[name_]);
CAmount nAmount = AmountFromValue(sendTo[i]);
if (nAmount <= 0)
throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send");
totalAmount += nAmount;
@@ -1488,6 +1483,7 @@ UniValue sendmany(const UniValue& params, bool fHelp)
CRecipient recipient = {scriptPubKey, nAmount, fSubtractFeeFromAmount};
vecSend.push_back(recipient);
i++;
}
EnsureWalletIsUnlocked();