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

Function sendtoaddress

src/wallet/rpc/spend.cpp:141–259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139}
140
141RPCHelpMan sendtoaddress()
142{
143 return RPCHelpMan{"sendtoaddress",
144 "\nSend an amount to a given address." +
145 HELP_REQUIRING_PASSPHRASE,
146 {
147 {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The address to send to."},
148 {"amount", RPCArg::Type::AMOUNT, RPCArg::Optional::NO, "The amount in " + CURRENCY_UNIT + " to send. eg 0.1"},
149 {"comment", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, "A comment used to store what the transaction is for.\n"
150 "This is not part of the transaction, just kept in your wallet."},
151 {"comment_to", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, "A comment to store the name of the person or organization\n"
152 "to which you're sending the transaction. This is not part of the \n"
153 "transaction, just kept in your wallet."},
154 {"subtractfeefromamount", RPCArg::Type::BOOL, RPCArg::Default{false}, "The fee will be deducted from the amount being sent.\n"
155 "The recipient will receive less bitcoins than you enter in the amount field."},
156 {"replaceable", RPCArg::Type::BOOL, RPCArg::DefaultHint{"wallet default"}, "Allow this transaction to be replaced by a transaction with higher fees via BIP 125"},
157 {"conf_target", RPCArg::Type::NUM, RPCArg::DefaultHint{"wallet -txconfirmtarget"}, "Confirmation target in blocks"},
158 {"estimate_mode", RPCArg::Type::STR, RPCArg::Default{"unset"}, std::string() + "The fee estimate mode, must be one of (case insensitive):\n"
159 " \"" + FeeModes("\"\n\"") + "\""},
160 {"avoid_reuse", RPCArg::Type::BOOL, RPCArg::Default{true}, "(only available if avoid_reuse wallet flag is set) Avoid spending from dirty addresses; addresses are considered\n"
161 "dirty if they have previously been used in a transaction. If true, this also activates avoidpartialspends, grouping outputs by their addresses."},
162 {"assetlabel", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, "Hex asset id or asset label for balance."},
163 {"ignoreblindfail", RPCArg::Type::BOOL, RPCArg::Default{true}, "Return a transaction even when a blinding attempt fails due to number of blinded inputs/outputs."},
164 {"fee_rate", RPCArg::Type::AMOUNT, RPCArg::DefaultHint{"not set, fall back to wallet fee estimation"}, "Specify a fee rate in " + CURRENCY_ATOM + "/vB."},
165 {"verbose", RPCArg::Type::BOOL, RPCArg::Default{false}, "If true, return extra information about the transaction."},
166 },
167 {
168 RPCResult{"if verbose is not set or set to false",
169 RPCResult::Type::STR_HEX, "txid", "The transaction id."
170 },
171 RPCResult{"if verbose is set to true",
172 RPCResult::Type::OBJ, "", "",
173 {
174 {RPCResult::Type::STR_HEX, "txid", "The transaction id."},
175 {RPCResult::Type::STR, "fee_reason", "The transaction fee reason."}
176 },
177 },
178 },
179 RPCExamples{
180 "\nSend 0.1 BTC\n"
181 + HelpExampleCli("sendtoaddress", "\"" + EXAMPLE_ADDRESS[0] + "\" 0.1") +
182 "\nSend 0.1 BTC with a confirmation target of 6 blocks in economical fee estimate mode using positional arguments\n"
183 + HelpExampleCli("sendtoaddress", "\"" + EXAMPLE_ADDRESS[0] + "\" 0.1 \"donation\" \"sean's outpost\" false true 6 economical") +
184 "\nSend 0.1 BTC with a fee rate of 1.1 " + CURRENCY_ATOM + "/vB, subtract fee from amount, BIP125-replaceable, using positional arguments\n"
185 + HelpExampleCli("sendtoaddress", "\"" + EXAMPLE_ADDRESS[0] + "\" 0.1 \"drinks\" \"room77\" true true null \"unset\" null 1.1") +
186 "\nSend 0.2 BTC with a confirmation target of 6 blocks in economical fee estimate mode using named arguments\n"
187 + HelpExampleCli("-named sendtoaddress", "address=\"" + EXAMPLE_ADDRESS[0] + "\" amount=0.2 conf_target=6 estimate_mode=\"economical\"") +
188 "\nSend 0.5 BTC with a fee rate of 25 " + CURRENCY_ATOM + "/vB using named arguments\n"
189 + HelpExampleCli("-named sendtoaddress", "address=\"" + EXAMPLE_ADDRESS[0] + "\" amount=0.5 fee_rate=25")
190 + HelpExampleCli("-named sendtoaddress", "address=\"" + EXAMPLE_ADDRESS[0] + "\" amount=0.5 fee_rate=25 subtractfeefromamount=false replaceable=true avoid_reuse=true comment=\"2 pizzas\" comment_to=\"jeremy\" verbose=true")
191 },
192 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
193{
194 std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
195 if (!pwallet) return NullUniValue;
196
197 // Make sure the results are valid at least up to the most recent block
198 // the user could have gotten from another RPC command prior to now

Callers

nothing calls this directly

Calls 15

FeeModesFunction · 0.85
HelpExampleCliFunction · 0.85
GetAvoidReuseFlagFunction · 0.85
GetAssetFromStringFunction · 0.85
JSONRPCErrorFunction · 0.85
SetFeeEstimateModeFunction · 0.85
EnsureWalletIsUnlockedFunction · 0.85
ParseRecipientsFunction · 0.85
SendMoneyFunction · 0.85
get_boolMethod · 0.80
isStrMethod · 0.80

Tested by

no test coverage detected