| 27 | |
| 28 | namespace wallet { |
| 29 | static void ParseRecipients(const UniValue& address_amounts, const UniValue& address_assets, const UniValue& subtract_fee_outputs, std::vector<CRecipient> &recipients) { |
| 30 | std::set<CTxDestination> destinations; |
| 31 | int i = 0; |
| 32 | for (const std::string& address: address_amounts.getKeys()) { |
| 33 | CAsset asset = Params().GetConsensus().pegged_asset; |
| 34 | if (!address_assets.isNull() && address_assets[address].isStr()) { |
| 35 | std::string strasset = address_assets[address].get_str(); |
| 36 | asset = GetAssetFromString(strasset); |
| 37 | } |
| 38 | if (asset.IsNull() && g_con_elementsmode) { |
| 39 | throw JSONRPCError(RPC_WALLET_ERROR, strprintf("Unknown label and invalid asset hex: %s", asset.GetHex())); |
| 40 | } |
| 41 | |
| 42 | CTxDestination dest = DecodeDestination(address); |
| 43 | if (!IsValidDestination(dest)) { |
| 44 | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Bitcoin address: ") + address); |
| 45 | } |
| 46 | |
| 47 | if (destinations.count(dest)) { |
| 48 | throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid parameter, duplicated address: ") + address); |
| 49 | } |
| 50 | destinations.insert(dest); |
| 51 | |
| 52 | CScript script_pub_key = GetScriptForDestination(dest); |
| 53 | CAmount amount = AmountFromValue(address_amounts[i++], asset == Params().GetConsensus().pegged_asset); |
| 54 | |
| 55 | bool subtract_fee = false; |
| 56 | for (unsigned int idx = 0; idx < subtract_fee_outputs.size(); idx++) { |
| 57 | const UniValue& addr = subtract_fee_outputs[idx]; |
| 58 | if (addr.get_str() == address) { |
| 59 | subtract_fee = true; |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | CRecipient recipient = {script_pub_key, amount, asset, GetDestinationBlindingKey(dest), subtract_fee}; |
| 64 | recipients.push_back(recipient); |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | UniValue SendMoney(CWallet& wallet, const CCoinControl &coin_control, std::vector<CRecipient> &recipients, mapValue_t map_value, bool verbose, bool ignore_blind_fail) |
| 69 | { |
no test coverage detected