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

Function SendMoney

src/wallet/rpc/spend.cpp:68–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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{
70 EnsureWalletIsUnlocked(wallet);
71
72 // This function is only used by sendtoaddress and sendmany.
73 // This should always try to sign, if we don't have private keys, don't try to do anything here.
74 if (wallet.IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) {
75 throw JSONRPCError(RPC_WALLET_ERROR, "Error: Private keys are disabled for this wallet");
76 }
77
78 // Shuffle recipient list
79 std::shuffle(recipients.begin(), recipients.end(), FastRandomContext());
80
81 // Send
82 CAmount nFeeRequired = 0;
83 int nChangePosRet = -1;
84 bilingual_str error;
85 CTransactionRef tx;
86 FeeCalculation fee_calc_out;
87 auto blind_details = g_con_elementsmode ? std::make_unique<BlindDetails>() : nullptr;
88 if (blind_details) blind_details->ignore_blind_failure = ignore_blind_fail;
89 const bool fCreated = CreateTransaction(wallet, recipients, tx, nFeeRequired, nChangePosRet, error, coin_control, fee_calc_out, true, blind_details.get());
90 if (!fCreated) {
91 throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, error.original);
92 }
93 wallet.CommitTransaction(tx, std::move(map_value), {} /* orderForm */, blind_details.get());
94 if (verbose) {
95 UniValue entry(UniValue::VOBJ);
96 entry.pushKV("txid", tx->GetHash().GetHex());
97 entry.pushKV("fee_reason", StringForFeeReason(fee_calc_out.reason));
98 return entry;
99 }
100 return tx->GetHash().GetHex();
101}
102
103
104/**

Callers 5

sendtoaddressFunction · 0.85
sendmanyFunction · 0.85
sendtomainchain_baseFunction · 0.85
sendtomainchain_pakFunction · 0.85
destroyamountFunction · 0.85

Calls 12

EnsureWalletIsUnlockedFunction · 0.85
JSONRPCErrorFunction · 0.85
FastRandomContextClass · 0.85
StringForFeeReasonFunction · 0.85
IsWalletFlagSetMethod · 0.80
CommitTransactionMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
getMethod · 0.45
pushKVMethod · 0.45
GetHexMethod · 0.45
GetHashMethod · 0.45

Tested by

no test coverage detected