MCPcopy Create free account
hub / github.com/ElementsProject/elements / ParseRecipients

Function ParseRecipients

src/wallet/rpc/spend.cpp:29–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27
28namespace wallet {
29static 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
68UniValue SendMoney(CWallet& wallet, const CCoinControl &coin_control, std::vector<CRecipient> &recipients, mapValue_t map_value, bool verbose, bool ignore_blind_fail)
69{

Callers 2

sendtoaddressFunction · 0.85
sendmanyFunction · 0.85

Calls 15

GetAssetFromStringFunction · 0.85
JSONRPCErrorFunction · 0.85
DecodeDestinationFunction · 0.85
IsValidDestinationFunction · 0.85
GetScriptForDestinationFunction · 0.85
isStrMethod · 0.80
countMethod · 0.80
ParamsClass · 0.50
AmountFromValueFunction · 0.50
isNullMethod · 0.45
IsNullMethod · 0.45

Tested by

no test coverage detected