49 static const std::string
HELP_REQUIRING_PASSPHRASE{
"\nRequires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.\n"};
53 bool avoid_reuse = param.
isNull() ? can_avoid_reuse : param.
get_bool();
55 if (avoid_reuse && !can_avoid_reuse) {
69 if (include_watchonly.
isNull()) {
100 std::string wallet_name;
102 std::shared_ptr<CWallet> pwallet =
GetWallet(wallet_name);
107 std::vector<std::shared_ptr<CWallet>> wallets =
GetWallets();
108 if (wallets.size() == 1) {
112 if (wallets.empty()) {
114 RPC_WALLET_NOT_FOUND,
"No wallet is loaded. Load a wallet using loadwallet or create a new one with createwallet. (Note: A default wallet is no longer automatically created)");
117 "Wallet file not specified (must request wallet RPC through /wallet/<filename> uri-path).");
139 if (!spk_man && also_create) {
151 entry.
pushKV(
"confirmations", confirms);
153 entry.
pushKV(
"generated",
true);
161 entry.
pushKV(
"blocktime", block_time);
170 entry.
pushKV(
"walletconflicts", conflicts);
175 std::string rbfStatus =
"no";
179 rbfStatus =
"unknown";
183 entry.
pushKV(
"bip125-replaceable", rbfStatus);
185 for (
const std::pair<const std::string, std::string>& item : wtx.
mapValue)
186 entry.
pushKV(item.first, item.second);
191 std::string label = value.
get_str();
213 if (!conf_target.
isNull()) {
214 throw JSONRPCError(
RPC_INVALID_PARAMETER,
"Cannot specify both conf_target and fee_rate. Please provide either a confirmation target in blocks for automatic fee estimation, or an explicit fee rate.");
216 if (!estimate_mode.
isNull() && estimate_mode.
get_str() !=
"unset") {
228 if (!conf_target.
isNull()) {
236 "\nReturns a new Bitcoin address for receiving payments.\n" 237 "If 'label' is specified, it is added to the address book \n" 238 "so payments received with the address will be associated with 'label'.\n",
240 {
"label",
RPCArg::Type::STR,
"\"\"",
"The label name for the address to be linked to. It can also be set to the empty string \"\" to represent the default label. The label does not need to exist, it will be created if there is no label by the given name."},
241 {
"address_type",
RPCArg::Type::STR,
"set by -addresstype",
"The address type to use. Options are \"legacy\", \"p2sh-segwit\", and \"bech32\"."},
254 CWallet*
const pwallet = wallet.get();
264 if (!request.params[0].isNull())
268 if (!request.params[1].isNull()) {
288 "\nReturns a new Bitcoin address, for receiving change.\n" 289 "This is for use with raw transactions, NOT normal use.\n",
291 {
"address_type",
RPCArg::Type::STR,
"set by -changetype",
"The address type to use. Options are \"legacy\", \"p2sh-segwit\", and \"bech32\"."},
304 CWallet*
const pwallet = wallet.get();
313 if (!request.params[0].isNull()) {
333 "\nSets the label associated with the given address.\n",
347 CWallet*
const pwallet = wallet.get();
358 if (pwallet->
IsMine(dest)) {
370 std::set<CTxDestination> destinations;
372 for (
const std::string& address: address_amounts.
getKeys()) {
378 if (destinations.count(dest)) {
381 destinations.insert(dest);
386 bool subtract_fee =
false;
387 for (
unsigned int idx = 0; idx < subtract_fee_outputs.
size(); idx++) {
388 const UniValue& addr = subtract_fee_outputs[idx];
389 if (addr.
get_str() == address) {
394 CRecipient recipient = {script_pub_key, amount, subtract_fee};
408 int nChangePosRet = -1;
419 entry.
pushKV(
"txid", tx->GetHash().GetHex());
423 return tx->GetHash().GetHex();
429 "\nSend an amount to a given address." +
435 "This is not part of the transaction, just kept in your wallet."},
437 "to which you're sending the transaction. This is not part of the \n" 438 "transaction, just kept in your wallet."},
439 {
"subtractfeefromamount",
RPCArg::Type::BOOL,
"false",
"The fee will be deducted from the amount being sent.\n" 440 "The recipient will receive less bitcoins than you enter in the amount field."},
441 {
"replaceable",
RPCArg::Type::BOOL,
"wallet default",
"Allow this transaction to be replaced by a transaction with higher fees via BIP 125"},
442 {
"conf_target",
RPCArg::Type::NUM,
"wallet -txconfirmtarget",
"Confirmation target in blocks"},
443 {
"estimate_mode",
RPCArg::Type::STR,
"unset", std::string() +
"The fee estimate mode, must be one of (case insensitive):\n" 445 {
"avoid_reuse",
RPCArg::Type::BOOL,
"true",
"(only available if avoid_reuse wallet flag is set) Avoid spending from dirty addresses; addresses are considered\n" 446 "dirty if they have previously been used in a transaction."},
448 {
"verbose",
RPCArg::Type::BOOL,
"false",
"If true, return extra information about the transaction."},
451 RPCResult{
"if verbose is not set or set to false",
465 "\nSend 0.1 BTC with a confirmation target of 6 blocks in economical fee estimate mode using positional arguments\n" 467 "\nSend 0.1 BTC with a fee rate of 1.1 " +
CURRENCY_ATOM +
"/vB, subtract fee from amount, BIP125-replaceable, using positional arguments\n" 469 "\nSend 0.2 BTC with a confirmation target of 6 blocks in economical fee estimate mode using named arguments\n" 471 "\nSend 0.5 BTC with a fee rate of 25 " +
CURRENCY_ATOM +
"/vB using named arguments\n" 473 +
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")
479 CWallet*
const pwallet = wallet.get();
483 pwallet->BlockUntilSyncedToCurrentChain();
489 if (!request.params[2].isNull() && !request.params[2].get_str().empty())
490 mapValue[
"comment"] = request.params[2].get_str();
491 if (!request.params[3].isNull() && !request.params[3].get_str().empty())
492 mapValue[
"to"] = request.params[3].get_str();
494 bool fSubtractFeeFromAmount =
false;
495 if (!request.params[4].isNull()) {
496 fSubtractFeeFromAmount = request.params[4].get_bool();
500 if (!request.params[5].isNull()) {
508 SetFeeEstimateMode(*pwallet, coin_control, request.params[6], request.params[7], request.params[9],
false);
513 const std::string address = request.params[0].get_str();
514 address_amounts.
pushKV(address, request.params[1]);
516 if (fSubtractFeeFromAmount) {
517 subtractFeeFromAmount.
push_back(address);
520 std::vector<CRecipient> recipients;
522 const bool verbose{request.params[10].isNull() ? false : request.params[10].get_bool()};
524 return SendMoney(pwallet, coin_control, recipients, mapValue, verbose);
532 "\nLists groups of addresses which have had their common ownership\n" 533 "made public by common use as inputs or as the resulting change\n" 534 "in past transactions\n",
558 const CWallet*
const pwallet = wallet.get();
562 pwallet->BlockUntilSyncedToCurrentChain();
577 if (address_book_entry) {
578 addressInfo.
push_back(address_book_entry->GetLabel());
585 return jsonGroupings;
593 "\nSign a message with the private key of an address" +
603 "\nUnlock the wallet for 30 seconds\n" 605 "\nCreate the signature\n" 606 +
HelpExampleCli(
"signmessage",
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"my message\"") +
607 "\nVerify the signature\n" 608 +
HelpExampleCli(
"verifymessage",
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"signature\" \"my message\"") +
609 "\nAs a JSON-RPC call\n" 610 +
HelpExampleRpc(
"signmessage",
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"my message\"")
616 const CWallet*
const pwallet = wallet.get();
622 std::string strAddress = request.params[0].get_str();
623 std::string strMessage = request.params[1].get_str();
630 const PKHash* pkhash = std::get_if<PKHash>(&dest);
635 std::string signature;
650 std::set<CTxDestination> address_set;
655 address_set =
wallet.GetLabelAddresses(label);
663 if (!
wallet.IsMine(script_pub_key)) {
666 address_set.insert(dest);
671 if (!params[1].isNull())
672 min_depth = params[1].get_int();
676 for (
const std::pair<const uint256, CWalletTx>& wtx_pair :
wallet.mapWallet) {
682 for (
const CTxOut& txout : wtx.
tx->vout) {
697 "\nReturns the total amount received by the given address in transactions with at least minconf confirmations.\n",
700 {
"minconf",
RPCArg::Type::NUM,
"1",
"Only include transactions confirmed at least this many times."},
706 "\nThe amount from transactions with at least 1 confirmation\n" 708 "\nThe amount including unconfirmed transactions, zero confirmations\n" 710 "\nThe amount with at least 6 confirmations\n" 712 "\nAs a JSON-RPC call\n" 719 const CWallet*
const pwallet = wallet.get();
723 pwallet->BlockUntilSyncedToCurrentChain();
736 "\nReturns the total amount received by addresses with <label> in transactions with at least [minconf] confirmations.\n",
739 {
"minconf",
RPCArg::Type::NUM,
"1",
"Only include transactions confirmed at least this many times."},
745 "\nAmount received by the default label with at least 1 confirmation\n" 747 "\nAmount received at the tabby label including unconfirmed amounts with zero confirmations\n" 749 "\nThe amount with at least 6 confirmations\n" 751 "\nAs a JSON-RPC call\n" 758 const CWallet*
const pwallet = wallet.get();
762 pwallet->BlockUntilSyncedToCurrentChain();
775 "\nReturns the total available balance.\n" 776 "The available balance is what the wallet considers currently spendable, and is\n" 777 "thus affected by options which limit spendability such as -spendzeroconfchange.\n",
780 {
"minconf",
RPCArg::Type::NUM,
"0",
"Only include transactions confirmed at least this many times."},
781 {
"include_watchonly",
RPCArg::Type::BOOL,
"true for watch-only wallets, otherwise false",
"Also include balance in watch-only addresses (see 'importaddress')"},
782 {
"avoid_reuse",
RPCArg::Type::BOOL,
"true",
"(only available if avoid_reuse wallet flag is set) Do not include balance in dirty outputs; addresses are considered dirty if they have previously been used in a transaction."},
788 "\nThe total amount in the wallet with 0 or more confirmations\n" 790 "\nThe total amount in the wallet with at least 6 confirmations\n" 792 "\nAs a JSON-RPC call\n" 799 const CWallet*
const pwallet = wallet.get();
803 pwallet->BlockUntilSyncedToCurrentChain();
807 const UniValue& dummy_value = request.params[0];
813 if (!request.params[1].isNull()) {
814 min_depth = request.params[1].get_int();
821 const auto bal = pwallet->
GetBalance(min_depth, avoid_reuse);
823 return ValueFromAmount(bal.m_mine_trusted + (include_watchonly ? bal.m_watchonly_trusted : 0));
831 "DEPRECATED\nIdentical to getbalances().mine.untrusted_pending\n",
839 const CWallet*
const pwallet = wallet.get();
843 pwallet->BlockUntilSyncedToCurrentChain();
856 "\nSend multiple times. Amounts are double-precision floating point numbers." +
868 "The fee will be equally deducted from the amount of each selected address.\n" 869 "Those recipients will receive less bitcoins than you enter in their corresponding amount field.\n" 870 "If no addresses are specified here, the sender pays the fee.",
875 {
"replaceable",
RPCArg::Type::BOOL,
"wallet default",
"Allow this transaction to be replaced by a transaction with higher fees via BIP 125"},
876 {
"conf_target",
RPCArg::Type::NUM,
"wallet -txconfirmtarget",
"Confirmation target in blocks"},
877 {
"estimate_mode",
RPCArg::Type::STR,
"unset", std::string() +
"The fee estimate mode, must be one of (case insensitive):\n" 880 {
"verbose",
RPCArg::Type::BOOL,
"false",
"If true, return extra infomration about the transaction."},
883 RPCResult{
"if verbose is not set or set to false",
885 "the number of addresses." 891 "the number of addresses."},
897 "\nSend two amounts to two different addresses:\n" 899 "\nSend two amounts to two different addresses setting the confirmation and comment:\n" 901 "\nSend two amounts to two different addresses, subtract fee from amount:\n" 903 "\nAs a JSON-RPC call\n" 910 CWallet*
const pwallet = wallet.get();
914 pwallet->BlockUntilSyncedToCurrentChain();
918 if (!request.params[0].isNull() && !request.params[0].get_str().empty()) {
924 if (!request.params[3].isNull() && !request.params[3].get_str().empty())
925 mapValue[
"comment"] = request.params[3].
get_str();
928 if (!request.params[4].isNull())
929 subtractFeeFromAmount = request.params[4].
get_array();
932 if (!request.params[5].isNull()) {
936 SetFeeEstimateMode(*pwallet, coin_control, request.params[6], request.params[7], request.params[8],
false);
938 std::vector<CRecipient> recipients;
940 const bool verbose{request.params[9].isNull() ? false : request.params[9].get_bool()};
942 return SendMoney(pwallet, coin_control, recipients, std::move(mapValue), verbose);
951 "\nAdd an nrequired-to-sign multisignature address to the wallet. Requires a new wallet backup.\n" 952 "Each key is a Bitcoin address or hex-encoded public key.\n" 953 "This functionality is only intended for use with non-watchonly addresses.\n" 954 "See `importaddress` for watchonly p2sh address support.\n" 955 "If 'label' is specified, assign address to that label.\n",
964 {
"address_type",
RPCArg::Type::STR,
"set by -addresstype",
"The address type to use. Options are \"legacy\", \"p2sh-segwit\", and \"bech32\"."},
975 "\nAdd a multisig address from 2 addresses\n" 977 "\nAs a JSON-RPC call\n" 984 CWallet*
const pwallet = wallet.get();
991 if (!request.params[2].isNull())
994 int required = request.params[0].get_int();
998 std::vector<CPubKey> pubkeys;
999 for (
unsigned int i = 0; i < keys_or_addrs.
size(); ++i) {
1000 if (
IsHex(keys_or_addrs[i].get_str()) && (keys_or_addrs[i].
get_str().length() == 66 || keys_or_addrs[i].
get_str().length() == 130)) {
1003 pubkeys.push_back(
AddrToPubKey(spk_man, keys_or_addrs[i].get_str()));
1008 if (!request.params[3].isNull()) {
1025 result.
pushKV(
"descriptor", descriptor->ToString());
1034 int nConf{std::numeric_limits<int>::max()};
1046 if (!params[0].isNull())
1047 nMinDepth = params[0].get_int();
1050 bool fIncludeEmpty =
false;
1051 if (!params[1].isNull())
1052 fIncludeEmpty = params[1].get_bool();
1060 bool has_filtered_address =
false;
1062 if (!by_label && params.size() > 3) {
1067 has_filtered_address =
true;
1071 std::map<CTxDestination, tallyitem> mapTally;
1072 for (
const std::pair<const uint256, CWalletTx>& pairWtx : pwallet->mapWallet) {
1075 if (wtx.
IsCoinBase() || !pwallet->chain().checkFinalTx(*wtx.
tx)) {
1080 if (nDepth < nMinDepth)
1083 for (
const CTxOut& txout : wtx.
tx->vout)
1089 if (has_filtered_address && !(filtered_address == address)) {
1094 if(!(mine & filter))
1108 std::map<std::string, tallyitem> label_tally;
1112 auto start = pwallet->m_address_book.begin();
1113 auto end = pwallet->m_address_book.end();
1115 if (has_filtered_address) {
1116 start = pwallet->m_address_book.find(filtered_address);
1118 end = std::next(start);
1122 for (
auto item_it = start; item_it != end; ++item_it)
1124 if (item_it->second.IsChange())
continue;
1126 const std::string& label = item_it->second.GetLabel();
1127 auto it = mapTally.find(address);
1128 if (
it == mapTally.end() && !fIncludeEmpty)
1132 int nConf = std::numeric_limits<int>::max();
1134 if (
it != mapTally.end())
1136 nAmount = (*it).second.nAmount;
1137 nConf = (*it).second.nConf;
1138 fIsWatchonly = (*it).second.fIsWatchonly;
1152 obj.
pushKV(
"involvesWatchonly",
true);
1155 obj.
pushKV(
"confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
1156 obj.
pushKV(
"label", label);
1158 if (
it != mapTally.end())
1160 for (
const uint256& _item : (*it).second.txids)
1165 obj.
pushKV(
"txids", transactions);
1172 for (
const auto& entry : label_tally)
1175 int nConf = entry.second.nConf;
1177 if (entry.second.fIsWatchonly)
1178 obj.
pushKV(
"involvesWatchonly",
true);
1180 obj.
pushKV(
"confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
1181 obj.
pushKV(
"label", entry.first);
1192 "\nList balances by receiving address.\n",
1194 {
"minconf",
RPCArg::Type::NUM,
"1",
"The minimum number of confirmations before payments are included."},
1195 {
"include_empty",
RPCArg::Type::BOOL,
"false",
"Whether to include addresses that haven't received any payments."},
1196 {
"include_watchonly",
RPCArg::Type::BOOL,
"true for watch-only wallets, otherwise false",
"Whether to include watch-only addresses (see 'importaddress')"},
1204 {
RPCResult::Type::BOOL,
"involvesWatchonly",
"Only returns true if imported addresses were involved in transaction"},
1207 {
RPCResult::Type::NUM,
"confirmations",
"The number of confirmations of the most recent transaction included"},
1208 {
RPCResult::Type::STR,
"label",
"The label of the receiving address. The default label is \"\""},
1226 const CWallet*
const pwallet = wallet.get();
1230 pwallet->BlockUntilSyncedToCurrentChain();
1242 "\nList received transactions by label.\n",
1244 {
"minconf",
RPCArg::Type::NUM,
"1",
"The minimum number of confirmations before payments are included."},
1245 {
"include_empty",
RPCArg::Type::BOOL,
"false",
"Whether to include labels that haven't received any payments."},
1246 {
"include_watchonly",
RPCArg::Type::BOOL,
"true for watch-only wallets, otherwise false",
"Whether to include watch-only addresses (see 'importaddress')"},
1253 {
RPCResult::Type::BOOL,
"involvesWatchonly",
"Only returns true if imported addresses were involved in transaction"},
1255 {
RPCResult::Type::NUM,
"confirmations",
"The number of confirmations of the most recent transaction included"},
1256 {
RPCResult::Type::STR,
"label",
"The label of the receiving address. The default label is \"\""},
1269 const CWallet*
const pwallet = wallet.get();
1273 pwallet->BlockUntilSyncedToCurrentChain();
1303 std::list<COutputEntry> listReceived;
1304 std::list<COutputEntry> listSent;
1306 wtx.GetAmounts(listReceived, listSent, nFee, filter_ismine);
1316 if (involvesWatchonly || (pwallet->IsMine(s.destination) &
ISMINE_WATCH_ONLY)) {
1317 entry.
pushKV(
"involvesWatchonly",
true);
1320 entry.
pushKV(
"category",
"send");
1322 const auto* address_book_entry = pwallet->FindAddressBookEntry(s.destination);
1323 if (address_book_entry) {
1324 entry.
pushKV(
"label", address_book_entry->GetLabel());
1326 entry.
pushKV(
"vout", s.vout);
1330 entry.
pushKV(
"abandoned", wtx.isAbandoned());
1331 ret.push_back(entry);
1336 if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth) {
1340 const auto* address_book_entry = pwallet->FindAddressBookEntry(r.destination);
1341 if (address_book_entry) {
1342 label = address_book_entry->GetLabel();
1344 if (filter_label && label != *filter_label) {
1348 if (involvesWatchonly || (pwallet->IsMine(r.destination) &
ISMINE_WATCH_ONLY)) {
1349 entry.
pushKV(
"involvesWatchonly",
true);
1352 if (wtx.IsCoinBase())
1354 if (wtx.GetDepthInMainChain() < 1)
1355 entry.
pushKV(
"category",
"orphan");
1356 else if (wtx.IsImmatureCoinBase())
1357 entry.
pushKV(
"category",
"immature");
1359 entry.
pushKV(
"category",
"generate");
1363 entry.
pushKV(
"category",
"receive");
1366 if (address_book_entry) {
1367 entry.
pushKV(
"label", label);
1369 entry.
pushKV(
"vout", r.vout);
1372 ret.push_back(entry);
1379 return{{
RPCResult::Type::NUM,
"confirmations",
"The number of confirmations for the transaction. Negative confirmations means the\n" 1380 "transaction conflicted that many blocks ago."},
1382 {
RPCResult::Type::BOOL,
"trusted",
"Only present if we consider transaction to be trusted and so safe to spend from."},
1385 {
RPCResult::Type::NUM,
"blockindex",
"The index of the transaction in the block that includes it."},
1394 {
RPCResult::Type::STR,
"comment",
"If a comment is associated with the transaction, only present if not empty."},
1395 {
RPCResult::Type::STR,
"bip125-replaceable",
"(\"yes|no|unknown\") Whether this transaction could be replaced due to BIP125 (replace-by-fee);\n" 1396 "may be unknown for unconfirmed transactions not in the mempool"}};
1402 "\nIf a label name is provided, this will return only incoming transactions paying to addresses with the specified label.\n" 1403 "\nReturns up to 'count' most recent transactions skipping the first 'from' transactions.\n",
1406 "with the specified label, or \"*\" to disable filtering and return all transactions."},
1409 {
"include_watchonly",
RPCArg::Type::BOOL,
"true for watch-only wallets, otherwise false",
"Include transactions to watch-only addresses (see 'importaddress')"},
1416 {
RPCResult::Type::BOOL,
"involvesWatchonly",
"Only returns true if imported addresses were involved in transaction."},
1419 "\"send\" Transactions sent.\n" 1420 "\"receive\" Non-coinbase transactions received.\n" 1421 "\"generate\" Coinbase transactions received with more than 100 confirmations.\n" 1422 "\"immature\" Coinbase transactions received with 100 or fewer confirmations.\n" 1423 "\"orphan\" Orphaned coinbase transactions received."},
1425 "for all other categories"},
1428 {
RPCResult::Type::STR_AMOUNT,
"fee",
"The amount of the fee in " + CURRENCY_UNIT +
". This is negative and only available for the\n" 1429 "'send' category of transactions."},
1433 {
RPCResult::Type::BOOL,
"abandoned",
"'true' if the transaction has been abandoned (inputs are respendable). Only available for the \n" 1434 "'send' category of transactions."},
1439 "\nList the most recent 10 transactions in the systems\n" 1441 "\nList transactions 100 to 120\n" 1443 "\nAs a JSON-RPC call\n" 1450 const CWallet*
const pwallet = wallet.get();
1454 pwallet->BlockUntilSyncedToCurrentChain();
1456 const std::string* filter_label =
nullptr;
1457 if (!request.params[0].isNull() && request.params[0].get_str() !=
"*") {
1458 filter_label = &request.params[0].get_str();
1459 if (filter_label->empty()) {
1464 if (!request.params[1].isNull())
1465 nCount = request.params[1].get_int();
1467 if (!request.params[2].isNull())
1468 nFrom = request.params[2].get_int();
1488 for (CWallet::TxItems::const_reverse_iterator
it = txOrdered.rbegin();
it != txOrdered.rend(); ++
it)
1492 if ((
int)ret.
size() >= (nCount+nFrom))
break;
1498 if (nFrom > (
int)ret.
size())
1500 if ((nFrom + nCount) > (
int)ret.
size())
1501 nCount = ret.
size() - nFrom;
1503 const std::vector<UniValue>& txs = ret.
getValues();
1505 result.push_backV({ txs.rend() - nFrom - nCount, txs.rend() - nFrom });
1514 "\nGet all transactions in blocks since block [blockhash], or all transactions if omitted.\n" 1515 "If \"blockhash\" is no longer a part of the main chain, transactions from the fork point onward are included.\n" 1516 "Additionally, if include_removed is set, transactions affecting the wallet which were removed are returned in the \"removed\" array.\n",
1519 {
"target_confirmations",
RPCArg::Type::NUM,
"1",
"Return the nth block hash from the main chain. e.g. 1 would mean the best block hash. Note: this is not used as a filter, but only affects [lastblock] in the return value"},
1520 {
"include_watchonly",
RPCArg::Type::BOOL,
"true for watch-only wallets, otherwise false",
"Include transactions to watch-only addresses (see 'importaddress')"},
1521 {
"include_removed",
RPCArg::Type::BOOL,
"true",
"Show transactions that were removed due to a reorg in the \"removed\" array\n" 1522 "(not guaranteed to work on pruned nodes)"},
1531 {
RPCResult::Type::BOOL,
"involvesWatchonly",
"Only returns true if imported addresses were involved in transaction."},
1534 "\"send\" Transactions sent.\n" 1535 "\"receive\" Non-coinbase transactions received.\n" 1536 "\"generate\" Coinbase transactions received with more than 100 confirmations.\n" 1537 "\"immature\" Coinbase transactions received with 100 or fewer confirmations.\n" 1538 "\"orphan\" Orphaned coinbase transactions received."},
1540 "for all other categories"},
1542 {
RPCResult::Type::STR_AMOUNT,
"fee",
"The amount of the fee in " + CURRENCY_UNIT +
". This is negative and only available for the\n" 1543 "'send' category of transactions."},
1547 {
RPCResult::Type::BOOL,
"abandoned",
"'true' if the transaction has been abandoned (inputs are respendable). Only available for the \n" 1548 "'send' category of transactions."},
1553 {
RPCResult::Type::ARR,
"removed",
"<structure is the same as \"transactions\" above, only present if include_removed=true>\n" 1554 "Note: transactions that were re-added in the active chain will appear as-is in this array, and may thus have a positive confirmation count." 1556 {
RPCResult::Type::STR_HEX,
"lastblock",
"The hash of the block (target_confirmations-1) from the best block on the main chain, or the genesis hash if the referenced block does not exist yet. This is typically used to feed back into listsinceblock the next time you call it. So you would generally use a target_confirmations of say 6, so you will be continually re-notified of transactions until they've reached 6 confirmations plus any new ones"},
1561 +
HelpExampleCli(
"listsinceblock",
"\"000000000000000bacf66f7497b7dc45ef753ee9a7d38571037cdb1a57f663ad\" 6")
1562 +
HelpExampleRpc(
"listsinceblock",
"\"000000000000000bacf66f7497b7dc45ef753ee9a7d38571037cdb1a57f663ad\", 6")
1572 wallet.BlockUntilSyncedToCurrentChain();
1578 int target_confirms = 1;
1582 if (!request.params[0].isNull() && !request.params[0].get_str().empty()) {
1583 blockId =
ParseHashV(request.params[0],
"blockhash");
1591 if (!request.params[1].isNull()) {
1592 target_confirms = request.params[1].get_int();
1594 if (target_confirms < 1) {
1603 bool include_removed = (request.params[3].isNull() || request.params[3].get_bool());
1609 for (
const std::pair<const uint256, CWalletTx>& pairWtx : wallet.mapWallet) {
1620 while (include_removed && altheight && *altheight > *height) {
1626 auto it = wallet.mapWallet.find(tx->GetHash());
1627 if (
it != wallet.mapWallet.end()) {
1642 ret.
pushKV(
"transactions", transactions);
1643 if (include_removed) ret.
pushKV(
"removed", removed);
1654 "\nGet detailed information about in-wallet transaction <txid>\n",
1657 {
"include_watchonly",
RPCArg::Type::BOOL,
"true for watch-only wallets, otherwise false",
1658 "Whether to include watch-only addresses in balance calculation and details[]"},
1660 "Whether to include a `decoded` field containing the decoded transaction (equivalent to RPC decoderawtransaction)"},
1666 {
RPCResult::Type::STR_AMOUNT,
"fee",
"The amount of the fee in " + CURRENCY_UNIT +
". This is negative and only available for the\n" 1667 "'send' category of transactions."},
1675 {
RPCResult::Type::BOOL,
"involvesWatchonly",
"Only returns true if imported addresses were involved in transaction."},
1678 "\"send\" Transactions sent.\n" 1679 "\"receive\" Non-coinbase transactions received.\n" 1680 "\"generate\" Coinbase transactions received with more than 100 confirmations.\n" 1681 "\"immature\" Coinbase transactions received with 100 or fewer confirmations.\n" 1682 "\"orphan\" Orphaned coinbase transactions received."},
1686 {
RPCResult::Type::STR_AMOUNT,
"fee",
"The amount of the fee in " + CURRENCY_UNIT +
". This is negative and only available for the \n" 1687 "'send' category of transactions."},
1688 {
RPCResult::Type::BOOL,
"abandoned",
"'true' if the transaction has been abandoned (inputs are respendable). Only available for the \n" 1689 "'send' category of transactions."},
1693 {
RPCResult::Type::OBJ,
"decoded",
"Optional, the decoded transaction (only present when `verbose` is passed)",
1695 {
RPCResult::Type::ELISION,
"",
"Equivalent to the RPC decoderawtransaction method, or the RPC getrawtransaction method when `verbose` is passed."},
1700 HelpExampleCli(
"gettransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
1701 +
HelpExampleCli(
"gettransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\" true")
1702 +
HelpExampleCli(
"gettransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\" false true")
1703 +
HelpExampleRpc(
"gettransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
1709 const CWallet*
const pwallet = wallet.get();
1713 pwallet->BlockUntilSyncedToCurrentChain();
1725 bool verbose = request.params[2].isNull() ? false : request.params[2].get_bool();
1728 auto it = pwallet->mapWallet.find(hash);
1729 if (
it == pwallet->mapWallet.end()) {
1736 CAmount nNet = nCredit - nDebit;
1747 entry.
pushKV(
"details", details);
1750 entry.
pushKV(
"hex", strHex);
1755 entry.
pushKV(
"decoded", decoded);
1766 "\nMark in-wallet transaction <txid> as abandoned\n" 1767 "This will mark this transaction and all its in-wallet descendants as abandoned which will allow\n" 1768 "for their inputs to be respent. It can be used to replace \"stuck\" or evicted transactions.\n" 1769 "It only works on transactions which are not included in a block and are not currently in the mempool.\n" 1770 "It has no effect on transactions which are already abandoned.\n",
1776 HelpExampleCli(
"abandontransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
1777 +
HelpExampleRpc(
"abandontransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
1783 CWallet*
const pwallet = wallet.get();
1787 pwallet->BlockUntilSyncedToCurrentChain();
1793 if (!pwallet->mapWallet.count(hash)) {
1809 "\nSafely copies current wallet file to destination, which can be a directory or a path with filename.\n",
1822 const CWallet*
const pwallet = wallet.get();
1826 pwallet->BlockUntilSyncedToCurrentChain();
1830 std::string strDest = request.params[0].get_str();
1844 "\nFills the keypool."+
1858 CWallet*
const pwallet = wallet.get();
1867 unsigned int kpSize = 0;
1868 if (!request.params[0].isNull()) {
1869 if (request.params[0].get_int() < 0)
1871 kpSize = (
unsigned int)request.params[0].
get_int();
1890 "\nStores the wallet decryption key in memory for 'timeout' seconds.\n" 1891 "This is needed prior to performing transactions related to private keys such as sending bitcoins\n" 1893 "Issuing the walletpassphrase command while the wallet is already unlocked will set a new unlock\n" 1894 "time that overrides the old one.\n",
1901 "\nUnlock the wallet for 60 seconds\n" 1903 "\nLock the wallet again (before 60 seconds)\n" 1905 "\nAs a JSON-RPC call\n" 1912 CWallet*
const pwallet = wallet.get();
1915 int64_t relock_time;
1927 strWalletPass.reserve(100);
1930 strWalletPass = request.params[0].get_str().c_str();
1933 nSleepTime = request.params[1].get_int64();
1935 if (nSleepTime < 0) {
1939 constexpr int64_t MAX_SLEEP_TIME = 100000000;
1940 if (nSleepTime > MAX_SLEEP_TIME) {
1941 nSleepTime = MAX_SLEEP_TIME;
1944 if (strWalletPass.empty()) {
1948 if (!pwallet->
Unlock(strWalletPass)) {
1954 pwallet->nRelockTime =
GetTime() + nSleepTime;
1955 relock_time = pwallet->nRelockTime;
1966 std::weak_ptr<CWallet> weak_wallet = wallet;
1968 if (
auto shared_wallet = weak_wallet.lock()) {
1969 LOCK(shared_wallet->cs_wallet);
1971 if (shared_wallet->nRelockTime != relock_time)
return;
1972 shared_wallet->Lock();
1973 shared_wallet->nRelockTime = 0;
1986 "\nChanges the wallet passphrase from 'oldpassphrase' to 'newpassphrase'.\n",
1993 HelpExampleCli(
"walletpassphrasechange",
"\"old one\" \"new one\"")
1994 +
HelpExampleRpc(
"walletpassphrasechange",
"\"old one\", \"new one\"")
2000 CWallet*
const pwallet = wallet.get();
2011 strOldWalletPass.reserve(100);
2012 strOldWalletPass = request.params[0].get_str().c_str();
2015 strNewWalletPass.reserve(100);
2016 strNewWalletPass = request.params[1].get_str().c_str();
2018 if (strOldWalletPass.empty() || strNewWalletPass.empty()) {
2035 "\nRemoves the wallet encryption key from memory, locking the wallet.\n" 2036 "After calling this method, you will need to call walletpassphrase again\n" 2037 "before being able to call any methods which require the wallet to be unlocked.\n",
2041 "\nSet the passphrase for 2 minutes to perform a transaction\n" 2043 "\nPerform a send (requires passphrase set)\n" 2045 "\nClear the passphrase since we are done before 2 minutes is up\n" 2047 "\nAs a JSON-RPC call\n" 2054 CWallet*
const pwallet = wallet.get();
2063 pwallet->nRelockTime = 0;
2074 "\nEncrypts the wallet with 'passphrase'. This is for first time encryption.\n" 2075 "After this, any calls that interact with private keys such as sending or signing \n" 2076 "will require the passphrase to be set prior the making these calls.\n" 2077 "Use the walletpassphrase call for this, and then walletlock call.\n" 2078 "If the wallet is already encrypted, use the walletpassphrasechange call.\n",
2084 "\nEncrypt your wallet\n" 2086 "\nNow set the passphrase to use the wallet, such as for signing or sending bitcoin\n" 2088 "\nNow we can do something like sign\n" 2089 +
HelpExampleCli(
"signmessage",
"\"address\" \"test message\"") +
2090 "\nNow lock the wallet again by removing the passphrase\n" 2092 "\nAs a JSON-RPC call\n" 2099 CWallet*
const pwallet = wallet.get();
2114 strWalletPass.reserve(100);
2115 strWalletPass = request.params[0].get_str().c_str();
2117 if (strWalletPass.empty()) {
2125 return "wallet encrypted; The keypool has been flushed and a new HD seed was generated (if you are using HD). You need to make a new backup.";
2133 "\nUpdates list of temporarily unspendable outputs.\n" 2134 "Temporarily lock (unlock=false) or unlock (unlock=true) specified transaction outputs.\n" 2135 "If no transaction outputs are specified when unlocking then all current locked transaction outputs are unlocked.\n" 2136 "A locked transaction output will not be chosen by automatic coin selection, when spending bitcoins.\n" 2137 "Manually selected coins are automatically unlocked.\n" 2138 "Locks are stored in memory only. Nodes start with zero locked outputs, and the locked output list\n" 2139 "is always cleared (by virtue of process exit) when a node stops or fails.\n" 2140 "Also see the listunspent call\n",
2143 {
"transactions",
RPCArg::Type::ARR,
"empty array",
"The transaction outputs and within each, the txid (string) vout (numeric).",
2158 "\nList the unspent transactions\n" 2160 "\nLock an unspent transaction\n" 2161 +
HelpExampleCli(
"lockunspent",
"false \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") +
2162 "\nList the locked transactions\n" 2164 "\nUnlock the transaction again\n" 2165 +
HelpExampleCli(
"lockunspent",
"true \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") +
2166 "\nAs a JSON-RPC call\n" 2167 +
HelpExampleRpc(
"lockunspent",
"false, \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"")
2173 CWallet*
const pwallet = wallet.get();
2177 pwallet->BlockUntilSyncedToCurrentChain();
2183 bool fUnlock = request.params[0].get_bool();
2185 if (request.params[1].isNull()) {
2193 const UniValue& output_params = request.params[1];
2197 std::vector<COutPoint> outputs;
2198 outputs.reserve(output_params.
size());
2200 for (
unsigned int idx = 0; idx < output_params.
size(); idx++) {
2217 const auto it = pwallet->mapWallet.find(outpt.
hash);
2218 if (
it == pwallet->mapWallet.end()) {
2224 if (outpt.
n >= trans.
tx->vout.size()) {
2234 if (fUnlock && !is_locked) {
2238 if (!fUnlock && is_locked) {
2242 outputs.push_back(outpt);
2246 for (
const COutPoint& outpt : outputs) {
2259 "\nReturns list of temporarily unspendable outputs.\n" 2260 "See the lockunspent call to lock and unlock transactions for spending.\n",
2273 "\nList the unspent transactions\n" 2275 "\nLock an unspent transaction\n" 2276 +
HelpExampleCli(
"lockunspent",
"false \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") +
2277 "\nList the locked transactions\n" 2279 "\nUnlock the transaction again\n" 2280 +
HelpExampleCli(
"lockunspent",
"true \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") +
2281 "\nAs a JSON-RPC call\n" 2288 const CWallet*
const pwallet = wallet.get();
2292 std::vector<COutPoint> vOutpts;
2297 for (
const COutPoint& outpt : vOutpts) {
2300 o.
pushKV(
"txid", outpt.hash.GetHex());
2301 o.
pushKV(
"vout", (
int)outpt.n);
2313 "\nSet the transaction fee per kB for this wallet. Overrides the global -paytxfee command line parameter.\n" 2314 "Can be deactivated by passing 0 as the fee. In that case automatic fee selection will be used by default.\n",
2329 CWallet*
const pwallet = wallet.get();
2334 CFeeRate tx_fee_rate(nAmount, 1000);
2338 }
else if (tx_fee_rate < pwallet->chain().relayMinFee()) {
2340 }
else if (tx_fee_rate < pwallet->m_min_fee) {
2342 }
else if (tx_fee_rate > max_tx_fee_rate) {
2356 "Returns an object with all balances in " +
CURRENCY_UNIT +
".\n",
2364 {
RPCResult::Type::STR_AMOUNT,
"untrusted_pending",
"untrusted pending balance (outputs created by others that are in the mempool)"},
2366 {
RPCResult::Type::STR_AMOUNT,
"used",
"(only present if avoid_reuse is set) balance from coins sent to addresses that were previously spent from (potentially privacy violating)"},
2368 {
RPCResult::Type::OBJ,
"watchonly",
"watchonly balances (not present if wallet does not watch anything)",
2371 {
RPCResult::Type::STR_AMOUNT,
"untrusted_pending",
"untrusted pending balance (outputs created by others that are in the mempool)"},
2387 wallet.BlockUntilSyncedToCurrentChain();
2396 balances_mine.pushKV(
"untrusted_pending",
ValueFromAmount(bal.m_mine_untrusted_pending));
2397 balances_mine.pushKV(
"immature",
ValueFromAmount(bal.m_mine_immature));
2401 const auto full_bal = wallet.
GetBalance(0,
false);
2402 balances_mine.pushKV(
"used",
ValueFromAmount(full_bal.m_mine_trusted + full_bal.m_mine_untrusted_pending - bal.m_mine_trusted - bal.m_mine_untrusted_pending));
2404 balances.pushKV(
"mine", balances_mine);
2407 if (spk_man && spk_man->HaveWatchOnly()) {
2409 balances_watchonly.pushKV(
"trusted",
ValueFromAmount(bal.m_watchonly_trusted));
2410 balances_watchonly.pushKV(
"untrusted_pending",
ValueFromAmount(bal.m_watchonly_untrusted_pending));
2411 balances_watchonly.pushKV(
"immature",
ValueFromAmount(bal.m_watchonly_immature));
2412 balances.pushKV(
"watchonly", balances_watchonly);
2422 "Returns an object containing various wallet state info.\n",
2436 {
RPCResult::Type::NUM,
"keypoolsize",
"how many new keys are pre-generated (only counts external keys)"},
2437 {
RPCResult::Type::NUM,
"keypoolsize_hd_internal",
"how many new keys are pre-generated for internal use (used for change outputs, only appears if the wallet is using this feature, otherwise external keys are used)"},
2438 {
RPCResult::Type::NUM_TIME,
"unlocked_until",
true,
"the " + UNIX_EPOCH_TIME +
" until which the wallet is unlocked for transfers, or 0 if the wallet is locked (only present for passphrase-encrypted wallets)"},
2441 {
RPCResult::Type::BOOL,
"private_keys_enabled",
"false if privatekeys are disabled for this wallet (enforced watch-only wallet)"},
2442 {
RPCResult::Type::BOOL,
"avoid_reuse",
"whether this wallet tracks clean/dirty coins in terms of reuse"},
2443 {
RPCResult::Type::OBJ,
"scanning",
"current scanning details, or false if no scan is in progress",
2448 {
RPCResult::Type::BOOL,
"descriptors",
"whether this wallet uses descriptors for scriptPubKey management"},
2459 const CWallet*
const pwallet = wallet.get();
2463 pwallet->BlockUntilSyncedToCurrentChain();
2478 obj.
pushKV(
"txcount", (
int)pwallet->mapWallet.size());
2479 if (kp_oldest > 0) {
2480 obj.
pushKV(
"keypoololdest", kp_oldest);
2482 obj.
pushKV(
"keypoolsize", (int64_t)kpExternalSize);
2496 obj.
pushKV(
"unlocked_until", pwallet->nRelockTime);
2505 obj.
pushKV(
"scanning", scanning);
2507 obj.
pushKV(
"scanning",
false);
2518 "Returns a list of wallets in the wallet directory.\n",
2541 wallet.
pushKV(
"name", path.string());
2546 result.
pushKV(
"wallets", wallets);
2555 "Returns a list of currently loaded wallets.\n" 2556 "For full information on the wallet, use \"getwalletinfo\"\n",
2585 "\nLoads a wallet from a wallet file or directory." 2586 "\nNote that all wallet command-line options used when starting bitcoind will be" 2587 "\napplied to the new wallet (eg -rescan, etc).\n",
2590 {
"load_on_startup",
RPCArg::Type::BOOL,
"null",
"Save wallet name to persistent settings and load on startup. True to add wallet to startup list, false to remove, null to leave unchanged."},
2606 const std::string
name(request.params[0].get_str());
2612 std::vector<bilingual_str> warnings;
2614 std::shared_ptr<CWallet>
const wallet =
LoadWallet(*context.
chain,
name, load_on_start, options, status, error, warnings);
2623 obj.
pushKV(
"name", wallet->GetName());
2633 std::string
flags =
"";
2636 flags += (flags ==
"" ?
"" :
", ") +
it.first;
2639 "\nChange the state of the given wallet flag for a wallet.\n",
2660 CWallet*
const pwallet = wallet.get();
2662 std::string flag_str = request.params[0].get_str();
2663 bool value = request.params[1].isNull() || request.params[1].get_bool();
2681 res.pushKV(
"flag_name", flag_str);
2682 res.pushKV(
"flag_state", value);
2703 "\nCreates and loads a new wallet.\n",
2706 {
"disable_private_keys",
RPCArg::Type::BOOL,
"false",
"Disable the possibility of private keys (only watchonlys are possible in this mode)."},
2707 {
"blank",
RPCArg::Type::BOOL,
"false",
"Create a blank wallet. A blank wallet has no keys or HD seed. One can be set using sethdseed."},
2709 {
"avoid_reuse",
RPCArg::Type::BOOL,
"false",
"Keep track of coin reuse, and treat dirty and clean coins differently with privacy considerations in mind."},
2710 {
"descriptors",
RPCArg::Type::BOOL,
"false",
"Create a native descriptor wallet. The wallet will use descriptors internally to handle address creation"},
2711 {
"load_on_startup",
RPCArg::Type::BOOL,
"null",
"Save wallet name to persistent settings and load on startup. True to add wallet to startup list, false to remove, null to leave unchanged."},
2716 {
RPCResult::Type::STR,
"name",
"The wallet name if created successfully. If the wallet was created using a full path, the wallet_name will be the full path."},
2728 if (!request.params[1].isNull() && request.params[1].get_bool()) {
2732 if (!request.params[2].isNull() && request.params[2].get_bool()) {
2736 passphrase.reserve(100);
2737 std::vector<bilingual_str> warnings;
2738 if (!request.params[3].isNull()) {
2739 passphrase = request.params[3].get_str().c_str();
2740 if (passphrase.empty()) {
2742 warnings.emplace_back(
Untranslated(
"Empty string given as passphrase, wallet will not be encrypted."));
2746 if (!request.params[4].isNull() && request.params[4].get_bool()) {
2749 if (!request.params[5].isNull() && request.params[5].get_bool()) {
2754 warnings.emplace_back(
Untranslated(
"Wallet is an experimental descriptor wallet"));
2770 std::shared_ptr<CWallet> wallet =
CreateWallet(*context.
chain, request.params[0].get_str(), load_on_start, options, status,
error, warnings);
2777 obj.
pushKV(
"name", wallet->GetName());
2788 "Unloads the wallet referenced by the request endpoint otherwise unloads the wallet specified in the argument.\n" 2789 "Specifying the wallet name on a wallet endpoint is invalid.",
2791 {
"wallet_name",
RPCArg::Type::STR,
"the wallet name from the RPC endpoint",
"The name of the wallet to unload. If provided both here and in the RPC endpoint, the two must be identical."},
2792 {
"load_on_startup",
RPCArg::Type::BOOL,
"null",
"Save wallet name to persistent settings and load on startup. True to add wallet to startup list, false to remove, null to leave unchanged."},
2803 std::string wallet_name;
2805 if (!(request.params[0].isNull() || request.params[0].get_str() == wallet_name)) {
2809 wallet_name = request.params[0].get_str();
2812 std::shared_ptr<CWallet> wallet =
GetWallet(wallet_name);
2820 std::vector<bilingual_str> warnings;
2839 "\nReturns array of unspent transaction outputs\n" 2840 "with between minconf and maxconf (inclusive) confirmations.\n" 2841 "Optionally filter to only include txouts paid to specified addresses.\n",
2844 {
"maxconf",
RPCArg::Type::NUM,
"9999999",
"The maximum confirmations to filter"},
2845 {
"addresses",
RPCArg::Type::ARR,
"empty array",
"The bitcoin addresses to filter",
2850 {
"include_unsafe",
RPCArg::Type::BOOL,
"true",
"Include outputs that are not safe to spend\n" 2851 "See description of \"safe\" attribute below."},
2855 {
"maximumAmount",
RPCArg::Type::AMOUNT,
"unlimited",
"Maximum value of each UTXO in " + CURRENCY_UNIT +
""},
2857 {
"minimumSumAmount",
RPCArg::Type::AMOUNT,
"unlimited",
"Minimum sum value of all UTXOs in " + CURRENCY_UNIT +
""},
2874 {
RPCResult::Type::STR,
"witnessScript",
"witnessScript if the scriptPubKey is P2WSH or P2SH-P2WSH"},
2876 {
RPCResult::Type::BOOL,
"solvable",
"Whether we know how to spend this output, ignoring the lack of keys"},
2877 {
RPCResult::Type::BOOL,
"reused",
"(only present if avoid_reuse is set) Whether this output is reused/dirty (sent to an address that was previously spent from)"},
2879 {
RPCResult::Type::BOOL,
"safe",
"Whether this output is considered safe to spend. Unconfirmed transactions\n" 2880 "from outside keys and unconfirmed replacement transactions are considered unsafe\n" 2881 "and are not eligible for spending by fundrawtransaction and sendtoaddress."},
2889 +
HelpExampleCli(
"listunspent",
"6 9999999 '[]' true '{ \"minimumAmount\": 0.005 }'")
2890 +
HelpExampleRpc(
"listunspent",
"6, 9999999, [] , true, { \"minimumAmount\": 0.005 } ")
2896 const CWallet*
const pwallet = wallet.get();
2899 if (!request.params[0].isNull()) {
2901 nMinDepth = request.params[0].get_int();
2904 int nMaxDepth = 9999999;
2905 if (!request.params[1].isNull()) {
2907 nMaxDepth = request.params[1].get_int();
2910 std::set<CTxDestination> destinations;
2911 if (!request.params[2].isNull()) {
2914 for (
unsigned int idx = 0; idx < inputs.
size(); idx++) {
2915 const UniValue& input = inputs[idx];
2920 if (!destinations.insert(dest).second) {
2926 bool include_unsafe =
true;
2927 if (!request.params[3].isNull()) {
2929 include_unsafe = request.params[3].get_bool();
2935 uint64_t nMaximumCount = 0;
2937 if (!request.params[4].isNull()) {
2949 if (options.
exists(
"minimumAmount"))
2952 if (options.
exists(
"maximumAmount"))
2955 if (options.
exists(
"minimumSumAmount"))
2958 if (options.
exists(
"maximumCount"))
2959 nMaximumCount = options[
"maximumCount"].get_int64();
2964 pwallet->BlockUntilSyncedToCurrentChain();
2967 std::vector<COutput> vecOutputs;
2974 pwallet->
AvailableCoins(vecOutputs, !include_unsafe, &cctl, nMinimumAmount, nMaximumAmount, nMinimumSumAmount, nMaximumCount);
2981 for (
const COutput& out : vecOutputs) {
2983 const CScript& scriptPubKey = out.tx->tx->vout[out.i].scriptPubKey;
2985 bool reused = avoid_reuse && pwallet->
IsSpentKey(out.tx->GetHash(), out.i);
2987 if (destinations.size() && (!fValidAddress || !destinations.count(address)))
2991 entry.
pushKV(
"txid", out.tx->GetHash().GetHex());
2992 entry.
pushKV(
"vout", out.i);
2994 if (fValidAddress) {
2998 if (address_book_entry) {
2999 entry.
pushKV(
"label", address_book_entry->GetLabel());
3002 std::unique_ptr<SigningProvider> provider = pwallet->
GetSolvingProvider(scriptPubKey);
3007 if (provider->GetCScript(hash, redeemScript)) {
3019 if (provider->GetCScript(
id, witnessScript)) {
3029 if (provider->GetCScript(
id, witnessScript)) {
3038 entry.
pushKV(
"confirmations", out.nDepth);
3039 entry.
pushKV(
"spendable", out.fSpendable);
3040 entry.
pushKV(
"solvable", out.fSolvable);
3041 if (out.fSolvable) {
3042 std::unique_ptr<SigningProvider> provider = pwallet->
GetSolvingProvider(scriptPubKey);
3045 entry.
pushKV(
"desc", descriptor->ToString());
3048 if (avoid_reuse) entry.
pushKV(
"reused", reused);
3049 entry.
pushKV(
"safe", out.fSafe);
3062 pwallet->BlockUntilSyncedToCurrentChain();
3064 change_position = -1;
3065 bool lockUnspents =
false;
3067 std::set<int> setSubtractFeeFromOutputs;
3102 if (options.
exists(
"add_inputs") ) {
3106 if (options.
exists(
"changeAddress") || options.
exists(
"change_address")) {
3107 const std::string change_address_str = (options.
exists(
"change_address") ? options[
"change_address"] : options[
"changeAddress"]).get_str();
3117 if (options.
exists(
"changePosition") || options.
exists(
"change_position")) {
3118 change_position = (options.
exists(
"change_position") ? options[
"change_position"] : options[
"changePosition"]).get_int();
3121 if (options.
exists(
"change_type")) {
3122 if (options.
exists(
"changeAddress") || options.
exists(
"change_address")) {
3132 const UniValue include_watching_option = options.
exists(
"include_watching") ? options[
"include_watching"] : options[
"includeWatching"];
3135 if (options.
exists(
"lockUnspents") || options.
exists(
"lock_unspents")) {
3136 lockUnspents = (options.
exists(
"lock_unspents") ? options[
"lock_unspents"] : options[
"lockUnspents"]).get_bool();
3139 if (options.
exists(
"feeRate")) {
3140 if (options.
exists(
"fee_rate")) {
3143 if (options.
exists(
"conf_target")) {
3144 throw JSONRPCError(
RPC_INVALID_PARAMETER,
"Cannot specify both conf_target and feeRate. Please provide either a confirmation target in blocks for automatic fee estimation, or an explicit fee rate.");
3146 if (options.
exists(
"estimate_mode")) {
3153 if (options.
exists(
"subtractFeeFromOutputs") || options.
exists(
"subtract_fee_from_outputs") )
3154 subtractFeeFromOutputs = (options.
exists(
"subtract_fee_from_outputs") ? options[
"subtract_fee_from_outputs"] : options[
"subtractFeeFromOutputs"]).get_array();
3156 if (options.
exists(
"replaceable")) {
3159 SetFeeEstimateMode(*pwallet, coinControl, options[
"conf_target"], options[
"estimate_mode"], options[
"fee_rate"], override_min_fee);
3166 if (tx.
vout.size() == 0)
3169 if (change_position != -1 && (change_position < 0 || (
unsigned int)change_position > tx.
vout.size()))
3172 for (
unsigned int idx = 0; idx < subtractFeeFromOutputs.
size(); idx++) {
3173 int pos = subtractFeeFromOutputs[idx].
get_int();
3174 if (setSubtractFeeFromOutputs.count(pos))
3178 if (pos >=
int(tx.
vout.size()))
3180 setSubtractFeeFromOutputs.insert(pos);
3185 if (!pwallet->
FundTransaction(tx, fee_out, change_position, error, lockUnspents, setSubtractFeeFromOutputs, coinControl)) {
3193 "\nIf the transaction has no inputs, they will be automatically selected to meet its out value.\n" 3194 "It will add at most one change output to the outputs.\n" 3195 "No existing outputs will be modified unless \"subtractFeeFromOutputs\" is specified.\n" 3196 "Note that inputs which were signed may need to be resigned after completion since in/outputs have been added.\n" 3197 "The inputs added will not be signed, use signrawtransactionwithkey\n" 3198 " or signrawtransactionwithwallet for that.\n" 3199 "Note that all existing inputs must have their previous output transaction be in the wallet.\n" 3200 "Note that all inputs selected must be of standard form and P2SH scripts must be\n" 3201 "in the wallet using importaddress or addmultisigaddress (to calculate fees).\n" 3202 "You can see whether this is the case by checking the \"solvable\" field in the listunspent output.\n" 3203 "Only pay-to-pubkey, multisig, and P2SH versions thereof are currently supported for watch-only\n",
3208 {
"add_inputs",
RPCArg::Type::BOOL,
"true",
"For a transaction with existing inputs, automatically include more if they are not enough."},
3209 {
"changeAddress",
RPCArg::Type::STR,
"pool address",
"The bitcoin address to receive the change"},
3210 {
"changePosition",
RPCArg::Type::NUM,
"random",
"The index of the change output"},
3211 {
"change_type",
RPCArg::Type::STR,
"set by -changetype",
"The output type to use. Only valid if changeAddress is not specified. Options are \"legacy\", \"p2sh-segwit\", and \"bech32\"."},
3212 {
"includeWatching",
RPCArg::Type::BOOL,
"true for watch-only wallets, otherwise false",
"Also select inputs which are watch only.\n" 3213 "Only solvable inputs can be used. Watch-only destinations are solvable if the public key and/or output script was imported,\n" 3214 "e.g. with 'importpubkey' or 'importmulti' with the 'pubkeys' or 'desc' field."},
3219 "The fee will be equally deducted from the amount of each specified output.\n" 3220 "Those recipients will receive less bitcoins than you enter in their corresponding amount field.\n" 3221 "If no outputs are specified here, the sender pays the fee.",
3226 {
"replaceable",
RPCArg::Type::BOOL,
"wallet default",
"Marks this transaction as BIP125 replaceable.\n" 3227 "Allows this transaction to be replaced by a transaction with higher fees"},
3228 {
"conf_target",
RPCArg::Type::NUM,
"wallet -txconfirmtarget",
"Confirmation target in blocks"},
3229 {
"estimate_mode",
RPCArg::Type::STR,
"unset", std::string() +
"The fee estimate mode, must be one of (case insensitive):\n" 3230 " \"" +
FeeModes(
"\"\n\"") +
"\""},
3233 {
"iswitness",
RPCArg::Type::BOOL,
"depends on heuristic tests",
"Whether the transaction hex is a serialized witness transaction.\n" 3234 "If iswitness is not present, heuristic tests will be used in decoding.\n" 3235 "If true, only witness deserialization will be tried.\n" 3236 "If false, only non-witness deserialization will be tried.\n" 3237 "This boolean should reflect whether the transaction has inputs\n" 3238 "(e.g. fully valid, or on-chain transactions), if known by the caller." 3250 "\nCreate a transaction with no inputs\n" 3251 +
HelpExampleCli(
"createrawtransaction",
"\"[]\" \"{\\\"myaddress\\\":0.01}\"") +
3252 "\nAdd sufficient unsigned inputs to meet the output value\n" 3253 +
HelpExampleCli(
"fundrawtransaction",
"\"rawtransactionhex\"") +
3254 "\nSign the transaction\n" 3255 +
HelpExampleCli(
"signrawtransactionwithwallet",
"\"fundedtransactionhex\"") +
3256 "\nSend the transaction\n" 3257 +
HelpExampleCli(
"sendrawtransaction",
"\"signedtransactionhex\"")
3263 CWallet*
const pwallet = wallet.get();
3265 RPCTypeCheck(request.params, {UniValue::VSTR, UniValueType(), UniValue::VBOOL});
3269 bool try_witness = request.params[2].isNull() ? true : request.params[2].get_bool();
3270 bool try_no_witness = request.params[2].isNull() ? true : !request.params[2].get_bool();
3271 if (!
DecodeHexTx(tx, request.params[0].get_str(), try_no_witness, try_witness)) {
3276 int change_position;
3280 FundTransaction(pwallet, tx, fee, change_position, request.params[1], coin_control,
true);
3285 result.
pushKV(
"changepos", change_position);
3294 return RPCHelpMan{
"signrawtransactionwithwallet",
3295 "\nSign inputs for raw transaction (serialized, hex-encoded).\n" 3296 "The second optional argument (may be null) is an array of previous transaction outputs that\n" 3297 "this transaction depends on but may not yet be in the block chain." +
3315 {
"sighashtype",
RPCArg::Type::STR,
"ALL",
"The signature hash type. Must be one of\n" 3319 " \"ALL|ANYONECANPAY\"\n" 3320 " \"NONE|ANYONECANPAY\"\n" 3321 " \"SINGLE|ANYONECANPAY\""},
3349 const CWallet*
const pwallet = wallet.get();
3351 RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VARR, UniValue::VSTR},
true);
3354 if (!
DecodeHexTx(mtx, request.params[0].get_str())) {
3363 std::map<COutPoint, Coin> coins;
3364 for (
const CTxIn& txin : mtx.
vin) {
3375 std::map<int, std::string> input_errors;
3377 bool complete = pwallet->
SignTransaction(mtx, coins, nHashType, input_errors);
3387 bool want_psbt = method_name ==
"psbtbumpfee";
3391 "\nBumps the fee of an opt-in-RBF transaction T, replacing it with a new transaction B.\n" 3392 + std::string(want_psbt ?
"Returns a PSBT instead of creating and signing a new transaction.\n" :
"") +
3393 "An opt-in RBF transaction with the given txid must be in the wallet.\n" 3394 "The command will pay the additional fee by reducing change outputs or adding inputs when necessary.\n" 3395 "It may add a new change output if one does not already exist.\n" 3396 "All inputs in the original transaction will be included in the replacement transaction.\n" 3397 "The command will fail if the wallet or mempool contains a transaction that spends one of T's outputs.\n" 3398 "By default, the new fee will be calculated automatically using the estimatesmartfee RPC.\n" 3399 "The user can specify a confirmation target for estimatesmartfee.\n" 3400 "Alternatively, the user can specify a fee rate in " +
CURRENCY_ATOM +
"/vB for the new transaction.\n" 3401 "At a minimum, the new fee rate must be high enough to pay an additional new relay fee (incrementalfee\n" 3402 "returned by getnetworkinfo) to enter the node's mempool.\n" 3403 "* WARNING: before version 0.21, fee_rate was in " +
CURRENCY_UNIT +
"/kvB. As of 0.21, fee_rate is in " +
CURRENCY_ATOM +
"/vB. *\n",
3408 {
"conf_target",
RPCArg::Type::NUM,
"wallet -txconfirmtarget",
"Confirmation target in blocks\n"},
3410 "\nSpecify a fee rate in " + CURRENCY_ATOM +
"/vB instead of relying on the built-in fee estimator.\n" 3411 "Must be at least " + incremental_fee +
" higher than the current transaction fee rate.\n" 3412 "WARNING: before version 0.21, fee_rate was in " +
CURRENCY_UNIT +
"/kvB. As of 0.21, fee_rate is in " + CURRENCY_ATOM +
"/vB.\n"},
3413 {
"replaceable",
RPCArg::Type::BOOL,
"true",
"Whether the new transaction should still be\n" 3414 "marked bip-125 replaceable. If true, the sequence numbers in the transaction will\n" 3415 "be left unchanged from the original. If false, any input sequence numbers in the\n" 3416 "original transaction that were less than 0xfffffffe will be increased to 0xfffffffe\n" 3417 "so the new transaction will not be explicitly bip-125 replaceable (though it may\n" 3418 "still be replaceable in practice, for example if it has unconfirmed ancestors which\n" 3419 "are replaceable).\n"},
3420 {
"estimate_mode",
RPCArg::Type::STR,
"unset", std::string() +
"The fee estimate mode, must be one of (case insensitive):\n" 3421 " \"" +
FeeModes(
"\"\n\"") +
"\""},
3428 {
RPCResult::Type::STR,
"psbt",
"The base64-encoded unsigned PSBT of the new transaction." + std::string(want_psbt ?
"" :
" Only returned when wallet private keys are disabled. (DEPRECATED)")},
3430 want_psbt ? std::vector<RPCResult>{} : std::vector<RPCResult>{{
RPCResult::Type::STR_HEX,
"txid",
"The id of the new transaction. Only returned when wallet private keys are enabled."}}
3442 "\nBump the fee, get the new transaction\'s" + std::string(want_psbt ?
"psbt" :
"txid") +
"\n" +
3449 CWallet*
const pwallet = wallet.get();
3452 throw JSONRPCError(
RPC_WALLET_ERROR,
"bumpfee is not available with wallets that have private keys disabled. Use psbtbumpfee instead.");
3455 RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VOBJ});
3463 if (!request.params[1].isNull()) {
3464 UniValue options = request.params[1];
3475 if (options.
exists(
"confTarget") && options.
exists(
"conf_target")) {
3479 auto conf_target = options.
exists(
"confTarget") ? options[
"confTarget"] : options[
"conf_target"];
3481 if (options.
exists(
"replaceable")) {
3484 SetFeeEstimateMode(*pwallet, coin_control, conf_target, options[
"estimate_mode"], options[
"fee_rate"],
false);
3489 pwallet->BlockUntilSyncedToCurrentChain();
3495 std::vector<bilingual_str> errors;
3539 bool complete =
false;
3554 result.
pushKV(
"errors", result_errors);
3567 "\nRescan the local blockchain for wallet related transactions.\n" 3568 "Note: Use \"getwalletinfo\" to query the scanning progress.\n",
3570 {
"start_height",
RPCArg::Type::NUM,
"0",
"block height where the rescan should start"},
3576 {
RPCResult::Type::NUM,
"start_height",
"The block height where the rescan started (the requested height or 0)"},
3577 {
RPCResult::Type::NUM,
"stop_height",
"The height of the last rescanned block. May be null in rare cases if there was a reorg and the call didn't scan any blocks because they were already scanned in the background."},
3588 CWallet*
const pwallet = wallet.get();
3595 int start_height = 0;
3602 if (!request.params[0].isNull()) {
3603 start_height = request.params[0].get_int();
3604 if (start_height < 0 || start_height > tip_height) {
3609 if (!request.params[1].isNull()) {
3610 stop_height = request.params[1].get_int();
3611 if (*stop_height < 0 || *stop_height > tip_height) {
3613 }
else if (*stop_height < start_height) {
3620 throw JSONRPCError(
RPC_MISC_ERROR,
"Can't rescan beyond pruned data. Use RPC call getblockchaininfo to determine your pruned height.");
3638 response.
pushKV(
"start_height", start_height);
3653 std::vector<std::vector<unsigned char>> solutions_data;
3664 UniValue wallet_detail = std::visit(*
this, embedded);
3665 subobj.
pushKVs(wallet_detail);
3669 if (subobj.
exists(
"pubkey")) obj.
pushKV(
"pubkey", subobj[
"pubkey"]);
3670 obj.
pushKV(
"embedded", std::move(subobj));
3674 obj.
pushKV(
"sigsrequired", solutions_data[0][0]);
3676 for (
size_t i = 1; i < solutions_data.size() - 1; ++i) {
3677 CPubKey key(solutions_data[i].begin(), solutions_data[i].end());
3680 obj.
pushKV(
"pubkeys", std::move(pubkeys));
3693 if (provider && provider->
GetPubKey(keyID, vchPubKey)) {
3705 if (provider && provider->
GetCScript(scriptID, subscript)) {
3706 ProcessSubScript(subscript, obj);
3729 ProcessSubScript(subscript, obj);
3742 std::unique_ptr<SigningProvider> provider =
nullptr;
3765 "\nReturn information about the given bitcoin address.\n" 3766 "Some of the information will only be present if the address is in the active wallet.\n",
3777 {
RPCResult::Type::BOOL,
"solvable",
"If we know how to spend coins sent to this address, ignoring the possible lack of private keys."},
3778 {
RPCResult::Type::STR,
"desc",
true,
"A descriptor for spending coins sent to this address (only when solvable)."},
3784 {
RPCResult::Type::STR,
"script",
true,
"The output script type. Only if isscript is true and the redeemscript is known. Possible\n" 3785 "types: nonstandard, pubkey, pubkeyhash, scripthash, multisig, nulldata, witness_v0_keyhash,\n" 3786 "witness_v0_scripthash, witness_unknown."},
3788 {
RPCResult::Type::ARR,
"pubkeys",
true,
"Array of pubkeys associated with the known redeemscript (only if script is multisig).",
3792 {
RPCResult::Type::NUM,
"sigsrequired",
true,
"The number of signatures required to spend multisig output (only if script is multisig)."},
3793 {
RPCResult::Type::STR_HEX,
"pubkey",
true,
"The hex value of the raw public key for single-key addresses (possibly embedded in P2SH or P2WSH)."},
3794 {
RPCResult::Type::OBJ,
"embedded",
true,
"Information about the address embedded in P2SH or P2WSH, if relevant and known.",
3796 {
RPCResult::Type::ELISION,
"",
"Includes all getaddressinfo output fields for the embedded address, excluding metadata (timestamp, hdkeypath, hdseedid)\n" 3797 "and relation to the wallet (ismine, iswatchonly)."},
3804 {
RPCResult::Type::ARR,
"labels",
"Array of labels associated with the address. Currently limited to one label but returned\n" 3805 "as an array to keep the API stable if multiple labels are enabled in the future.",
3819 const CWallet*
const pwallet = wallet.get();
3831 ret.
pushKV(
"address", currentAddress);
3836 std::unique_ptr<SigningProvider> provider = pwallet->
GetSolvingProvider(scriptPubKey);
3841 bool solvable = provider &&
IsSolvable(*provider, scriptPubKey);
3842 ret.
pushKV(
"solvable", solvable);
3857 if (
const std::unique_ptr<CKeyMetadata> meta = spk_man->
GetMetadata(dest)) {
3858 ret.
pushKV(
"timestamp", meta->nCreateTime);
3859 if (meta->has_key_origin) {
3861 ret.
pushKV(
"hdseedid", meta->hd_seed_id.GetHex());
3862 ret.
pushKV(
"hdmasterfingerprint",
HexStr(meta->key_origin.fingerprint));
3874 if (address_book_entry) {
3875 labels.
push_back(address_book_entry->GetLabel());
3877 ret.
pushKV(
"labels", std::move(labels));
3887 "\nReturns the list of addresses assigned the specified label.\n",
3896 {
RPCResult::Type::STR,
"purpose",
"Purpose of address (\"send\" for sending address, \"receive\" for receiving address)"},
3908 const CWallet*
const pwallet = wallet.get();
3916 std::set<std::string> addresses;
3917 for (
const std::pair<const CTxDestination, CAddressBookData>& item : pwallet->m_address_book) {
3918 if (item.second.IsChange())
continue;
3919 if (item.second.GetLabel() == label) {
3924 bool unique = addresses.emplace(address).second;
3946 "\nReturns the list of all labels, or labels that are assigned to addresses with a specific purpose.\n",
3957 "\nList all labels\n" 3959 "\nList labels that have receiving addresses\n" 3961 "\nList labels that have sending addresses\n" 3963 "\nAs a JSON-RPC call\n" 3970 const CWallet*
const pwallet = wallet.get();
3974 std::string purpose;
3975 if (!request.params[0].isNull()) {
3976 purpose = request.params[0].get_str();
3980 std::set<std::string> label_set;
3981 for (
const std::pair<const CTxDestination, CAddressBookData>& entry : pwallet->m_address_book) {
3982 if (entry.second.IsChange())
continue;
3983 if (purpose.empty() || entry.second.purpose == purpose) {
3984 label_set.insert(entry.second.GetLabel());
3989 for (
const std::string&
name : label_set) {
4001 "\nEXPERIMENTAL warning: this call may be changed in future releases.\n" 4002 "\nSend a transaction.\n",
4005 "That is, each address can only appear once and there can only be one 'data' object.\n" 4006 "For convenience, a dictionary, which holds the key-value pairs directly, is also accepted.",
4020 {
"conf_target",
RPCArg::Type::NUM,
"wallet -txconfirmtarget",
"Confirmation target in blocks"},
4021 {
"estimate_mode",
RPCArg::Type::STR,
"unset", std::string() +
"The fee estimate mode, must be one of (case insensitive):\n" 4022 " \"" +
FeeModes(
"\"\n\"") +
"\""},
4026 {
"add_inputs",
RPCArg::Type::BOOL,
"false",
"If inputs are specified, automatically include more if they are not enough."},
4027 {
"add_to_wallet",
RPCArg::Type::BOOL,
"true",
"When false, returns a serialized transaction which will not be added to the wallet or broadcast"},
4028 {
"change_address",
RPCArg::Type::STR_HEX,
"pool address",
"The bitcoin address to receive the change"},
4029 {
"change_position",
RPCArg::Type::NUM,
"random",
"The index of the change output"},
4030 {
"change_type",
RPCArg::Type::STR,
"set by -changetype",
"The output type to use. Only valid if change_address is not specified. Options are \"legacy\", \"p2sh-segwit\", and \"bech32\"."},
4031 {
"conf_target",
RPCArg::Type::NUM,
"wallet -txconfirmtarget",
"Confirmation target in blocks"},
4032 {
"estimate_mode",
RPCArg::Type::STR,
"unset", std::string() +
"The fee estimate mode, must be one of (case insensitive):\n" 4033 " \"" +
FeeModes(
"\"\n\"") +
"\""},
4034 {
"fee_rate",
RPCArg::Type::AMOUNT,
"not set, fall back to wallet fee estimation",
"Specify a fee rate in " + CURRENCY_ATOM +
"/vB."},
4035 {
"include_watching",
RPCArg::Type::BOOL,
"true for watch-only wallets, otherwise false",
"Also select inputs which are watch only.\n" 4036 "Only solvable inputs can be used. Watch-only destinations are solvable if the public key and/or output script was imported,\n" 4037 "e.g. with 'importpubkey' or 'importmulti' with the 'pubkeys' or 'desc' field."},
4038 {
"inputs",
RPCArg::Type::ARR,
"empty array",
"Specify inputs instead of adding them automatically. A JSON array of JSON objects",
4045 {
"locktime",
RPCArg::Type::NUM,
"0",
"Raw locktime. Non-0 value also locktime-activates inputs"},
4047 {
"psbt",
RPCArg::Type::BOOL,
"automatic",
"Always return a PSBT, implies add_to_wallet=false."},
4048 {
"subtract_fee_from_outputs",
RPCArg::Type::ARR,
"empty array",
"Outputs to subtract the fee from, specified as integer indices.\n" 4049 "The fee will be equally deducted from the amount of each specified output.\n" 4050 "Those recipients will receive less bitcoins than you enter in their corresponding amount field.\n" 4051 "If no outputs are specified here, the sender pays the fee.",
4056 {
"replaceable",
RPCArg::Type::BOOL,
"wallet default",
"Marks this transaction as BIP125 replaceable.\n" 4057 "Allows this transaction to be replaced by a transaction with higher fees"},
4065 {
RPCResult::Type::STR_HEX,
"txid",
"The transaction id for the send. Only 1 transaction is created regardless of the number of addresses."},
4067 {
RPCResult::Type::STR,
"psbt",
"If more signatures are needed, or if add_to_wallet is false, the base64-encoded (partially) signed transaction"}
4071 "\nSend 0.1 BTC with a confirmation target of 6 blocks in economical fee estimate mode\n" 4073 "Send 0.2 BTC with a fee rate of 1.1 " +
CURRENCY_ATOM +
"/vB using positional arguments\n" 4075 "Send 0.2 BTC with a fee rate of 1 " +
CURRENCY_ATOM +
"/vB using the options argument\n" 4077 "Send 0.3 BTC with a fee rate of 25 " +
CURRENCY_ATOM +
"/vB using named arguments\n" 4079 "Create a transaction that should confirm the next block, with a specific input, and return result without adding to wallet or broadcasting to the network\n" 4080 +
HelpExampleCli(
"send",
"'{\"" +
EXAMPLE_ADDRESS[0] +
"\": 0.1}' 1 economical '{\"add_to_wallet\": false, \"inputs\": [{\"txid\":\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\", \"vout\":1}]}'")
4095 CWallet*
const pwallet = wallet.get();
4098 if (options.exists(
"conf_target") || options.exists(
"estimate_mode")) {
4099 if (!request.params[1].isNull() || !request.params[2].isNull()) {
4103 options.pushKV(
"conf_target", request.params[1]);
4104 options.pushKV(
"estimate_mode", request.params[2]);
4106 if (options.exists(
"fee_rate")) {
4107 if (!request.params[3].isNull()) {
4111 options.pushKV(
"fee_rate", request.params[3]);
4113 if (!options[
"conf_target"].isNull() && (options[
"estimate_mode"].isNull() || (options[
"estimate_mode"].get_str() ==
"unset"))) {
4116 if (options.exists(
"feeRate")) {
4119 if (options.exists(
"changeAddress")) {
4122 if (options.exists(
"changePosition")) {
4125 if (options.exists(
"includeWatching")) {
4128 if (options.exists(
"lockUnspents")) {
4131 if (options.exists(
"subtractFeeFromOutputs")) {
4135 const bool psbt_opt_in = options.exists(
"psbt") && options[
"psbt"].get_bool();
4138 int change_position;
4140 if (options.exists(
"replaceable")) {
4141 rbf = options[
"replaceable"].get_bool();
4148 FundTransaction(pwallet, rawTx, fee, change_position, options, coin_control,
false);
4150 bool add_to_wallet =
true;
4151 if (options.exists(
"add_to_wallet")) {
4152 add_to_wallet = options[
"add_to_wallet"].get_bool();
4159 bool complete =
true;
4170 if (psbt_opt_in || !complete || !add_to_wallet) {
4178 std::string err_string;
4181 result.
pushKV(
"txid", tx->GetHash().GetHex());
4182 if (add_to_wallet && !psbt_opt_in) {
4185 result.
pushKV(
"hex", hex);
4188 result.
pushKV(
"complete", complete);
4198 "\nSet or generate a new HD wallet seed. Non-HD wallets will not be upgraded to being a HD wallet. Wallets that are already\n" 4199 "HD will have a new HD seed set so that new keys added to the keypool will be derived from this new seed.\n" 4200 "\nNote that you will need to MAKE A NEW BACKUP of your wallet after setting the HD wallet seed." +
4203 {
"newkeypool",
RPCArg::Type::BOOL,
"true",
"Whether to flush old unused addresses, including change addresses, from the keypool and regenerate it.\n" 4204 "If true, the next address from getnewaddress and change address from getrawchangeaddress will be from this new seed.\n" 4205 "If false, addresses (including change addresses if the wallet already had HD Chain Split enabled) from the existing\n" 4206 "keypool will be used until it has been depleted."},
4207 {
"seed",
RPCArg::Type::STR,
"random seed",
"The WIF private key to use as the new HD seed.\n" 4208 "The seed value can be retrieved using the dumpwallet command. It is the private key marked hdseed=1"},
4221 CWallet*
const pwallet = wallet.get();
4233 throw JSONRPCError(
RPC_WALLET_ERROR,
"Cannot set an HD seed on a non-HD wallet. Use the upgradewallet RPC in order to upgrade a non-HD wallet to HD");
4238 bool flush_key_pool =
true;
4239 if (!request.params[0].isNull()) {
4240 flush_key_pool = request.params[0].get_bool();
4244 if (request.params[1].isNull()) {
4270 "\nUpdate a PSBT with input information from our wallet and then sign inputs\n" 4271 "that we can sign for." +
4276 {
"sighashtype",
RPCArg::Type::STR,
"ALL",
"The signature hash type to sign with if not specified by the PSBT. Must be one of\n" 4280 " \"ALL|ANYONECANPAY\"\n" 4281 " \"NONE|ANYONECANPAY\"\n" 4282 " \"SINGLE|ANYONECANPAY\""},
4283 {
"bip32derivs",
RPCArg::Type::BOOL,
"true",
"Include BIP 32 derivation paths for public keys if we know them"},
4299 const CWallet*
const pwallet = wallet.get();
4301 RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL, UniValue::VSTR});
4314 bool sign = request.params[1].isNull() ? true : request.params[1].get_bool();
4315 bool bip32derivs = request.params[3].isNull() ? true : request.params[3].get_bool();
4316 bool complete =
true;
4326 result.
pushKV(
"complete", complete);
4336 "\nCreates and funds a transaction in the Partially Signed Transaction format.\n" 4337 "Implements the Creator and Updater roles.\n",
4345 {
"sequence",
RPCArg::Type::NUM,
"depends on the value of the 'locktime' and 'options.replaceable' arguments",
"The sequence number"},
4351 "That is, each address can only appear once and there can only be one 'data' object.\n" 4352 "For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also\n" 4353 "accepted as second parameter.",
4367 {
"locktime",
RPCArg::Type::NUM,
"0",
"Raw locktime. Non-0 value also locktime-activates inputs"},
4370 {
"add_inputs",
RPCArg::Type::BOOL,
"false",
"If inputs are specified, automatically include more if they are not enough."},
4371 {
"changeAddress",
RPCArg::Type::STR_HEX,
"pool address",
"The bitcoin address to receive the change"},
4372 {
"changePosition",
RPCArg::Type::NUM,
"random",
"The index of the change output"},
4373 {
"change_type",
RPCArg::Type::STR,
"set by -changetype",
"The output type to use. Only valid if changeAddress is not specified. Options are \"legacy\", \"p2sh-segwit\", and \"bech32\"."},
4374 {
"includeWatching",
RPCArg::Type::BOOL,
"true for watch-only wallets, otherwise false",
"Also select inputs which are watch only"},
4378 {
"subtractFeeFromOutputs",
RPCArg::Type::ARR,
"empty array",
"The outputs to subtract the fee from.\n" 4379 "The fee will be equally deducted from the amount of each specified output.\n" 4380 "Those recipients will receive less bitcoins than you enter in their corresponding amount field.\n" 4381 "If no outputs are specified here, the sender pays the fee.",
4386 {
"replaceable",
RPCArg::Type::BOOL,
"wallet default",
"Marks this transaction as BIP125 replaceable.\n" 4387 "Allows this transaction to be replaced by a transaction with higher fees"},
4388 {
"conf_target",
RPCArg::Type::NUM,
"wallet -txconfirmtarget",
"Confirmation target in blocks"},
4389 {
"estimate_mode",
RPCArg::Type::STR,
"unset", std::string() +
"The fee estimate mode, must be one of (case insensitive):\n" 4390 " \"" +
FeeModes(
"\"\n\"") +
"\""},
4393 {
"bip32derivs",
RPCArg::Type::BOOL,
"true",
"Include BIP 32 derivation paths for public keys if we know them"},
4404 "\nCreate a transaction with no inputs\n" 4405 +
HelpExampleCli(
"walletcreatefundedpsbt",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
4411 CWallet*
const pwallet = wallet.get();
4423 int change_position;
4425 const UniValue &replaceable_arg = request.params[3][
"replaceable"];
4426 if (!replaceable_arg.
isNull()) {
4428 rbf = replaceable_arg.
isTrue();
4435 FundTransaction(pwallet, rawTx, fee, change_position, request.params[3], coin_control,
true);
4441 bool bip32derivs = request.params[4].isNull() ? true : request.params[4].get_bool();
4442 bool complete =
true;
4455 result.
pushKV(
"changepos", change_position);
4464 "\nUpgrade the wallet. Upgrades to the latest version if no version number is specified.\n" 4465 "New keys may be generated and a new wallet backup will need to be made.",
4487 CWallet*
const pwallet = wallet.get();
4494 if (!request.params[0].isNull()) {
4495 version = request.params[0].get_int();
4498 const int previous_version{pwallet->
GetVersion()};
4499 const bool wallet_upgraded{pwallet->
UpgradeWallet(version, error)};
4500 const int current_version{pwallet->
GetVersion()};
4503 if (wallet_upgraded) {
4504 if (previous_version == current_version) {
4505 result =
"Already at latest version. Wallet version unchanged.";
4507 result =
strprintf(
"Wallet upgraded successfully from version %i to version %i.", previous_version, current_version);
4513 obj.
pushKV(
"previous_version", previous_version);
4514 obj.
pushKV(
"current_version", current_version);
4515 if (!result.empty()) {
4516 obj.
pushKV(
"result", result);
4544 {
"rawtransactions",
"fundrawtransaction", &
fundrawtransaction, {
"hexstring",
"options",
"iswitness"} },
4547 {
"wallet",
"addmultisigaddress", &
addmultisigaddress, {
"nrequired",
"keys",
"label",
"address_type"} },
4548 {
"wallet",
"backupwallet", &
backupwallet, {
"destination"} },
4549 {
"wallet",
"bumpfee", &
bumpfee, {
"txid",
"options"} },
4550 {
"wallet",
"psbtbumpfee", &
psbtbumpfee, {
"txid",
"options"} },
4551 {
"wallet",
"createwallet", &
createwallet, {
"wallet_name",
"disable_private_keys",
"blank",
"passphrase",
"avoid_reuse",
"descriptors",
"load_on_startup"} },
4552 {
"wallet",
"dumpprivkey", &
dumpprivkey, {
"address"} },
4553 {
"wallet",
"dumpwallet", &
dumpwallet, {
"filename"} },
4554 {
"wallet",
"encryptwallet", &
encryptwallet, {
"passphrase"} },
4557 {
"wallet",
"getbalance", &
getbalance, {
"dummy",
"minconf",
"include_watchonly",
"avoid_reuse"} },
4558 {
"wallet",
"getnewaddress", &
getnewaddress, {
"label",
"address_type"} },
4562 {
"wallet",
"gettransaction", &
gettransaction, {
"txid",
"include_watchonly",
"verbose"} },
4566 {
"wallet",
"importaddress", &
importaddress, {
"address",
"label",
"rescan",
"p2sh"} },
4568 {
"wallet",
"importmulti", &
importmulti, {
"requests",
"options"} },
4569 {
"wallet",
"importprivkey", &
importprivkey, {
"privkey",
"label",
"rescan"} },
4570 {
"wallet",
"importprunedfunds", &
importprunedfunds, {
"rawtransaction",
"txoutproof"} },
4571 {
"wallet",
"importpubkey", &
importpubkey, {
"pubkey",
"label",
"rescan"} },
4572 {
"wallet",
"importwallet", &
importwallet, {
"filename"} },
4575 {
"wallet",
"listlabels", &
listlabels, {
"purpose"} },