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()) {
83 key2.Set(key.begin(), key.end(), !key.IsCompressed());
84 return wallet.
HaveKey(key.GetPubKey().GetID()) || wallet.
HaveKey(key2.GetPubKey().GetID());
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};
395 recipients.push_back(recipient);
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 = boost::get<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();
1133 bool fIsWatchonly =
false;
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)
1174 CAmount nAmount = entry.second.nAmount;
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"},
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"},
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")
1569 const CWallet& wallet = *pwallet;
1572 wallet.BlockUntilSyncedToCurrentChain();
1579 int target_confirms = 1;
1583 if (!request.params[0].isNull() && !request.params[0].get_str().empty()) {
1584 blockId =
ParseHashV(request.params[0],
"blockhash");
1592 if (!request.params[1].isNull()) {
1593 target_confirms = request.params[1].get_int();
1595 if (target_confirms < 1) {
1604 bool include_removed = (request.params[3].isNull() || request.params[3].get_bool());
1610 for (
const std::pair<const uint256, CWalletTx>& pairWtx : wallet.mapWallet) {
1621 while (include_removed && altheight && *altheight > *height) {
1627 auto it = wallet.mapWallet.find(tx->GetHash());
1628 if (
it != wallet.mapWallet.end()) {
1643 ret.
pushKV(
"transactions", transactions);
1644 if (include_removed) ret.
pushKV(
"removed", removed);
1655 "\nGet detailed information about in-wallet transaction <txid>\n",
1658 {
"include_watchonly",
RPCArg::Type::BOOL,
"true for watch-only wallets, otherwise false",
1659 "Whether to include watch-only addresses in balance calculation and details[]"},
1661 "Whether to include a `decoded` field containing the decoded transaction (equivalent to RPC decoderawtransaction)"},
1668 "'send' category of transactions."},
1676 {
RPCResult::Type::BOOL,
"involvesWatchonly",
"Only returns true if imported addresses were involved in transaction."},
1679 "\"send\" Transactions sent.\n"
1680 "\"receive\" Non-coinbase transactions received.\n"
1681 "\"generate\" Coinbase transactions received with more than 100 confirmations.\n"
1682 "\"immature\" Coinbase transactions received with 100 or fewer confirmations.\n"
1683 "\"orphan\" Orphaned coinbase transactions received."},
1688 "'send' category of transactions."},
1689 {
RPCResult::Type::BOOL,
"abandoned",
"'true' if the transaction has been abandoned (inputs are respendable). Only available for the \n"
1690 "'send' category of transactions."},
1694 {
RPCResult::Type::OBJ,
"decoded",
"Optional, the decoded transaction (only present when `verbose` is passed)",
1696 {
RPCResult::Type::ELISION,
"",
"Equivalent to the RPC decoderawtransaction method, or the RPC getrawtransaction method when `verbose` is passed."},
1701 HelpExampleCli(
"gettransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
1702 +
HelpExampleCli(
"gettransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\" true")
1703 +
HelpExampleCli(
"gettransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\" false true")
1704 +
HelpExampleRpc(
"gettransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
1710 const CWallet*
const pwallet = wallet.get();
1714 pwallet->BlockUntilSyncedToCurrentChain();
1726 bool verbose = request.params[2].isNull() ?
false : request.params[2].get_bool();
1729 auto it = pwallet->mapWallet.find(hash);
1730 if (
it == pwallet->mapWallet.end()) {
1737 CAmount nNet = nCredit - nDebit;
1748 entry.
pushKV(
"details", details);
1751 entry.
pushKV(
"hex", strHex);
1756 entry.
pushKV(
"decoded", decoded);
1767 "\nMark in-wallet transaction <txid> as abandoned\n"
1768 "This will mark this transaction and all its in-wallet descendants as abandoned which will allow\n"
1769 "for their inputs to be respent. It can be used to replace \"stuck\" or evicted transactions.\n"
1770 "It only works on transactions which are not included in a block and are not currently in the mempool.\n"
1771 "It has no effect on transactions which are already abandoned.\n",
1777 HelpExampleCli(
"abandontransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
1778 +
HelpExampleRpc(
"abandontransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
1784 CWallet*
const pwallet = wallet.get();
1788 pwallet->BlockUntilSyncedToCurrentChain();
1794 if (!pwallet->mapWallet.count(hash)) {
1810 "\nSafely copies current wallet file to destination, which can be a directory or a path with filename.\n",
1823 const CWallet*
const pwallet = wallet.get();
1827 pwallet->BlockUntilSyncedToCurrentChain();
1831 std::string strDest = request.params[0].get_str();
1845 "\nFills the keypool."+
1859 CWallet*
const pwallet = wallet.get();
1868 unsigned int kpSize = 0;
1869 if (!request.params[0].isNull()) {
1870 if (request.params[0].get_int() < 0)
1872 kpSize = (
unsigned int)request.params[0].
get_int();
1891 "\nStores the wallet decryption key in memory for 'timeout' seconds.\n"
1892 "This is needed prior to performing transactions related to private keys such as sending bitcoins\n"
1894 "Issuing the walletpassphrase command while the wallet is already unlocked will set a new unlock\n"
1895 "time that overrides the old one.\n",
1902 "\nUnlock the wallet for 60 seconds\n"
1904 "\nLock the wallet again (before 60 seconds)\n"
1906 "\nAs a JSON-RPC call\n"
1913 CWallet*
const pwallet = wallet.get();
1916 int64_t relock_time;
1928 strWalletPass.reserve(100);
1931 strWalletPass = request.params[0].get_str().c_str();
1934 nSleepTime = request.params[1].get_int64();
1936 if (nSleepTime < 0) {
1940 constexpr int64_t MAX_SLEEP_TIME = 100000000;
1941 if (nSleepTime > MAX_SLEEP_TIME) {
1942 nSleepTime = MAX_SLEEP_TIME;
1945 if (strWalletPass.empty()) {
1949 if (!pwallet->
Unlock(strWalletPass)) {
1955 pwallet->nRelockTime =
GetTime() + nSleepTime;
1956 relock_time = pwallet->nRelockTime;
1967 std::weak_ptr<CWallet> weak_wallet = wallet;
1969 if (
auto shared_wallet = weak_wallet.lock()) {
1970 LOCK(shared_wallet->cs_wallet);
1972 if (shared_wallet->nRelockTime != relock_time)
return;
1973 shared_wallet->Lock();
1974 shared_wallet->nRelockTime = 0;
1987 "\nChanges the wallet passphrase from 'oldpassphrase' to 'newpassphrase'.\n",
1994 HelpExampleCli(
"walletpassphrasechange",
"\"old one\" \"new one\"")
1995 +
HelpExampleRpc(
"walletpassphrasechange",
"\"old one\", \"new one\"")
2001 CWallet*
const pwallet = wallet.get();
2012 strOldWalletPass.reserve(100);
2013 strOldWalletPass = request.params[0].get_str().c_str();
2016 strNewWalletPass.reserve(100);
2017 strNewWalletPass = request.params[1].get_str().c_str();
2019 if (strOldWalletPass.empty() || strNewWalletPass.empty()) {
2036 "\nRemoves the wallet encryption key from memory, locking the wallet.\n"
2037 "After calling this method, you will need to call walletpassphrase again\n"
2038 "before being able to call any methods which require the wallet to be unlocked.\n",
2042 "\nSet the passphrase for 2 minutes to perform a transaction\n"
2044 "\nPerform a send (requires passphrase set)\n"
2046 "\nClear the passphrase since we are done before 2 minutes is up\n"
2048 "\nAs a JSON-RPC call\n"
2055 CWallet*
const pwallet = wallet.get();
2064 pwallet->nRelockTime = 0;
2075 "\nEncrypts the wallet with 'passphrase'. This is for first time encryption.\n"
2076 "After this, any calls that interact with private keys such as sending or signing \n"
2077 "will require the passphrase to be set prior the making these calls.\n"
2078 "Use the walletpassphrase call for this, and then walletlock call.\n"
2079 "If the wallet is already encrypted, use the walletpassphrasechange call.\n",
2085 "\nEncrypt your wallet\n"
2087 "\nNow set the passphrase to use the wallet, such as for signing or sending bitcoin\n"
2089 "\nNow we can do something like sign\n"
2090 +
HelpExampleCli(
"signmessage",
"\"address\" \"test message\"") +
2091 "\nNow lock the wallet again by removing the passphrase\n"
2093 "\nAs a JSON-RPC call\n"
2100 CWallet*
const pwallet = wallet.get();
2115 strWalletPass.reserve(100);
2116 strWalletPass = request.params[0].get_str().c_str();
2118 if (strWalletPass.empty()) {
2126 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.";
2134 "\nUpdates list of temporarily unspendable outputs.\n"
2135 "Temporarily lock (unlock=false) or unlock (unlock=true) specified transaction outputs.\n"
2136 "If no transaction outputs are specified when unlocking then all current locked transaction outputs are unlocked.\n"
2137 "A locked transaction output will not be chosen by automatic coin selection, when spending bitcoins.\n"
2138 "Manually selected coins are automatically unlocked.\n"
2139 "Locks are stored in memory only. Nodes start with zero locked outputs, and the locked output list\n"
2140 "is always cleared (by virtue of process exit) when a node stops or fails.\n"
2141 "Also see the listunspent call\n",
2144 {
"transactions",
RPCArg::Type::ARR,
"empty array",
"The transaction outputs and within each, the txid (string) vout (numeric).",
2159 "\nList the unspent transactions\n"
2161 "\nLock an unspent transaction\n"
2162 +
HelpExampleCli(
"lockunspent",
"false \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") +
2163 "\nList the locked transactions\n"
2165 "\nUnlock the transaction again\n"
2166 +
HelpExampleCli(
"lockunspent",
"true \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") +
2167 "\nAs a JSON-RPC call\n"
2168 +
HelpExampleRpc(
"lockunspent",
"false, \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"")
2174 CWallet*
const pwallet = wallet.get();
2178 pwallet->BlockUntilSyncedToCurrentChain();
2184 bool fUnlock = request.params[0].get_bool();
2186 if (request.params[1].isNull()) {
2194 const UniValue& output_params = request.params[1];
2198 std::vector<COutPoint> outputs;
2199 outputs.reserve(output_params.
size());
2201 for (
unsigned int idx = 0; idx < output_params.
size(); idx++) {
2218 const auto it = pwallet->mapWallet.find(outpt.
hash);
2219 if (
it == pwallet->mapWallet.end()) {
2225 if (outpt.
n >= trans.
tx->vout.size()) {
2235 if (fUnlock && !is_locked) {
2239 if (!fUnlock && is_locked) {
2243 outputs.push_back(outpt);
2247 for (
const COutPoint& outpt : outputs) {
2260 "\nReturns list of temporarily unspendable outputs.\n"
2261 "See the lockunspent call to lock and unlock transactions for spending.\n",
2274 "\nList the unspent transactions\n"
2276 "\nLock an unspent transaction\n"
2277 +
HelpExampleCli(
"lockunspent",
"false \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") +
2278 "\nList the locked transactions\n"
2280 "\nUnlock the transaction again\n"
2281 +
HelpExampleCli(
"lockunspent",
"true \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") +
2282 "\nAs a JSON-RPC call\n"
2289 const CWallet*
const pwallet = wallet.get();
2293 std::vector<COutPoint> vOutpts;
2298 for (
const COutPoint& outpt : vOutpts) {
2301 o.
pushKV(
"txid", outpt.hash.GetHex());
2302 o.
pushKV(
"vout", (
int)outpt.n);
2314 "\nSet the transaction fee per kB for this wallet. Overrides the global -paytxfee command line parameter.\n"
2315 "Can be deactivated by passing 0 as the fee. In that case automatic fee selection will be used by default.\n",
2330 CWallet*
const pwallet = wallet.get();
2335 CFeeRate tx_fee_rate(nAmount, 1000);
2339 }
else if (tx_fee_rate < pwallet->chain().relayMinFee()) {
2341 }
else if (tx_fee_rate < pwallet->m_min_fee) {
2343 }
else if (tx_fee_rate > max_tx_fee_rate) {
2357 "Returns an object with all balances in " +
CURRENCY_UNIT +
".\n",
2365 {
RPCResult::Type::STR_AMOUNT,
"untrusted_pending",
"untrusted pending balance (outputs created by others that are in the mempool)"},
2367 {
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)"},
2369 {
RPCResult::Type::OBJ,
"watchonly",
"watchonly balances (not present if wallet does not watch anything)",
2372 {
RPCResult::Type::STR_AMOUNT,
"untrusted_pending",
"untrusted pending balance (outputs created by others that are in the mempool)"},
2384 CWallet& wallet = *rpc_wallet;
2388 wallet.BlockUntilSyncedToCurrentChain();
2397 balances_mine.pushKV(
"untrusted_pending",
ValueFromAmount(bal.m_mine_untrusted_pending));
2398 balances_mine.pushKV(
"immature",
ValueFromAmount(bal.m_mine_immature));
2402 const auto full_bal = wallet.
GetBalance(0,
false);
2403 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));
2405 balances.pushKV(
"mine", balances_mine);
2408 if (spk_man && spk_man->HaveWatchOnly()) {
2410 balances_watchonly.pushKV(
"trusted",
ValueFromAmount(bal.m_watchonly_trusted));
2411 balances_watchonly.pushKV(
"untrusted_pending",
ValueFromAmount(bal.m_watchonly_untrusted_pending));
2412 balances_watchonly.pushKV(
"immature",
ValueFromAmount(bal.m_watchonly_immature));
2413 balances.pushKV(
"watchonly", balances_watchonly);
2423 "Returns an object containing various wallet state info.\n",
2437 {
RPCResult::Type::NUM,
"keypoolsize",
"how many new keys are pre-generated (only counts external keys)"},
2438 {
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)"},
2439 {
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)"},
2442 {
RPCResult::Type::BOOL,
"private_keys_enabled",
"false if privatekeys are disabled for this wallet (enforced watch-only wallet)"},
2443 {
RPCResult::Type::BOOL,
"avoid_reuse",
"whether this wallet tracks clean/dirty coins in terms of reuse"},
2444 {
RPCResult::Type::OBJ,
"scanning",
"current scanning details, or false if no scan is in progress",
2449 {
RPCResult::Type::BOOL,
"descriptors",
"whether this wallet uses descriptors for scriptPubKey management"},
2460 const CWallet*
const pwallet = wallet.get();
2464 pwallet->BlockUntilSyncedToCurrentChain();
2479 obj.
pushKV(
"txcount", (
int)pwallet->mapWallet.size());
2480 if (kp_oldest > 0) {
2481 obj.
pushKV(
"keypoololdest", kp_oldest);
2483 obj.
pushKV(
"keypoolsize", (int64_t)kpExternalSize);
2497 obj.
pushKV(
"unlocked_until", pwallet->nRelockTime);
2506 obj.
pushKV(
"scanning", scanning);
2508 obj.
pushKV(
"scanning",
false);
2519 "Returns a list of wallets in the wallet directory.\n",
2542 wallet.
pushKV(
"name", path.string());
2547 result.
pushKV(
"wallets", wallets);
2556 "Returns a list of currently loaded wallets.\n"
2557 "For full information on the wallet, use \"getwalletinfo\"\n",
2573 for (
const std::shared_ptr<CWallet>& wallet :
GetWallets()) {
2574 LOCK(wallet->cs_wallet);
2586 "\nLoads a wallet from a wallet file or directory."
2587 "\nNote that all wallet command-line options used when starting bitcoind will be"
2588 "\napplied to the new wallet (eg -rescan, etc).\n",
2591 {
"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."},
2607 const std::string
name(request.params[0].get_str());
2613 std::vector<bilingual_str> warnings;
2615 std::shared_ptr<CWallet>
const wallet =
LoadWallet(*context.
chain,
name, load_on_start, options, status, error, warnings);
2624 obj.
pushKV(
"name", wallet->GetName());
2634 std::string
flags =
"";
2637 flags += (flags ==
"" ?
"" :
", ") +
it.first;
2640 "\nChange the state of the given wallet flag for a wallet.\n",
2661 CWallet*
const pwallet = wallet.get();
2663 std::string flag_str = request.params[0].get_str();
2664 bool value = request.params[1].isNull() || request.params[1].get_bool();
2682 res.pushKV(
"flag_name", flag_str);
2683 res.pushKV(
"flag_state", value);
2704 "\nCreates and loads a new wallet.\n",
2707 {
"disable_private_keys",
RPCArg::Type::BOOL,
"false",
"Disable the possibility of private keys (only watchonlys are possible in this mode)."},
2708 {
"blank",
RPCArg::Type::BOOL,
"false",
"Create a blank wallet. A blank wallet has no keys or HD seed. One can be set using sethdseed."},
2710 {
"avoid_reuse",
RPCArg::Type::BOOL,
"false",
"Keep track of coin reuse, and treat dirty and clean coins differently with privacy considerations in mind."},
2711 {
"descriptors",
RPCArg::Type::BOOL,
"false",
"Create a native descriptor wallet. The wallet will use descriptors internally to handle address creation"},
2712 {
"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."},
2717 {
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."},
2729 if (!request.params[1].isNull() && request.params[1].get_bool()) {
2733 if (!request.params[2].isNull() && request.params[2].get_bool()) {
2737 passphrase.reserve(100);
2738 std::vector<bilingual_str> warnings;
2739 if (!request.params[3].isNull()) {
2740 passphrase = request.params[3].get_str().c_str();
2741 if (passphrase.empty()) {
2743 warnings.emplace_back(
Untranslated(
"Empty string given as passphrase, wallet will not be encrypted."));
2747 if (!request.params[4].isNull() && request.params[4].get_bool()) {
2750 if (!request.params[5].isNull() && request.params[5].get_bool()) {
2755 warnings.emplace_back(
Untranslated(
"Wallet is an experimental descriptor wallet"));
2765 std::shared_ptr<CWallet> wallet =
CreateWallet(*context.
chain, request.params[0].get_str(), load_on_start, options, status,
error, warnings);
2772 obj.
pushKV(
"name", wallet->GetName());
2783 "Unloads the wallet referenced by the request endpoint otherwise unloads the wallet specified in the argument.\n"
2784 "Specifying the wallet name on a wallet endpoint is invalid.",
2786 {
"wallet_name",
RPCArg::Type::STR,
"the wallet name from the RPC endpoint",
"The name of the wallet to unload. Must be provided in the RPC endpoint or this parameter (but not both)."},
2787 {
"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."},
2798 std::string wallet_name;
2800 if (!request.params[0].isNull()) {
2804 wallet_name = request.params[0].get_str();
2807 std::shared_ptr<CWallet> wallet =
GetWallet(wallet_name);
2815 std::vector<bilingual_str> warnings;
2834 "\nReturns array of unspent transaction outputs\n"
2835 "with between minconf and maxconf (inclusive) confirmations.\n"
2836 "Optionally filter to only include txouts paid to specified addresses.\n",
2839 {
"maxconf",
RPCArg::Type::NUM,
"9999999",
"The maximum confirmations to filter"},
2840 {
"addresses",
RPCArg::Type::ARR,
"empty array",
"The bitcoin addresses to filter",
2845 {
"include_unsafe",
RPCArg::Type::BOOL,
"true",
"Include outputs that are not safe to spend\n"
2846 "See description of \"safe\" attribute below."},
2869 {
RPCResult::Type::STR,
"witnessScript",
"witnessScript if the scriptPubKey is P2WSH or P2SH-P2WSH"},
2871 {
RPCResult::Type::BOOL,
"solvable",
"Whether we know how to spend this output, ignoring the lack of keys"},
2872 {
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)"},
2874 {
RPCResult::Type::BOOL,
"safe",
"Whether this output is considered safe to spend. Unconfirmed transactions\n"
2875 "from outside keys and unconfirmed replacement transactions are considered unsafe\n"
2876 "and are not eligible for spending by fundrawtransaction and sendtoaddress."},
2884 +
HelpExampleCli(
"listunspent",
"6 9999999 '[]' true '{ \"minimumAmount\": 0.005 }'")
2885 +
HelpExampleRpc(
"listunspent",
"6, 9999999, [] , true, { \"minimumAmount\": 0.005 } ")
2891 const CWallet*
const pwallet = wallet.get();
2894 if (!request.params[0].isNull()) {
2896 nMinDepth = request.params[0].get_int();
2899 int nMaxDepth = 9999999;
2900 if (!request.params[1].isNull()) {
2902 nMaxDepth = request.params[1].get_int();
2905 std::set<CTxDestination> destinations;
2906 if (!request.params[2].isNull()) {
2909 for (
unsigned int idx = 0; idx < inputs.
size(); idx++) {
2910 const UniValue& input = inputs[idx];
2915 if (!destinations.insert(dest).second) {
2921 bool include_unsafe =
true;
2922 if (!request.params[3].isNull()) {
2924 include_unsafe = request.params[3].get_bool();
2930 uint64_t nMaximumCount = 0;
2932 if (!request.params[4].isNull()) {
2944 if (options.
exists(
"minimumAmount"))
2947 if (options.
exists(
"maximumAmount"))
2950 if (options.
exists(
"minimumSumAmount"))
2953 if (options.
exists(
"maximumCount"))
2954 nMaximumCount = options[
"maximumCount"].get_int64();
2959 pwallet->BlockUntilSyncedToCurrentChain();
2962 std::vector<COutput> vecOutputs;
2969 pwallet->
AvailableCoins(vecOutputs, !include_unsafe, &cctl, nMinimumAmount, nMaximumAmount, nMinimumSumAmount, nMaximumCount);
2976 for (
const COutput& out : vecOutputs) {
2978 const CScript& scriptPubKey = out.tx->tx->vout[out.i].scriptPubKey;
2980 bool reused = avoid_reuse && pwallet->
IsSpentKey(out.tx->GetHash(), out.i);
2982 if (destinations.size() && (!fValidAddress || !destinations.count(address)))
2986 entry.
pushKV(
"txid", out.tx->GetHash().GetHex());
2987 entry.
pushKV(
"vout", out.i);
2989 if (fValidAddress) {
2993 if (address_book_entry) {
2994 entry.
pushKV(
"label", address_book_entry->GetLabel());
2997 std::unique_ptr<SigningProvider> provider = pwallet->
GetSolvingProvider(scriptPubKey);
3002 if (provider->GetCScript(hash, redeemScript)) {
3014 if (provider->GetCScript(
id, witnessScript)) {
3024 if (provider->GetCScript(
id, witnessScript)) {
3033 entry.
pushKV(
"confirmations", out.nDepth);
3034 entry.
pushKV(
"spendable", out.fSpendable);
3035 entry.
pushKV(
"solvable", out.fSolvable);
3036 if (out.fSolvable) {
3037 std::unique_ptr<SigningProvider> provider = pwallet->
GetSolvingProvider(scriptPubKey);
3040 entry.
pushKV(
"desc", descriptor->ToString());
3043 if (avoid_reuse) entry.
pushKV(
"reused", reused);
3044 entry.
pushKV(
"safe", out.fSafe);
3057 pwallet->BlockUntilSyncedToCurrentChain();
3059 change_position = -1;
3060 bool lockUnspents =
false;
3062 std::set<int> setSubtractFeeFromOutputs;
3097 if (options.
exists(
"add_inputs") ) {
3101 if (options.
exists(
"changeAddress") || options.
exists(
"change_address")) {
3102 const std::string change_address_str = (options.
exists(
"change_address") ? options[
"change_address"] : options[
"changeAddress"]).get_str();
3112 if (options.
exists(
"changePosition") || options.
exists(
"change_position")) {
3113 change_position = (options.
exists(
"change_position") ? options[
"change_position"] : options[
"changePosition"]).get_int();
3116 if (options.
exists(
"change_type")) {
3117 if (options.
exists(
"changeAddress") || options.
exists(
"change_address")) {
3127 const UniValue include_watching_option = options.
exists(
"include_watching") ? options[
"include_watching"] : options[
"includeWatching"];
3130 if (options.
exists(
"lockUnspents") || options.
exists(
"lock_unspents")) {
3131 lockUnspents = (options.
exists(
"lock_unspents") ? options[
"lock_unspents"] : options[
"lockUnspents"]).get_bool();
3134 if (options.
exists(
"feeRate")) {
3135 if (options.
exists(
"fee_rate")) {
3138 if (options.
exists(
"conf_target")) {
3139 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.");
3141 if (options.
exists(
"estimate_mode")) {
3148 if (options.
exists(
"subtractFeeFromOutputs") || options.
exists(
"subtract_fee_from_outputs") )
3149 subtractFeeFromOutputs = (options.
exists(
"subtract_fee_from_outputs") ? options[
"subtract_fee_from_outputs"] : options[
"subtractFeeFromOutputs"]).get_array();
3151 if (options.
exists(
"replaceable")) {
3154 SetFeeEstimateMode(*pwallet, coinControl, options[
"conf_target"], options[
"estimate_mode"], options[
"fee_rate"], override_min_fee);
3161 if (tx.
vout.size() == 0)
3164 if (change_position != -1 && (change_position < 0 || (
unsigned int)change_position > tx.
vout.size()))
3167 for (
unsigned int idx = 0; idx < subtractFeeFromOutputs.
size(); idx++) {
3168 int pos = subtractFeeFromOutputs[idx].
get_int();
3169 if (setSubtractFeeFromOutputs.count(pos))
3173 if (pos >=
int(tx.
vout.size()))
3175 setSubtractFeeFromOutputs.insert(pos);
3180 if (!pwallet->
FundTransaction(tx, fee_out, change_position, error, lockUnspents, setSubtractFeeFromOutputs, coinControl)) {
3188 "\nIf the transaction has no inputs, they will be automatically selected to meet its out value.\n"
3189 "It will add at most one change output to the outputs.\n"
3190 "No existing outputs will be modified unless \"subtractFeeFromOutputs\" is specified.\n"
3191 "Note that inputs which were signed may need to be resigned after completion since in/outputs have been added.\n"
3192 "The inputs added will not be signed, use signrawtransactionwithkey\n"
3193 " or signrawtransactionwithwallet for that.\n"
3194 "Note that all existing inputs must have their previous output transaction be in the wallet.\n"
3195 "Note that all inputs selected must be of standard form and P2SH scripts must be\n"
3196 "in the wallet using importaddress or addmultisigaddress (to calculate fees).\n"
3197 "You can see whether this is the case by checking the \"solvable\" field in the listunspent output.\n"
3198 "Only pay-to-pubkey, multisig, and P2SH versions thereof are currently supported for watch-only\n",
3203 {
"add_inputs",
RPCArg::Type::BOOL,
"true",
"For a transaction with existing inputs, automatically include more if they are not enough."},
3204 {
"changeAddress",
RPCArg::Type::STR,
"pool address",
"The bitcoin address to receive the change"},
3205 {
"changePosition",
RPCArg::Type::NUM,
"random",
"The index of the change output"},
3206 {
"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\"."},
3207 {
"includeWatching",
RPCArg::Type::BOOL,
"true for watch-only wallets, otherwise false",
"Also select inputs which are watch only.\n"
3208 "Only solvable inputs can be used. Watch-only destinations are solvable if the public key and/or output script was imported,\n"
3209 "e.g. with 'importpubkey' or 'importmulti' with the 'pubkeys' or 'desc' field."},
3214 "The fee will be equally deducted from the amount of each specified output.\n"
3215 "Those recipients will receive less bitcoins than you enter in their corresponding amount field.\n"
3216 "If no outputs are specified here, the sender pays the fee.",
3221 {
"replaceable",
RPCArg::Type::BOOL,
"wallet default",
"Marks this transaction as BIP125 replaceable.\n"
3222 "Allows this transaction to be replaced by a transaction with higher fees"},
3223 {
"conf_target",
RPCArg::Type::NUM,
"wallet -txconfirmtarget",
"Confirmation target in blocks"},
3224 {
"estimate_mode",
RPCArg::Type::STR,
"unset", std::string() +
"The fee estimate mode, must be one of (case insensitive):\n"
3225 " \"" +
FeeModes(
"\"\n\"") +
"\""},
3228 {
"iswitness",
RPCArg::Type::BOOL,
"depends on heuristic tests",
"Whether the transaction hex is a serialized witness transaction.\n"
3229 "If iswitness is not present, heuristic tests will be used in decoding.\n"
3230 "If true, only witness deserialization will be tried.\n"
3231 "If false, only non-witness deserialization will be tried.\n"
3232 "This boolean should reflect whether the transaction has inputs\n"
3233 "(e.g. fully valid, or on-chain transactions), if known by the caller."
3245 "\nCreate a transaction with no inputs\n"
3246 +
HelpExampleCli(
"createrawtransaction",
"\"[]\" \"{\\\"myaddress\\\":0.01}\"") +
3247 "\nAdd sufficient unsigned inputs to meet the output value\n"
3248 +
HelpExampleCli(
"fundrawtransaction",
"\"rawtransactionhex\"") +
3249 "\nSign the transaction\n"
3250 +
HelpExampleCli(
"signrawtransactionwithwallet",
"\"fundedtransactionhex\"") +
3251 "\nSend the transaction\n"
3252 +
HelpExampleCli(
"sendrawtransaction",
"\"signedtransactionhex\"")
3258 CWallet*
const pwallet = wallet.get();
3260 RPCTypeCheck(request.params, {UniValue::VSTR, UniValueType(), UniValue::VBOOL});
3264 bool try_witness = request.params[2].isNull() ?
true : request.params[2].get_bool();
3265 bool try_no_witness = request.params[2].isNull() ?
true : !request.params[2].get_bool();
3266 if (!
DecodeHexTx(tx, request.params[0].get_str(), try_no_witness, try_witness)) {
3271 int change_position;
3275 FundTransaction(pwallet, tx, fee, change_position, request.params[1], coin_control,
true);
3280 result.
pushKV(
"changepos", change_position);
3289 return RPCHelpMan{
"signrawtransactionwithwallet",
3290 "\nSign inputs for raw transaction (serialized, hex-encoded).\n"
3291 "The second optional argument (may be null) is an array of previous transaction outputs that\n"
3292 "this transaction depends on but may not yet be in the block chain." +
3310 {
"sighashtype",
RPCArg::Type::STR,
"ALL",
"The signature hash type. Must be one of\n"
3314 " \"ALL|ANYONECANPAY\"\n"
3315 " \"NONE|ANYONECANPAY\"\n"
3316 " \"SINGLE|ANYONECANPAY\""},
3344 const CWallet*
const pwallet = wallet.get();
3346 RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VARR, UniValue::VSTR},
true);
3349 if (!
DecodeHexTx(mtx, request.params[0].get_str())) {
3358 std::map<COutPoint, Coin> coins;
3359 for (
const CTxIn& txin : mtx.
vin) {
3370 std::map<int, std::string> input_errors;
3372 bool complete = pwallet->
SignTransaction(mtx, coins, nHashType, input_errors);
3382 bool want_psbt = method_name ==
"psbtbumpfee";
3386 "\nBumps the fee of an opt-in-RBF transaction T, replacing it with a new transaction B.\n"
3387 + std::string(want_psbt ?
"Returns a PSBT instead of creating and signing a new transaction.\n" :
"") +
3388 "An opt-in RBF transaction with the given txid must be in the wallet.\n"
3389 "The command will pay the additional fee by reducing change outputs or adding inputs when necessary.\n"
3390 "It may add a new change output if one does not already exist.\n"
3391 "All inputs in the original transaction will be included in the replacement transaction.\n"
3392 "The command will fail if the wallet or mempool contains a transaction that spends one of T's outputs.\n"
3393 "By default, the new fee will be calculated automatically using the estimatesmartfee RPC.\n"
3394 "The user can specify a confirmation target for estimatesmartfee.\n"
3395 "Alternatively, the user can specify a fee rate in " +
CURRENCY_ATOM +
"/vB for the new transaction.\n"
3396 "At a minimum, the new fee rate must be high enough to pay an additional new relay fee (incrementalfee\n"
3397 "returned by getnetworkinfo) to enter the node's mempool.\n"
3398 "* WARNING: before version 0.21, fee_rate was in " +
CURRENCY_UNIT +
"/kvB. As of 0.21, fee_rate is in " +
CURRENCY_ATOM +
"/vB. *\n",
3403 {
"conf_target",
RPCArg::Type::NUM,
"wallet -txconfirmtarget",
"Confirmation target in blocks\n"},
3405 "\nSpecify a fee rate in " + CURRENCY_ATOM +
"/vB instead of relying on the built-in fee estimator.\n"
3406 "Must be at least " + incremental_fee +
" higher than the current transaction fee rate.\n"
3407 "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 {
"replaceable",
RPCArg::Type::BOOL,
"true",
"Whether the new transaction should still be\n"
3409 "marked bip-125 replaceable. If true, the sequence numbers in the transaction will\n"
3410 "be left unchanged from the original. If false, any input sequence numbers in the\n"
3411 "original transaction that were less than 0xfffffffe will be increased to 0xfffffffe\n"
3412 "so the new transaction will not be explicitly bip-125 replaceable (though it may\n"
3413 "still be replaceable in practice, for example if it has unconfirmed ancestors which\n"
3414 "are replaceable).\n"},
3415 {
"estimate_mode",
RPCArg::Type::STR,
"unset", std::string() +
"The fee estimate mode, must be one of (case insensitive):\n"
3416 " \"" +
FeeModes(
"\"\n\"") +
"\""},
3423 {
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)")},
3425 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."}}
3437 "\nBump the fee, get the new transaction\'s" + std::string(want_psbt ?
"psbt" :
"txid") +
"\n" +
3444 CWallet*
const pwallet = wallet.get();
3448 throw JSONRPCError(
RPC_METHOD_DEPRECATED,
"Using bumpfee with wallets that have private keys disabled is deprecated. Use psbtbumpfee instead or restart bitcoind with -deprecatedrpc=bumpfee. This functionality will be removed in 0.22");
3453 RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VOBJ});
3461 if (!request.params[1].isNull()) {
3462 UniValue options = request.params[1];
3473 if (options.
exists(
"confTarget") && options.
exists(
"conf_target")) {
3477 auto conf_target = options.
exists(
"confTarget") ? options[
"confTarget"] : options[
"conf_target"];
3479 if (options.
exists(
"replaceable")) {
3482 SetFeeEstimateMode(*pwallet, coin_control, conf_target, options[
"estimate_mode"], options[
"fee_rate"],
false);
3487 pwallet->BlockUntilSyncedToCurrentChain();
3493 std::vector<bilingual_str> errors;
3537 bool complete =
false;
3552 result.
pushKV(
"errors", result_errors);
3565 "\nRescan the local blockchain for wallet related transactions.\n"
3566 "Note: Use \"getwalletinfo\" to query the scanning progress.\n",
3568 {
"start_height",
RPCArg::Type::NUM,
"0",
"block height where the rescan should start"},
3574 {
RPCResult::Type::NUM,
"start_height",
"The block height where the rescan started (the requested height or 0)"},
3575 {
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."},
3586 CWallet*
const pwallet = wallet.get();
3593 int start_height = 0;
3600 if (!request.params[0].isNull()) {
3601 start_height = request.params[0].get_int();
3602 if (start_height < 0 || start_height > tip_height) {
3607 if (!request.params[1].isNull()) {
3608 stop_height = request.params[1].get_int();
3609 if (*stop_height < 0 || *stop_height > tip_height) {
3611 }
else if (*stop_height < start_height) {
3618 throw JSONRPCError(
RPC_MISC_ERROR,
"Can't rescan beyond pruned data. Use RPC call getblockchaininfo to determine your pruned height.");
3636 response.
pushKV(
"start_height", start_height);
3651 std::vector<std::vector<unsigned char>> solutions_data;
3662 UniValue wallet_detail = boost::apply_visitor(*
this, embedded);
3663 subobj.
pushKVs(wallet_detail);
3667 if (subobj.
exists(
"pubkey")) obj.
pushKV(
"pubkey", subobj[
"pubkey"]);
3668 obj.
pushKV(
"embedded", std::move(subobj));
3672 obj.
pushKV(
"sigsrequired", solutions_data[0][0]);
3674 for (
size_t i = 1; i < solutions_data.size() - 1; ++i) {
3675 CPubKey key(solutions_data[i].begin(), solutions_data[i].end());
3678 obj.
pushKV(
"pubkeys", std::move(pubkeys));
3691 if (provider && provider->
GetPubKey(keyID, vchPubKey)) {
3693 obj.
pushKV(
"iscompressed", vchPubKey.IsCompressed());
3703 if (provider && provider->
GetCScript(scriptID, subscript)) {
3740 std::unique_ptr<SigningProvider> provider =
nullptr;
3763 "\nReturn information about the given bitcoin address.\n"
3764 "Some of the information will only be present if the address is in the active wallet.\n",
3775 {
RPCResult::Type::BOOL,
"solvable",
"If we know how to spend coins sent to this address, ignoring the possible lack of private keys."},
3776 {
RPCResult::Type::STR,
"desc",
true,
"A descriptor for spending coins sent to this address (only when solvable)."},
3782 {
RPCResult::Type::STR,
"script",
true,
"The output script type. Only if isscript is true and the redeemscript is known. Possible\n"
3783 "types: nonstandard, pubkey, pubkeyhash, scripthash, multisig, nulldata, witness_v0_keyhash,\n"
3784 "witness_v0_scripthash, witness_unknown."},
3786 {
RPCResult::Type::ARR,
"pubkeys",
true,
"Array of pubkeys associated with the known redeemscript (only if script is multisig).",
3790 {
RPCResult::Type::NUM,
"sigsrequired",
true,
"The number of signatures required to spend multisig output (only if script is multisig)."},
3791 {
RPCResult::Type::STR_HEX,
"pubkey",
true,
"The hex value of the raw public key for single-key addresses (possibly embedded in P2SH or P2WSH)."},
3792 {
RPCResult::Type::OBJ,
"embedded",
true,
"Information about the address embedded in P2SH or P2WSH, if relevant and known.",
3794 {
RPCResult::Type::ELISION,
"",
"Includes all getaddressinfo output fields for the embedded address, excluding metadata (timestamp, hdkeypath, hdseedid)\n"
3795 "and relation to the wallet (ismine, iswatchonly)."},
3802 {
RPCResult::Type::ARR,
"labels",
"Array of labels associated with the address. Currently limited to one label but returned\n"
3803 "as an array to keep the API stable if multiple labels are enabled in the future.",
3817 const CWallet*
const pwallet = wallet.get();
3829 ret.
pushKV(
"address", currentAddress);
3834 std::unique_ptr<SigningProvider> provider = pwallet->
GetSolvingProvider(scriptPubKey);
3839 bool solvable = provider &&
IsSolvable(*provider, scriptPubKey);
3840 ret.
pushKV(
"solvable", solvable);
3855 if (
const std::unique_ptr<CKeyMetadata> meta = spk_man->
GetMetadata(dest)) {
3856 ret.
pushKV(
"timestamp", meta->nCreateTime);
3857 if (meta->has_key_origin) {
3859 ret.
pushKV(
"hdseedid", meta->hd_seed_id.GetHex());
3860 ret.
pushKV(
"hdmasterfingerprint",
HexStr(meta->key_origin.fingerprint));
3872 if (address_book_entry) {
3873 labels.
push_back(address_book_entry->GetLabel());
3875 ret.
pushKV(
"labels", std::move(labels));
3885 "\nReturns the list of addresses assigned the specified label.\n",
3894 {
RPCResult::Type::STR,
"purpose",
"Purpose of address (\"send\" for sending address, \"receive\" for receiving address)"},
3906 const CWallet*
const pwallet = wallet.get();
3914 std::set<std::string> addresses;
3915 for (
const std::pair<const CTxDestination, CAddressBookData>& item : pwallet->m_address_book) {
3916 if (item.second.IsChange())
continue;
3917 if (item.second.GetLabel() == label) {
3922 bool unique = addresses.emplace(address).second;
3944 "\nReturns the list of all labels, or labels that are assigned to addresses with a specific purpose.\n",
3955 "\nList all labels\n"
3957 "\nList labels that have receiving addresses\n"
3959 "\nList labels that have sending addresses\n"
3961 "\nAs a JSON-RPC call\n"
3968 const CWallet*
const pwallet = wallet.get();
3972 std::string purpose;
3973 if (!request.params[0].isNull()) {
3974 purpose = request.params[0].get_str();
3978 std::set<std::string> label_set;
3979 for (
const std::pair<const CTxDestination, CAddressBookData>& entry : pwallet->m_address_book) {
3980 if (entry.second.IsChange())
continue;
3981 if (purpose.empty() || entry.second.purpose == purpose) {
3982 label_set.insert(entry.second.GetLabel());
3987 for (
const std::string&
name : label_set) {
3999 "\nEXPERIMENTAL warning: this call may be changed in future releases.\n"
4000 "\nSend a transaction.\n",
4003 "That is, each address can only appear once and there can only be one 'data' object.\n"
4004 "For convenience, a dictionary, which holds the key-value pairs directly, is also accepted.",
4018 {
"conf_target",
RPCArg::Type::NUM,
"wallet -txconfirmtarget",
"Confirmation target in blocks"},
4019 {
"estimate_mode",
RPCArg::Type::STR,
"unset", std::string() +
"The fee estimate mode, must be one of (case insensitive):\n"
4020 " \"" +
FeeModes(
"\"\n\"") +
"\""},
4024 {
"add_inputs",
RPCArg::Type::BOOL,
"false",
"If inputs are specified, automatically include more if they are not enough."},
4025 {
"add_to_wallet",
RPCArg::Type::BOOL,
"true",
"When false, returns a serialized transaction which will not be added to the wallet or broadcast"},
4026 {
"change_address",
RPCArg::Type::STR_HEX,
"pool address",
"The bitcoin address to receive the change"},
4027 {
"change_position",
RPCArg::Type::NUM,
"random",
"The index of the change output"},
4028 {
"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\"."},
4029 {
"conf_target",
RPCArg::Type::NUM,
"wallet -txconfirmtarget",
"Confirmation target in blocks"},
4030 {
"estimate_mode",
RPCArg::Type::STR,
"unset", std::string() +
"The fee estimate mode, must be one of (case insensitive):\n"
4031 " \"" +
FeeModes(
"\"\n\"") +
"\""},
4033 {
"include_watching",
RPCArg::Type::BOOL,
"true for watch-only wallets, otherwise false",
"Also select inputs which are watch only.\n"
4034 "Only solvable inputs can be used. Watch-only destinations are solvable if the public key and/or output script was imported,\n"
4035 "e.g. with 'importpubkey' or 'importmulti' with the 'pubkeys' or 'desc' field."},
4036 {
"inputs",
RPCArg::Type::ARR,
"empty array",
"Specify inputs instead of adding them automatically. A JSON array of JSON objects",
4043 {
"locktime",
RPCArg::Type::NUM,
"0",
"Raw locktime. Non-0 value also locktime-activates inputs"},
4045 {
"psbt",
RPCArg::Type::BOOL,
"automatic",
"Always return a PSBT, implies add_to_wallet=false."},
4046 {
"subtract_fee_from_outputs",
RPCArg::Type::ARR,
"empty array",
"Outputs to subtract the fee from, specified as integer indices.\n"
4047 "The fee will be equally deducted from the amount of each specified output.\n"
4048 "Those recipients will receive less bitcoins than you enter in their corresponding amount field.\n"
4049 "If no outputs are specified here, the sender pays the fee.",
4054 {
"replaceable",
RPCArg::Type::BOOL,
"wallet default",
"Marks this transaction as BIP125 replaceable.\n"
4055 "Allows this transaction to be replaced by a transaction with higher fees"},
4063 {
RPCResult::Type::STR_HEX,
"txid",
"The transaction id for the send. Only 1 transaction is created regardless of the number of addresses."},
4065 {
RPCResult::Type::STR,
"psbt",
"If more signatures are needed, or if add_to_wallet is false, the base64-encoded (partially) signed transaction"}
4069 "\nSend 0.1 BTC with a confirmation target of 6 blocks in economical fee estimate mode\n"
4071 "Send 0.2 BTC with a fee rate of 1.1 " +
CURRENCY_ATOM +
"/vB using positional arguments\n"
4073 "Send 0.2 BTC with a fee rate of 1 " +
CURRENCY_ATOM +
"/vB using the options argument\n"
4075 "Send 0.3 BTC with a fee rate of 25 " +
CURRENCY_ATOM +
"/vB using named arguments\n"
4077 "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"
4078 +
HelpExampleCli(
"send",
"'{\"" +
EXAMPLE_ADDRESS[0] +
"\": 0.1}' 1 economical '{\"add_to_wallet\": false, \"inputs\": [{\"txid\":\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\", \"vout\":1}]}'")
4093 CWallet*
const pwallet = wallet.get();
4096 if (options.exists(
"conf_target") || options.exists(
"estimate_mode")) {
4097 if (!request.params[1].isNull() || !request.params[2].isNull()) {
4101 options.pushKV(
"conf_target", request.params[1]);
4102 options.pushKV(
"estimate_mode", request.params[2]);
4104 if (options.exists(
"fee_rate")) {
4105 if (!request.params[3].isNull()) {
4109 options.pushKV(
"fee_rate", request.params[3]);
4111 if (!options[
"conf_target"].isNull() && (options[
"estimate_mode"].isNull() || (options[
"estimate_mode"].get_str() ==
"unset"))) {
4114 if (options.exists(
"feeRate")) {
4117 if (options.exists(
"changeAddress")) {
4120 if (options.exists(
"changePosition")) {
4123 if (options.exists(
"includeWatching")) {
4126 if (options.exists(
"lockUnspents")) {
4129 if (options.exists(
"subtractFeeFromOutputs")) {
4133 const bool psbt_opt_in = options.exists(
"psbt") && options[
"psbt"].get_bool();
4136 int change_position;
4138 if (options.exists(
"replaceable")) {
4139 rbf = options[
"replaceable"].get_bool();
4146 FundTransaction(pwallet, rawTx, fee, change_position, options, coin_control,
false);
4148 bool add_to_wallet =
true;
4149 if (options.exists(
"add_to_wallet")) {
4150 add_to_wallet = options[
"add_to_wallet"].get_bool();
4157 bool complete =
true;
4168 if (psbt_opt_in || !complete || !add_to_wallet) {
4176 std::string err_string;
4179 result.
pushKV(
"txid", tx->GetHash().GetHex());
4180 if (add_to_wallet && !psbt_opt_in) {
4183 result.
pushKV(
"hex", hex);
4186 result.
pushKV(
"complete", complete);
4196 "\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"
4197 "HD will have a new HD seed set so that new keys added to the keypool will be derived from this new seed.\n"
4198 "\nNote that you will need to MAKE A NEW BACKUP of your wallet after setting the HD wallet seed." +
4201 {
"newkeypool",
RPCArg::Type::BOOL,
"true",
"Whether to flush old unused addresses, including change addresses, from the keypool and regenerate it.\n"
4202 "If true, the next address from getnewaddress and change address from getrawchangeaddress will be from this new seed.\n"
4203 "If false, addresses (including change addresses if the wallet already had HD Chain Split enabled) from the existing\n"
4204 "keypool will be used until it has been depleted."},
4205 {
"seed",
RPCArg::Type::STR,
"random seed",
"The WIF private key to use as the new HD seed.\n"
4206 "The seed value can be retrieved using the dumpwallet command. It is the private key marked hdseed=1"},
4219 CWallet*
const pwallet = wallet.get();
4231 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");
4236 bool flush_key_pool =
true;
4237 if (!request.params[0].isNull()) {
4238 flush_key_pool = request.params[0].get_bool();
4242 if (request.params[1].isNull()) {
4246 if (!key.IsValid()) {
4268 "\nUpdate a PSBT with input information from our wallet and then sign inputs\n"
4269 "that we can sign for." +
4274 {
"sighashtype",
RPCArg::Type::STR,
"ALL",
"The signature hash type to sign with if not specified by the PSBT. Must be one of\n"
4278 " \"ALL|ANYONECANPAY\"\n"
4279 " \"NONE|ANYONECANPAY\"\n"
4280 " \"SINGLE|ANYONECANPAY\""},
4281 {
"bip32derivs",
RPCArg::Type::BOOL,
"true",
"Include BIP 32 derivation paths for public keys if we know them"},
4297 const CWallet*
const pwallet = wallet.get();
4299 RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL, UniValue::VSTR});
4312 bool sign = request.params[1].isNull() ?
true : request.params[1].get_bool();
4313 bool bip32derivs = request.params[3].isNull() ?
true : request.params[3].get_bool();
4314 bool complete =
true;
4324 result.
pushKV(
"complete", complete);
4334 "\nCreates and funds a transaction in the Partially Signed Transaction format.\n"
4335 "Implements the Creator and Updater roles.\n",
4343 {
"sequence",
RPCArg::Type::NUM,
"depends on the value of the 'locktime' and 'options.replaceable' arguments",
"The sequence number"},
4349 "That is, each address can only appear once and there can only be one 'data' object.\n"
4350 "For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also\n"
4351 "accepted as second parameter.",
4365 {
"locktime",
RPCArg::Type::NUM,
"0",
"Raw locktime. Non-0 value also locktime-activates inputs"},
4368 {
"add_inputs",
RPCArg::Type::BOOL,
"false",
"If inputs are specified, automatically include more if they are not enough."},
4369 {
"changeAddress",
RPCArg::Type::STR_HEX,
"pool address",
"The bitcoin address to receive the change"},
4370 {
"changePosition",
RPCArg::Type::NUM,
"random",
"The index of the change output"},
4371 {
"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\"."},
4372 {
"includeWatching",
RPCArg::Type::BOOL,
"true for watch-only wallets, otherwise false",
"Also select inputs which are watch only"},
4376 {
"subtractFeeFromOutputs",
RPCArg::Type::ARR,
"empty array",
"The outputs to subtract the fee from.\n"
4377 "The fee will be equally deducted from the amount of each specified output.\n"
4378 "Those recipients will receive less bitcoins than you enter in their corresponding amount field.\n"
4379 "If no outputs are specified here, the sender pays the fee.",
4384 {
"replaceable",
RPCArg::Type::BOOL,
"wallet default",
"Marks this transaction as BIP125 replaceable.\n"
4385 "Allows this transaction to be replaced by a transaction with higher fees"},
4386 {
"conf_target",
RPCArg::Type::NUM,
"wallet -txconfirmtarget",
"Confirmation target in blocks"},
4387 {
"estimate_mode",
RPCArg::Type::STR,
"unset", std::string() +
"The fee estimate mode, must be one of (case insensitive):\n"
4388 " \"" +
FeeModes(
"\"\n\"") +
"\""},
4391 {
"bip32derivs",
RPCArg::Type::BOOL,
"true",
"Include BIP 32 derivation paths for public keys if we know them"},
4402 "\nCreate a transaction with no inputs\n"
4403 +
HelpExampleCli(
"walletcreatefundedpsbt",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
4409 CWallet*
const pwallet = wallet.get();
4421 int change_position;
4423 const UniValue &replaceable_arg = request.params[3][
"replaceable"];
4424 if (!replaceable_arg.
isNull()) {
4426 rbf = replaceable_arg.
isTrue();
4433 FundTransaction(pwallet, rawTx, fee, change_position, request.params[3], coin_control,
true);
4439 bool bip32derivs = request.params[4].isNull() ?
true : request.params[4].get_bool();
4440 bool complete =
true;
4453 result.
pushKV(
"changepos", change_position);
4462 "\nUpgrade the wallet. Upgrades to the latest version if no version number is specified.\n"
4463 "New keys may be generated and a new wallet backup will need to be made.",
4485 CWallet*
const pwallet = wallet.get();
4492 if (!request.params[0].isNull()) {
4493 version = request.params[0].get_int();
4496 const int previous_version{pwallet->
GetVersion()};
4497 const bool wallet_upgraded{pwallet->
UpgradeWallet(version, error)};
4498 const int current_version{pwallet->
GetVersion()};
4501 if (wallet_upgraded) {
4502 if (previous_version == current_version) {
4503 result =
"Already at latest version. Wallet version unchanged.";
4505 result =
strprintf(
"Wallet upgraded successfully from version %i to version %i.", previous_version, current_version);
4511 obj.
pushKV(
"previous_version", previous_version);
4512 obj.
pushKV(
"current_version", current_version);
4513 if (!result.empty()) {
4514 obj.
pushKV(
"result", result);
4542 {
"rawtransactions",
"fundrawtransaction", &
fundrawtransaction, {
"hexstring",
"options",
"iswitness"} },
4545 {
"wallet",
"addmultisigaddress", &
addmultisigaddress, {
"nrequired",
"keys",
"label",
"address_type"} },
4546 {
"wallet",
"backupwallet", &
backupwallet, {
"destination"} },
4547 {
"wallet",
"bumpfee", &
bumpfee, {
"txid",
"options"} },
4548 {
"wallet",
"psbtbumpfee", &
psbtbumpfee, {
"txid",
"options"} },
4549 {
"wallet",
"createwallet", &
createwallet, {
"wallet_name",
"disable_private_keys",
"blank",
"passphrase",
"avoid_reuse",
"descriptors",
"load_on_startup"} },
4550 {
"wallet",
"dumpprivkey", &
dumpprivkey, {
"address"} },
4551 {
"wallet",
"dumpwallet", &
dumpwallet, {
"filename"} },
4552 {
"wallet",
"encryptwallet", &
encryptwallet, {
"passphrase"} },
4555 {
"wallet",
"getbalance", &
getbalance, {
"dummy",
"minconf",
"include_watchonly",
"avoid_reuse"} },
4556 {
"wallet",
"getnewaddress", &
getnewaddress, {
"label",
"address_type"} },
4560 {
"wallet",
"gettransaction", &
gettransaction, {
"txid",
"include_watchonly",
"verbose"} },
4564 {
"wallet",
"importaddress", &
importaddress, {
"address",
"label",
"rescan",
"p2sh"} },
4566 {
"wallet",
"importmulti", &
importmulti, {
"requests",
"options"} },
4567 {
"wallet",
"importprivkey", &
importprivkey, {
"privkey",
"label",
"rescan"} },
4568 {
"wallet",
"importprunedfunds", &
importprunedfunds, {
"rawtransaction",
"txoutproof"} },
4569 {
"wallet",
"importpubkey", &
importpubkey, {
"pubkey",
"label",
"rescan"} },
4570 {
"wallet",
"importwallet", &
importwallet, {
"filename"} },
4573 {
"wallet",
"listlabels", &
listlabels, {
"purpose"} },
4575 {
"wallet",
"listreceivedbyaddress", &
listreceivedbyaddress, {
"minconf",
"include_empty",
"include_watchonly",
"address_filter"} },
4576 {
"wallet",
"listreceivedbylabel", &
listreceivedbylabel, {
"minconf",
"include_empty",
"include_watchonly"} },
4577 {
"wallet",
"listsinceblock", &
listsinceblock, {
"blockhash",
"target_confirmations",
"include_watchonly",
"include_removed"} },
4578 {
"wallet",
"listtransactions", &
listtransactions, {
"label|dummy",
"count",
"skip",
"include_watchonly"} },
4579 {
"wallet",
"listunspent", &
listunspent, {
"minconf",
"maxconf",
"addresses",
"include_unsafe",
"query_options"} },
4582 {
"wallet",
"loadwallet", &
loadwallet, {
"filename",
"load_on_startup"} },
4583 {
"wallet",
"lockunspent", &
lockunspent, {
"unlock",
"transactions"} },
4585 {
"wallet",
"rescanblockchain", &
rescanblockchain, {
"start_height",
"stop_height"} },
4586 {
"wallet",
"send", &
send, {
"outputs",
"conf_target",
"estimate_mode",
"fee_rate",
"options"} },
4587 {
"wallet",
"sendmany", &
sendmany, {
"dummy",
"amounts",
"minconf",
"comment",
"subtractfeefrom",
"replaceable",
"conf_target",
"estimate_mode",
"fee_rate",
"verbose"} },
4588 {
"wallet",
"sendtoaddress", &
sendtoaddress, {
"address",
"amount",
"comment",
"comment_to",
"subtractfeefromamount",
"replaceable",
"conf_target",
"estimate_mode",
"avoid_reuse",
"fee_rate",
"verbose"} },
4589 {
"wallet",
"sethdseed", &
sethdseed, {
"newkeypool",
"seed"} },
4590 {
"wallet",
"setlabel", &
setlabel, {
"address",
"label"} },
4591 {
"wallet",
"settxfee", &
settxfee, {
"amount"} },
4592 {
"wallet",
"setwalletflag", &
setwalletflag, {
"flag",
"value"} },
4593 {
"wallet",
"signmessage", &
signmessage, {
"address",
"message"} },
4595 {
"wallet",
"unloadwallet", &
unloadwallet, {
"wallet_name",
"load_on_startup"} },
4597 {
"wallet",
"walletcreatefundedpsbt", &
walletcreatefundedpsbt, {
"inputs",
"outputs",
"locktime",
"options",
"bip32derivs"} },
4599 {
"wallet",
"walletpassphrase", &
walletpassphrase, {
"passphrase",
"timeout"} },
4601 {
"wallet",
"walletprocesspsbt", &
walletprocesspsbt, {
"psbt",
"sign",
"sighashtype",
"bip32derivs"} },
std::shared_ptr< const CTransaction > CTransactionRef
No wallet specified (error when there are multiple wallets loaded)
std::unique_ptr< SigningProvider > GetSolvingProvider(const CScript &script) const
Get the SigningProvider for a script.
CPubKey AddrToPubKey(const FillableSigningProvider &keystore, const std::string &addr_in)
CAmount GetFeePerK() const
Return the fee in satoshis for a size of 1000 bytes.
const std::string & GetName() const
Get a name for this wallet for logging/debugging purposes.
Helper for findBlock to selectively return pieces of block data.
static RPCHelpMan bumpfee_helper(std::string method_name)
RPCHelpMan signrawtransactionwithwallet()
bool NewKeyPool()
Mark old keypool keys as used, and generate all new keys.
const uint256 & GetHash() const
const std::string & get_str() const
bool IsWalletFlagSet(uint64_t flag) const override
check if a certain wallet flag is set
virtual bool findCommonAncestor(const uint256 &block_hash1, const uint256 &block_hash2, const FoundBlock &ancestor_out={}, const FoundBlock &block1_out={}, const FoundBlock &block2_out={})=0
Find most recent common ancestor between two blocks and optionally return block information.
static UniValue DescribeWalletAddress(const CWallet *const pwallet, const CTxDestination &dest)
const std::map< uint64_t, std::string > WALLET_FLAG_CAVEATS
virtual void findCoins(std::map< COutPoint, Coin > &coins)=0
Look up unspent output information.
static RPCHelpMan setlabel()
void RPCTypeCheck(const UniValue ¶ms, const std::list< UniValueType > &typesExpected, bool fAllowNull)
Type-check arguments; throws JSONRPCError if wrong type given.
unsigned int GetKeyPoolSize() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool IsLegacy() const
Determine if we are a legacy wallet.
virtual int rpcSerializationFlags()=0
Current RPC serialization flags.
bool SignTransaction(CWallet &wallet, CMutableTransaction &mtx)
Sign the new transaction,.
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
bool GetWalletNameFromJSONRPCRequest(const JSONRPCRequest &request, std::string &wallet_name)
Keypool ran out, call keypoolrefill first.
static RPCHelpMan listreceivedbylabel()
bool fAllowWatchOnly
Includes watch only addresses which are solvable.
std::map< std::string, std::string > mapValue_t
Enter the wallet passphrase with walletpassphrase first.
RPCHelpMan importpubkey()
void UnloadWallet(std::shared_ptr< CWallet > &&wallet)
Explicitly unload and delete the wallet.
void UnlockCoin(const COutPoint &output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
std::shared_ptr< CWallet > GetWallet(const std::string &name)
static RPCHelpMan walletpassphrasechange()
isminetype IsMine(const CTxDestination &dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void ParsePrevouts(const UniValue &prevTxsUnival, FillableSigningProvider *keystore, std::map< COutPoint, Coin > &coins)
Parse a prevtxs UniValue array and get the map of coins from it.
TransactionError FillPSBT(PartiallySignedTransaction &psbtx, bool &complete, int sighash_type=1, bool sign=true, bool bip32derivs=true, size_t *n_signed=nullptr) const
Fills out a PSBT with information from the wallet.
void ParseRecipients(const UniValue &address_amounts, const UniValue &subtract_fee_outputs, std::vector< CRecipient > &recipients)
ScriptPubKeyMan * GetScriptPubKeyMan(const OutputType &type, bool internal) const
Get the ScriptPubKeyMan for the given OutputType and internal/external chain.
Either this tx or a mempool ancestor signals rbf.
Optional< T > MakeOptional(bool condition, T &&value)
Substitute for C++17 std::make_optional.
RPCHelpMan importaddress()
auto Join(const std::vector< T > &list, const BaseType &separator, UnaryOp unary_op) -> decltype(unary_op(list.at(0)))
Join a list of items.
static RPCHelpMan getreceivedbylabel()
bool IsValidDestinationString(const std::string &str, const CChainParams ¶ms)
static const CAmount MAX_MONEY
No amount larger than this (in satoshi) is valid.
virtual void rpcRunLater(const std::string &name, std::function< void()> fn, int64_t seconds)=0
Run function after given number of seconds. Cancel any previous calls with same name.
static RPCHelpMan sendmany()
RecursiveMutex cs_KeyStore
Unconfirmed tx that does not signal rbf and is not in the mempool.
CAmount m_mine_untrusted_pending
Untrusted, but in mempool (pending)
static UniValue AddressBookDataToJSON(const CAddressBookData &data, const bool verbose)
Convert CAddressBookData to JSON record.
std::vector< uint256 > txids
static RPCHelpMan getwalletinfo()
bool IsPayToScriptHash() const
static RPCHelpMan getbalance()
static RPCHelpMan getrawchangeaddress()
static RPCHelpMan listsinceblock()
static const CAmount COIN
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
static RPCHelpMan listlockunspent()
LegacyScriptPubKeyMan & EnsureLegacyScriptPubKeyMan(CWallet &wallet, bool also_create)
static RPCHelpMan getaddressesbylabel()
void AvailableCoins(std::vector< COutput > &vCoins, bool fOnlySafe=true, const CCoinControl *coinControl=nullptr, const CAmount &nMinimumAmount=1, const CAmount &nMaximumAmount=MAX_MONEY, const CAmount &nMinimumSumAmount=MAX_MONEY, const uint64_t nMaximumCount=0) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
populate vCoins with vector of available COutputs.
const std::string UNIX_EPOCH_TIME
String used to describe UNIX epoch time in documentation, factored out to a constant for consistency...
const std::vector< UniValue > & getValues() const
std::string GetHex() const
static bool ParseIncludeWatchonly(const UniValue &include_watchonly, const CWallet &pwallet)
Used by RPC commands that have an include_watchonly parameter.
#define CHECK_NONFATAL(condition)
Throw a NonFatalCheckError when the condition evaluates to false.
static RPCHelpMan listwalletdir()
void EnsureWalletIsUnlocked(const CWallet *pwallet)
static CTransactionRef MakeTransactionRef()
bool IsChange(const CTxOut &txout) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
static UniValue ListReceived(const CWallet *const pwallet, const UniValue ¶ms, bool by_label) EXCLUSIVE_LOCKS_REQUIRED(pwallet-> cs_wallet)
UniValue ValueFromAmount(const CAmount &amount)
static RPCHelpMan sendtoaddress()
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
RPCHelpMan removeprunedfunds()
static const unsigned int DEFAULT_INCREMENTAL_RELAY_FEE
Default for -incrementalrelayfee, which sets the minimum feerate increase for mempool limiting or BIP...
bool HaveKey(const SigningProvider &wallet, const CKey &key)
Checks if a CKey is in the given CWallet compressed or otherwise.
static RPCHelpMan psbtbumpfee()
bool CanGetAddresses(bool internal=false) const
void RPCTypeCheckArgument(const UniValue &value, const UniValueType &typeExpected)
Type-check one argument; throws JSONRPCError if wrong type given.
static std::string LabelFromValue(const UniValue &value)
static auto & nullopt
Substitute for C++17 std::nullopt.
double ScanningProgress() const
int m_min_depth
Minimum chain depth value for coin availability.
WalletContext & EnsureWalletContext(const util::Ref &context)
Use sat/vB fee rate unit.
static RPCHelpMan listwallets()
static RPCHelpMan gettransaction()
static RPCHelpMan sethdseed()
std::vector< std::shared_ptr< CWallet > > GetWallets()
bool IsLocked() const override
int64_t GetTxTime() const
A version of CTransaction with the PSBT format.
Double ended buffer combining vector and stream-like interfaces.
CAmount m_default_max_tx_fee
Absolute maximum transaction fee (in satoshis) used by default for the wallet.
std::string SigningResultString(const SigningResult res)
static RPCHelpMan listaddressgroupings()
bool pushKVs(const UniValue &obj)
const SigningProvider *const provider
CAmount GetCredit(const isminefilter &filter) const
static bool GetAvoidReuseFlag(const CWallet *const pwallet, const UniValue ¶m)
CMutableTransaction ConstructTransaction(const UniValue &inputs_in, const UniValue &outputs_in, const UniValue &locktime, bool rbf)
Create a transaction from univalue parameters.
bool EncryptWallet(const SecureString &strWalletPassphrase)
bool FinalizeAndExtractPSBT(PartiallySignedTransaction &psbtx, CMutableTransaction &result)
Finalizes a PSBT if possible, and extracts it to a CMutableTransaction if it could be finalized...
int GetLastBlockHeight() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Get last block processed height.
bool fOverrideFeeRate
Override automatic min/max checks on fee, m_feerate must be set if true.
static RPCHelpMan walletlock()
const std::string & GetLabel() const
static RPCHelpMan signmessage()
CAmount GetDebit(const isminefilter &filter) const
filter decides which addresses will count towards the debit
CFeeRate m_min_fee
Override with -mintxfee.
Invalid, missing or duplicate parameter.
bool IsPayToWitnessScriptHash() const
static RPCHelpMan settxfee()
interfaces::Chain & chain() const
Interface for accessing chain state.
Result CreateRateBumpTransaction(CWallet &wallet, const uint256 &txid, const CCoinControl &coin_control, std::vector< bilingual_str > &errors, CAmount &old_fee, CAmount &new_fee, CMutableTransaction &mtx)
Create bumpfee transaction based on feerate estimates.
static RPCHelpMan keypoolrefill()
void RPCTypeCheckObj(const UniValue &o, const std::map< std::string, UniValueType > &typesExpected, bool fAllowNull, bool fStrict)
const UniValue & find_value(const UniValue &obj, const std::string &name)
RBFTransactionState
The rbf state of unconfirmed transactions.
void SignTransactionResultToJSON(CMutableTransaction &mtx, bool complete, const std::map< COutPoint, Coin > &coins, std::map< int, std::string > &input_errors, UniValue &result)
mapValue_t mapValue
Key/value map with information about the transaction.
std::shared_ptr< CWallet > CreateWallet(interfaces::Chain &chain, const std::string &name, Optional< bool > load_on_start, DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error, std::vector< bilingual_str > &warnings)
static RPCHelpMan walletpassphrase()
bool GetNewChangeDestination(const OutputType type, CTxDestination &dest, std::string &error)
int64_t CAmount
Amount in satoshis (Can be negative)
bool m_avoid_partial_spends
Avoid partial use of funds sent to a given address.
bool SetAddressBook(const CTxDestination &address, const std::string &strName, const std::string &purpose)
static RPCHelpMan abandontransaction()
CPubKey GenerateNewSeed()
virtual bool hasBlocks(const uint256 &block_hash, int min_height=0, Optional< int > max_height={})=0
Return true if data is available for all blocks in the specified range of blocks. ...
The wallet passphrase entered was incorrect.
std::string ToString(const T &t)
Locale-independent version of std::to_string.
Special type that is a STR with only hex chars.
std::string EncodeBase64(Span< const unsigned char > input)
static void ListTransactions(const CWallet *const pwallet, const CWalletTx &wtx, int nMinDepth, bool fLong, UniValue &ret, const isminefilter &filter_ismine, const std::string *filter_label) EXCLUSIVE_LOCKS_REQUIRED(pwallet-> cs_wallet)
List transactions based on the given criteria.
int64_t ScanningDuration() const
Optional< bool > m_signal_bip125_rbf
Override the wallet's m_signal_rbf if set.
UniValue operator()(const WitnessV0ScriptHash &id) const
bool IsLockedCoin(uint256 hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
UniValue operator()(const WitnessUnknown &id) const
void UnsetWalletFlag(uint64_t flag)
Unsets a single wallet flag.
bool error(const char *fmt, const Args &...args)
static const std::map< std::string, WalletFlags > WALLET_FLAG_MAP
int GetVersion() const
get the current wallet format (the oldest client version guaranteed to understand this wallet) ...
static const std::string WALLET_ENDPOINT_BASE
UniValue JSONRPCError(int code, const std::string &message)
bool push_back(const UniValue &val)
void ProcessSubScript(const CScript &subscript, UniValue &obj) const
Special string with only hex chars.
static RPCHelpMan bumpfee()
const std::string CURRENCY_ATOM
std::string ToString(const FeeEstimateMode &fee_estimate_mode=FeeEstimateMode::BTC_KVB) const
void CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::vector< std::pair< std::string, std::string >> orderForm)
Submit the transaction to the node's mempool and then relay to peers.
bool AbandonTransaction(const uint256 &hashTx)
static CAmount AmountFromValue(const UniValue &value)
RPCHelpMan importwallet()
std::string GetTxnOutputType(TxoutType t)
Get the name of a TxoutType as a string.
int64_t GetOldestKeyPoolTime() const
virtual bool findAncestorByHeight(const uint256 &block_hash, int ancestor_height, const FoundBlock &ancestor_out={})=0
Find ancestor of block at specified height and optionally return ancestor information.
int ParseSighashString(const UniValue &sighash)
An input of a transaction.
bool FundTransaction(CMutableTransaction &tx, CAmount &nFeeRet, int &nChangePosInOut, bilingual_str &error, bool lockUnspents, const std::set< int > &setSubtractFeeFromOutputs, CCoinControl)
Insert additional inputs into the transaction by calling CreateTransaction();.
bool DecodeBase64PSBT(PartiallySignedTransaction &psbt, const std::string &base64_tx, std::string &error)
Decode a base64ed PSBT into a PartiallySignedTransaction.
static RPCHelpMan unloadwallet()
OutputType m_default_address_type
CTxDestination subtype to encode any future Witness version.
static RPCHelpMan loadwallet()
bool m_add_inputs
If false, only selected inputs are used.
UniValue SendMoney(CWallet *const pwallet, const CCoinControl &coin_control, std::vector< CRecipient > &recipients, mapValue_t map_value, bool verbose)
virtual std::string Format()=0
CTxDestination destChange
Custom change destination, if not set an address is generated.
unsigned int ParseConfirmTarget(const UniValue &value, unsigned int max_target)
Parse a confirm target option and raise an RPC error if it is invalid.
std::set< uint256 > GetConflicts() const NO_THREAD_SAFETY_ANALYSIS
static RPCHelpMan listunspent()
An encapsulated public key.
static RPCHelpMan getbalances()
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
bool IsHex(const std::string &str)
void SetHDSeed(const CPubKey &key)
void UnlockAllCoins() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Unexpected type was passed as parameter.
Command given in wrong wallet encryption state (encrypting an encrypted wallet etc.)
Flag set when a wallet contains no HD seed and no private keys, scripts, addresses, and other watch only things, and is therefore "blank.".
virtual bool findBlock(const uint256 &hash, const FoundBlock &block={})=0
Return whether node has the block and optionally return block metadata or contents.
static const std::vector< RPCResult > TransactionDescriptionString()
SigningResult SignMessage(const std::string &message, const PKHash &pkhash, std::string &str_sig) const
uint256 GetLastBlockHash() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
const std::string CURRENCY_UNIT
Optional< unsigned int > m_confirm_target
Override the default confirmation target if set.
bool m_avoid_address_reuse
Forbids inclusion of dirty (previously used) addresses.
static RPCHelpMan upgradewallet()
General application defined errors.
static const std::string HELP_REQUIRING_PASSPHRASE
LegacyScriptPubKeyMan * GetOrCreateLegacyScriptPubKeyMan()
bool pushKV(const std::string &key, const UniValue &val)
isminetype
IsMine() return codes.
An output of a transaction.
bool RemoveWallet(const std::shared_ptr< CWallet > &wallet, Optional< bool > load_on_start, std::vector< bilingual_str > &warnings)
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
const std::string InvalidEstimateModeErrorMessage()
bool IsFromMe(const isminefilter &filter) const
Invalid wallet specified.
An outpoint - a combination of a transaction hash and an index n into its vout.
std::vector< CTxOut > vout
std::shared_ptr< CWallet > GetWalletForJSONRPCRequest(const JSONRPCRequest &request)
Figures out what wallet, if any, to use for a JSONRPCRequest.
CTxDestination AddAndGetMultisigDestination(const int required, const std::vector< CPubKey > &pubkeys, OutputType type, FillableSigningProvider &keystore, CScript &script_out)
Special numeric to denote unix epoch time.
std::map< CTxDestination, CAmount > GetAddressBalances() const
UniValue operator()(const CNoDestination &dest) const
Type-safe dynamic reference.
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
Optional arg that is a named argument and has a default value of null.
static RPCHelpMan createwallet()
RAII object to check and reserve a wallet rescan.
A transaction with a bunch of additional info that only the owner cares about.
std::string FeeModes(const std::string &delimiter)
size_t KeypoolCountExternalKeys() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
RPC method is deprecated.
bool IsSolvable(const SigningProvider &provider, const CScript &script)
CRIPEMD160 & Write(const unsigned char *data, size_t len)
void ListLockedCoins(std::vector< COutPoint > &vOutpts) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
static RPCHelpMan lockunspent()
RPCHelpMan importdescriptors()
static constexpr uint64_t MUTABLE_WALLET_FLAGS
static RPCHelpMan getunconfirmedbalance()
void LockCoin(const COutPoint &output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Failed to encrypt the wallet.
UniValue operator()(const ScriptHash &scripthash) const
Optional argument with default value omitted because they are implicitly clear.
CTxDestination DecodeDestination(const std::string &str)
const CHDChain & GetHDChain() const
static RPCHelpMan walletcreatefundedpsbt()
static RPCHelpMan listlabels()
Span< const CRPCCommand > GetWalletRPCCommands()
RPCHelpMan importprunedfunds()
#define EXCLUSIVE_LOCKS_REQUIRED(...)
static void WalletTxToJSON(interfaces::Chain &chain, const CWalletTx &wtx, UniValue &entry)
std::vector< CTransactionRef > vtx
int m_max_depth
Maximum chain depth value for coin availability.
bool UpgradeWallet(int version, bilingual_str &error)
Upgrade the wallet.
static void SetFeeEstimateMode(const CWallet &wallet, CCoinControl &cc, const UniValue &conf_target, const UniValue &estimate_mode, const UniValue &fee_rate, bool override_min_fee)
Update coin control with fee estimation based on the given parameters.
Result CommitTransaction(CWallet &wallet, const uint256 &txid, CMutableTransaction &&mtx, std::vector< bilingual_str > &errors, uint256 &bumped_txid)
Commit the bumpfee transaction.
interfaces::Chain * chain
WalletDatabase & GetDatabase() const override
Optional< OutputType > m_default_change_type
Default output type for change outputs.
std::unique_ptr< Descriptor > InferDescriptor(const CScript &script, const SigningProvider &provider)
Find a descriptor for the specified script, using information from provider where possible...
An interface to be implemented by keystores that support signing.
const UniValue & get_array() const
bool ChangeWalletPassphrase(const SecureString &strOldWalletPassphrase, const SecureString &strNewWalletPassphrase)
void BlockUntilSyncedToCurrentChain() const EXCLUSIVE_LOCKS_REQUIRED(!void SetWalletFlag(uint64_t flags)
Blocks until the wallet state is up-to-date to /at least/ the current chain at the time this function...
UniValue operator()(const WitnessV0KeyHash &id) const
Special string to represent a floating point amount.
bool CreateTransaction(const std::vector< CRecipient > &vecSend, CTransactionRef &tx, CAmount &nFeeRet, int &nChangePosInOut, bilingual_str &error, const CCoinControl &coin_control, FeeCalculation &fee_calc_out, bool sign=true)
Create a new transaction paying the recipients with a set of coins selected by SelectCoins(); Also cr...
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
Serialized script, used inside transaction inputs and outputs.
static RPCHelpMan rescanblockchain()
bool TopUpKeyPool(unsigned int kpSize=0)
static const int PROTOCOL_VERSION
network protocol versioning
Not enough funds in wallet or account.
std::string WriteHDKeypath(const std::vector< uint32_t > &keypath)
Write HD keypaths as strings.
enum CWallet::ScanResult::@15 status
LegacyScriptPubKeyMan * GetLegacyScriptPubKeyMan() const
Get the LegacyScriptPubKeyMan which is used for all types, internal, and external.
virtual bool GetCScript(const CScriptID &scriptid, CScript &script) const
A reference to a CKey: the Hash160 of its serialized public key.
static CAmount GetReceived(const CWallet &wallet, const UniValue ¶ms, bool by_label) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
virtual bool GetPubKey(const CKeyID &address, CPubKey &pubkey) const
Special type representing a floating point amount (can be either NUM or STR)
TxoutType Solver(const CScript &scriptPubKey, std::vector< std::vector< unsigned char >> &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
int GetDepthInMainChain() const NO_THREAD_SAFETY_ANALYSIS
Return depth of transaction in blockchain: <0 : conflicts with a transaction this deep in the blockch...
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
RPCHelpMan importprivkey()
std::string EncodeHexTx(const CTransaction &tx, const int serializeFlags=0)
Fee rate in satoshis per kilobyte: CAmount / kB.
static RPCHelpMan getnewaddress()
FoundBlock & hash(uint256 &hash)
static RPCHelpMan setwalletflag()
virtual RBFTransactionState isRBFOptIn(const CTransaction &tx)=0
Check if transaction is RBF opt in.
const UniValue NullUniValue
#define AssertLockNotHeld(cs)
UrlDecodeFn *const URL_DECODE
CPubKey DeriveNewSeed(const CKey &key)
A reference to a CScript: the Hash160 of its serialization (see script.h)
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
WalletContext struct containing references to state shared between CWallet instances, like the reference to the chain interface, and the list of opened wallets.
std::string EncodeDestination(const CTxDestination &dest)
Standard JSON-RPC 2.0 errors.
Optional< int > last_scanned_height
A mutable version of CTransaction.
static RPCHelpMan backupwallet()
SecureString create_passphrase
void TxToUniv(const CTransaction &tx, const uint256 &hashBlock, UniValue &entry, bool include_hex=true, int serialize_flags=0)
static RPCHelpMan getreceivedbyaddress()
virtual std::unique_ptr< CKeyMetadata > GetMetadata(const CTxDestination &dest) const
virtual unsigned int estimateMaxBlocks()=0
Fee estimator max target.
static RPCHelpMan walletprocesspsbt()
bool CanSupportFeature(enum WalletFeature wf) const override EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
check whether we support the named feature
void FundTransaction(CWallet *const pwallet, CMutableTransaction &tx, CAmount &fee_out, int &change_position, const UniValue &options, CCoinControl &coinControl, bool override_min_fee)
UniValue JSONRPCTransactionError(TransactionError terr, const std::string &err_string)
FeeEstimateMode m_fee_mode
Fee estimation mode to control arguments to estimateSmartFee.
std::vector< fs::path > ListWalletDir()
Get wallets in wallet directory.
bool IsSpent(const uint256 &hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Outpoint is spent if any non-conflicted transaction spends it:
FoundBlock & height(int &height)
bool exists(const std::string &key) const
static RPCHelpMan encryptwallet()
Optional< CFeeRate > m_feerate
Override the wallet's m_pay_tx_fee if set.
Optional< OutputType > m_change_type
Override the default change type if set, ignored if destChange is set.
unsigned int nTimeReceived
time received by this node
An encapsulated private key.
A Span is an object that can refer to a contiguous sequence of objects.
The basic transaction that is broadcasted on the network and contained in blocks. ...
const std::vector< std::string > & getKeys() const
boost::optional< T > Optional
Substitute for C++17 std::optional.
uint256 ParseHashV(const UniValue &v, std::string strName)
Utilities: convert hex-encoded Values (throws error if not hex).
RPCHelpMan getaddressinfo()
bool FeeModeFromString(const std::string &mode_string, FeeEstimateMode &fee_estimate_mode)
RPCErrorCode
Bitcoin RPC error codes.
std::shared_ptr< CWallet > LoadWallet(interfaces::Chain &chain, const std::string &name, Optional< bool > load_on_start, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error, std::vector< bilingual_str > &warnings)
UniValue operator()(const PKHash &pkhash) const
Special dictionary with keys that are not literals.
CKey DecodeSecret(const std::string &str)
ScanResult ScanForWalletTransactions(const uint256 &start_block, int start_height, Optional< int > max_height, const WalletRescanReserver &reserver, bool fUpdate)
Scan the block chain (starting in start_block) for transactions from or to us.
void Finalize(unsigned char hash[OUTPUT_SIZE])
boost::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
void __pushKV(const std::string &key, const UniValue &val)
static RPCHelpMan listtransactions()
bool BackupWallet(const std::string &strDest) const
Indicate that this wallet supports DescriptorScriptPubKeyMan.
CKeyID seed_id
seed hash160
const UniValue & get_obj() const
virtual bool rpcEnableDeprecated(const std::string &method)=0
Check if deprecated RPC is enabled.
bool IsSpentKey(const uint256 &hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
int64_t GetTime()
Return system time (or mocked time, if set)
static RPCHelpMan fundrawtransaction()
DescribeWalletAddressVisitor(const SigningProvider *_provider)
static void MaybePushAddress(UniValue &entry, const CTxDestination &dest)
UniValue DescribeAddress(const CTxDestination &dest)
std::multimap< int64_t, CWalletTx * > TxItems
const CAddressBookData * FindAddressBookEntry(const CTxDestination &, bool allow_change=false) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Balance GetBalance(int min_depth=0, bool avoid_reuse=true) const
bool ParseOutputType(const std::string &type, OutputType &output_type)
bool Unlock(const CKeyingMaterial &vMasterKeyIn, bool accept_no_keys=false)
std::string StringForFeeReason(FeeReason reason)
bool SignTransaction(CMutableTransaction &tx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
const std::string EXAMPLE_ADDRESS[2]
Example bech32 addresses for the RPCExamples help documentation.
virtual CFeeRate relayMinFee()=0
Relay current minimum fee (from -minrelaytxfee and -incrementalrelayfee settings).
Wrapper for UniValue::VType, which includes typeAny: Used to denote don't care type.
CPubKey HexToPubKey(const std::string &hex_in)
Error parsing or validating structure in raw format.
bool GetNewDestination(const OutputType type, const std::string label, CTxDestination &dest, std::string &error)
static RPCHelpMan listreceivedbyaddress()
A hasher class for RIPEMD-160.
CKeyID ToKeyID(const PKHash &key_hash)
Special type to denote elision (...)
V Cat(V v1, V &&v2)
Concatenate two vectors, moving elements.
virtual bool HaveKey(const CKeyID &address) const
static RPCHelpMan addmultisigaddress()
Span< A > constexpr MakeSpan(A(&a)[N])
MakeSpan for arrays:
std::set< std::set< CTxDestination > > GetAddressGroupings() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
NODISCARD bool DecodeHexTx(CMutableTransaction &tx, const std::string &hex_tx, bool try_no_witness=false, bool try_witness=true)
uint256 ParseHashO(const UniValue &o, std::string strKey)