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);
414 int nChangePosRet = -1;
418 const bool fCreated = pwallet->
CreateTransaction(recipients, tx, nFeeRequired, nChangePosRet, error, coin_control, fee_calc_out,
true);
425 entry.
pushKV(
"txid", tx->GetHash().GetHex());
429 return tx->GetHash().GetHex();
435 "\nSend an amount to a given address." +
441 "This is not part of the transaction, just kept in your wallet."},
443 "to which you're sending the transaction. This is not part of the \n"
444 "transaction, just kept in your wallet."},
445 {
"subtractfeefromamount",
RPCArg::Type::BOOL,
"false",
"The fee will be deducted from the amount being sent.\n"
446 "The recipient will receive less bitcoins than you enter in the amount field."},
447 {
"replaceable",
RPCArg::Type::BOOL,
"wallet default",
"Allow this transaction to be replaced by a transaction with higher fees via BIP 125"},
448 {
"conf_target",
RPCArg::Type::NUM,
"wallet -txconfirmtarget",
"Confirmation target in blocks"},
449 {
"estimate_mode",
RPCArg::Type::STR,
"unset", std::string() +
"The fee estimate mode, must be one of (case insensitive):\n"
451 {
"avoid_reuse",
RPCArg::Type::BOOL,
"true",
"(only available if avoid_reuse wallet flag is set) Avoid spending from dirty addresses; addresses are considered\n"
452 "dirty if they have previously been used in a transaction."},
454 {
"verbose",
RPCArg::Type::BOOL,
"false",
"If true, return extra information about the transaction."},
457 RPCResult{
"if verbose is not set or set to false",
471 "\nSend 0.1 BTC with a confirmation target of 6 blocks in economical fee estimate mode using positional arguments\n"
473 "\nSend 0.1 BTC with a fee rate of 1.1 " +
CURRENCY_ATOM +
"/vB, subtract fee from amount, BIP125-replaceable, using positional arguments\n"
475 "\nSend 0.2 BTC with a confirmation target of 6 blocks in economical fee estimate mode using named arguments\n"
477 "\nSend 0.5 BTC with a fee rate of 25 " +
CURRENCY_ATOM +
"/vB using named arguments\n"
479 +
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")
485 CWallet*
const pwallet = wallet.get();
489 pwallet->BlockUntilSyncedToCurrentChain();
495 if (!request.params[2].isNull() && !request.params[2].get_str().empty())
496 mapValue[
"comment"] = request.params[2].get_str();
497 if (!request.params[3].isNull() && !request.params[3].get_str().empty())
498 mapValue[
"to"] = request.params[3].get_str();
500 bool fSubtractFeeFromAmount =
false;
501 if (!request.params[4].isNull()) {
502 fSubtractFeeFromAmount = request.params[4].get_bool();
506 if (!request.params[5].isNull()) {
514 SetFeeEstimateMode(*pwallet, coin_control, request.params[6], request.params[7], request.params[9],
false);
519 const std::string address = request.params[0].get_str();
520 address_amounts.
pushKV(address, request.params[1]);
522 if (fSubtractFeeFromAmount) {
523 subtractFeeFromAmount.
push_back(address);
526 std::vector<CRecipient> recipients;
528 const bool verbose{request.params[10].isNull() ?
false : request.params[10].get_bool()};
530 return SendMoney(pwallet, coin_control, recipients, mapValue, verbose);
538 "\nLists groups of addresses which have had their common ownership\n"
539 "made public by common use as inputs or as the resulting change\n"
540 "in past transactions\n",
564 const CWallet*
const pwallet = wallet.get();
568 pwallet->BlockUntilSyncedToCurrentChain();
583 if (address_book_entry) {
584 addressInfo.
push_back(address_book_entry->GetLabel());
591 return jsonGroupings;
599 "\nSign a message with the private key of an address" +
609 "\nUnlock the wallet for 30 seconds\n"
611 "\nCreate the signature\n"
612 +
HelpExampleCli(
"signmessage",
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"my message\"") +
613 "\nVerify the signature\n"
614 +
HelpExampleCli(
"verifymessage",
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"signature\" \"my message\"") +
615 "\nAs a JSON-RPC call\n"
616 +
HelpExampleRpc(
"signmessage",
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"my message\"")
622 const CWallet*
const pwallet = wallet.get();
628 std::string strAddress = request.params[0].get_str();
629 std::string strMessage = request.params[1].get_str();
636 const PKHash *pkhash = boost::get<PKHash>(&dest);
641 std::string signature;
656 std::set<CTxDestination> address_set;
661 address_set = wallet.GetLabelAddresses(label);
669 if (!wallet.IsMine(script_pub_key)) {
672 address_set.insert(dest);
677 if (!params[1].isNull())
678 min_depth = params[1].get_int();
682 for (
const std::pair<const uint256, CWalletTx>& wtx_pair : wallet.mapWallet) {
688 for (
const CTxOut& txout : wtx.
tx->vout) {
703 "\nReturns the total amount received by the given address in transactions with at least minconf confirmations.\n",
706 {
"minconf",
RPCArg::Type::NUM,
"1",
"Only include transactions confirmed at least this many times."},
712 "\nThe amount from transactions with at least 1 confirmation\n"
714 "\nThe amount including unconfirmed transactions, zero confirmations\n"
716 "\nThe amount with at least 6 confirmations\n"
718 "\nAs a JSON-RPC call\n"
725 const CWallet*
const pwallet = wallet.get();
729 pwallet->BlockUntilSyncedToCurrentChain();
742 "\nReturns the total amount received by addresses with <label> in transactions with at least [minconf] confirmations.\n",
745 {
"minconf",
RPCArg::Type::NUM,
"1",
"Only include transactions confirmed at least this many times."},
751 "\nAmount received by the default label with at least 1 confirmation\n"
753 "\nAmount received at the tabby label including unconfirmed amounts with zero confirmations\n"
755 "\nThe amount with at least 6 confirmations\n"
757 "\nAs a JSON-RPC call\n"
764 const CWallet*
const pwallet = wallet.get();
768 pwallet->BlockUntilSyncedToCurrentChain();
781 "\nReturns the total available balance.\n"
782 "The available balance is what the wallet considers currently spendable, and is\n"
783 "thus affected by options which limit spendability such as -spendzeroconfchange.\n",
786 {
"minconf",
RPCArg::Type::NUM,
"0",
"Only include transactions confirmed at least this many times."},
787 {
"include_watchonly",
RPCArg::Type::BOOL,
"true for watch-only wallets, otherwise false",
"Also include balance in watch-only addresses (see 'importaddress')"},
788 {
"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."},
794 "\nThe total amount in the wallet with 0 or more confirmations\n"
796 "\nThe total amount in the wallet with at least 6 confirmations\n"
798 "\nAs a JSON-RPC call\n"
805 const CWallet*
const pwallet = wallet.get();
809 pwallet->BlockUntilSyncedToCurrentChain();
813 const UniValue& dummy_value = request.params[0];
819 if (!request.params[1].isNull()) {
820 min_depth = request.params[1].get_int();
827 const auto bal = pwallet->
GetBalance(min_depth, avoid_reuse);
829 return ValueFromAmount(bal.m_mine_trusted + (include_watchonly ? bal.m_watchonly_trusted : 0));
837 "DEPRECATED\nIdentical to getbalances().mine.untrusted_pending\n",
845 const CWallet*
const pwallet = wallet.get();
849 pwallet->BlockUntilSyncedToCurrentChain();
862 "\nSend multiple times. Amounts are double-precision floating point numbers." +
874 "The fee will be equally deducted from the amount of each selected address.\n"
875 "Those recipients will receive less bitcoins than you enter in their corresponding amount field.\n"
876 "If no addresses are specified here, the sender pays the fee.",
881 {
"replaceable",
RPCArg::Type::BOOL,
"wallet default",
"Allow this transaction to be replaced by a transaction with higher fees via BIP 125"},
882 {
"conf_target",
RPCArg::Type::NUM,
"wallet -txconfirmtarget",
"Confirmation target in blocks"},
883 {
"estimate_mode",
RPCArg::Type::STR,
"unset", std::string() +
"The fee estimate mode, must be one of (case insensitive):\n"
886 {
"verbose",
RPCArg::Type::BOOL,
"false",
"If true, return extra infomration about the transaction."},
889 RPCResult{
"if verbose is not set or set to false",
891 "the number of addresses."
897 "the number of addresses."},
903 "\nSend two amounts to two different addresses:\n"
905 "\nSend two amounts to two different addresses setting the confirmation and comment:\n"
907 "\nSend two amounts to two different addresses, subtract fee from amount:\n"
909 "\nAs a JSON-RPC call\n"
916 CWallet*
const pwallet = wallet.get();
920 pwallet->BlockUntilSyncedToCurrentChain();
924 if (!request.params[0].isNull() && !request.params[0].get_str().empty()) {
930 if (!request.params[3].isNull() && !request.params[3].get_str().empty())
931 mapValue[
"comment"] = request.params[3].
get_str();
934 if (!request.params[4].isNull())
935 subtractFeeFromAmount = request.params[4].
get_array();
938 if (!request.params[5].isNull()) {
942 SetFeeEstimateMode(*pwallet, coin_control, request.params[6], request.params[7], request.params[8],
false);
944 std::vector<CRecipient> recipients;
946 const bool verbose{request.params[9].isNull() ?
false : request.params[9].get_bool()};
948 return SendMoney(pwallet, coin_control, recipients, std::move(mapValue), verbose);
957 "\nAdd an nrequired-to-sign multisignature address to the wallet. Requires a new wallet backup.\n"
958 "Each key is a Bitcoin address or hex-encoded public key.\n"
959 "This functionality is only intended for use with non-watchonly addresses.\n"
960 "See `importaddress` for watchonly p2sh address support.\n"
961 "If 'label' is specified, assign address to that label.\n",
970 {
"address_type",
RPCArg::Type::STR,
"set by -addresstype",
"The address type to use. Options are \"legacy\", \"p2sh-segwit\", and \"bech32\"."},
981 "\nAdd a multisig address from 2 addresses\n"
983 "\nAs a JSON-RPC call\n"
990 CWallet*
const pwallet = wallet.get();
997 if (!request.params[2].isNull())
1000 int required = request.params[0].get_int();
1004 std::vector<CPubKey> pubkeys;
1005 for (
unsigned int i = 0; i < keys_or_addrs.
size(); ++i) {
1006 if (
IsHex(keys_or_addrs[i].get_str()) && (keys_or_addrs[i].
get_str().length() == 66 || keys_or_addrs[i].
get_str().length() == 130)) {
1009 pubkeys.push_back(
AddrToPubKey(spk_man, keys_or_addrs[i].get_str()));
1014 if (!request.params[3].isNull()) {
1031 result.
pushKV(
"descriptor", descriptor->ToString());
1040 int nConf{std::numeric_limits<int>::max()};
1052 if (!params[0].isNull())
1053 nMinDepth = params[0].get_int();
1056 bool fIncludeEmpty =
false;
1057 if (!params[1].isNull())
1058 fIncludeEmpty = params[1].get_bool();
1066 bool has_filtered_address =
false;
1068 if (!by_label && params.size() > 3) {
1073 has_filtered_address =
true;
1077 std::map<CTxDestination, tallyitem> mapTally;
1078 for (
const std::pair<const uint256, CWalletTx>& pairWtx : pwallet->mapWallet) {
1081 if (wtx.
IsCoinBase() || !pwallet->chain().checkFinalTx(*wtx.
tx)) {
1086 if (nDepth < nMinDepth)
1089 for (
const CTxOut& txout : wtx.
tx->vout)
1095 if (has_filtered_address && !(filtered_address == address)) {
1100 if(!(mine & filter))
1114 std::map<std::string, tallyitem> label_tally;
1118 auto start = pwallet->m_address_book.begin();
1119 auto end = pwallet->m_address_book.end();
1121 if (has_filtered_address) {
1122 start = pwallet->m_address_book.find(filtered_address);
1124 end = std::next(start);
1128 for (
auto item_it = start; item_it != end; ++item_it)
1130 if (item_it->second.IsChange())
continue;
1132 const std::string& label = item_it->second.GetLabel();
1133 auto it = mapTally.find(address);
1134 if (
it == mapTally.end() && !fIncludeEmpty)
1138 int nConf = std::numeric_limits<int>::max();
1139 bool fIsWatchonly =
false;
1140 if (
it != mapTally.end())
1142 nAmount = (*it).second.nAmount;
1143 nConf = (*it).second.nConf;
1144 fIsWatchonly = (*it).second.fIsWatchonly;
1158 obj.
pushKV(
"involvesWatchonly",
true);
1161 obj.
pushKV(
"confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
1162 obj.
pushKV(
"label", label);
1164 if (
it != mapTally.end())
1166 for (
const uint256& _item : (*it).second.txids)
1171 obj.
pushKV(
"txids", transactions);
1178 for (
const auto& entry : label_tally)
1180 CAmount nAmount = entry.second.nAmount;
1181 int nConf = entry.second.nConf;
1183 if (entry.second.fIsWatchonly)
1184 obj.
pushKV(
"involvesWatchonly",
true);
1186 obj.
pushKV(
"confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
1187 obj.
pushKV(
"label", entry.first);
1198 "\nList balances by receiving address.\n",
1200 {
"minconf",
RPCArg::Type::NUM,
"1",
"The minimum number of confirmations before payments are included."},
1201 {
"include_empty",
RPCArg::Type::BOOL,
"false",
"Whether to include addresses that haven't received any payments."},
1202 {
"include_watchonly",
RPCArg::Type::BOOL,
"true for watch-only wallets, otherwise false",
"Whether to include watch-only addresses (see 'importaddress')"},
1210 {
RPCResult::Type::BOOL,
"involvesWatchonly",
"Only returns true if imported addresses were involved in transaction"},
1213 {
RPCResult::Type::NUM,
"confirmations",
"The number of confirmations of the most recent transaction included"},
1214 {
RPCResult::Type::STR,
"label",
"The label of the receiving address. The default label is \"\""},
1232 const CWallet*
const pwallet = wallet.get();
1236 pwallet->BlockUntilSyncedToCurrentChain();
1248 "\nList received transactions by label.\n",
1250 {
"minconf",
RPCArg::Type::NUM,
"1",
"The minimum number of confirmations before payments are included."},
1251 {
"include_empty",
RPCArg::Type::BOOL,
"false",
"Whether to include labels that haven't received any payments."},
1252 {
"include_watchonly",
RPCArg::Type::BOOL,
"true for watch-only wallets, otherwise false",
"Whether to include watch-only addresses (see 'importaddress')"},
1259 {
RPCResult::Type::BOOL,
"involvesWatchonly",
"Only returns true if imported addresses were involved in transaction"},
1261 {
RPCResult::Type::NUM,
"confirmations",
"The number of confirmations of the most recent transaction included"},
1262 {
RPCResult::Type::STR,
"label",
"The label of the receiving address. The default label is \"\""},
1275 const CWallet*
const pwallet = wallet.get();
1279 pwallet->BlockUntilSyncedToCurrentChain();
1309 std::list<COutputEntry> listReceived;
1310 std::list<COutputEntry> listSent;
1312 wtx.GetAmounts(listReceived, listSent, nFee, filter_ismine);
1322 if (involvesWatchonly || (pwallet->IsMine(s.destination) &
ISMINE_WATCH_ONLY)) {
1323 entry.
pushKV(
"involvesWatchonly",
true);
1326 entry.
pushKV(
"category",
"send");
1328 const auto* address_book_entry = pwallet->FindAddressBookEntry(s.destination);
1329 if (address_book_entry) {
1330 entry.
pushKV(
"label", address_book_entry->GetLabel());
1332 entry.
pushKV(
"vout", s.vout);
1336 entry.
pushKV(
"abandoned", wtx.isAbandoned());
1337 ret.push_back(entry);
1342 if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth) {
1346 const auto* address_book_entry = pwallet->FindAddressBookEntry(r.destination);
1347 if (address_book_entry) {
1348 label = address_book_entry->GetLabel();
1350 if (filter_label && label != *filter_label) {
1354 if (involvesWatchonly || (pwallet->IsMine(r.destination) &
ISMINE_WATCH_ONLY)) {
1355 entry.
pushKV(
"involvesWatchonly",
true);
1358 if (wtx.IsCoinBase())
1360 if (wtx.GetDepthInMainChain() < 1)
1361 entry.
pushKV(
"category",
"orphan");
1362 else if (wtx.IsImmatureCoinBase())
1363 entry.
pushKV(
"category",
"immature");
1365 entry.
pushKV(
"category",
"generate");
1369 entry.
pushKV(
"category",
"receive");
1372 if (address_book_entry) {
1373 entry.
pushKV(
"label", label);
1375 entry.
pushKV(
"vout", r.vout);
1378 ret.push_back(entry);
1385 return{{
RPCResult::Type::NUM,
"confirmations",
"The number of confirmations for the transaction. Negative confirmations means the\n"
1386 "transaction conflicted that many blocks ago."},
1388 {
RPCResult::Type::BOOL,
"trusted",
"Only present if we consider transaction to be trusted and so safe to spend from."},
1391 {
RPCResult::Type::NUM,
"blockindex",
"The index of the transaction in the block that includes it."},
1400 {
RPCResult::Type::STR,
"comment",
"If a comment is associated with the transaction, only present if not empty."},
1401 {
RPCResult::Type::STR,
"bip125-replaceable",
"(\"yes|no|unknown\") Whether this transaction could be replaced due to BIP125 (replace-by-fee);\n"
1402 "may be unknown for unconfirmed transactions not in the mempool"}};
1408 "\nIf a label name is provided, this will return only incoming transactions paying to addresses with the specified label.\n"
1409 "\nReturns up to 'count' most recent transactions skipping the first 'from' transactions.\n",
1412 "with the specified label, or \"*\" to disable filtering and return all transactions."},
1415 {
"include_watchonly",
RPCArg::Type::BOOL,
"true for watch-only wallets, otherwise false",
"Include transactions to watch-only addresses (see 'importaddress')"},
1422 {
RPCResult::Type::BOOL,
"involvesWatchonly",
"Only returns true if imported addresses were involved in transaction."},
1425 "\"send\" Transactions sent.\n"
1426 "\"receive\" Non-coinbase transactions received.\n"
1427 "\"generate\" Coinbase transactions received with more than 100 confirmations.\n"
1428 "\"immature\" Coinbase transactions received with 100 or fewer confirmations.\n"
1429 "\"orphan\" Orphaned coinbase transactions received."},
1431 "for all other categories"},
1435 "'send' category of transactions."},
1439 {
RPCResult::Type::BOOL,
"abandoned",
"'true' if the transaction has been abandoned (inputs are respendable). Only available for the \n"
1440 "'send' category of transactions."},
1445 "\nList the most recent 10 transactions in the systems\n"
1447 "\nList transactions 100 to 120\n"
1449 "\nAs a JSON-RPC call\n"
1456 const CWallet*
const pwallet = wallet.get();
1460 pwallet->BlockUntilSyncedToCurrentChain();
1462 const std::string* filter_label =
nullptr;
1463 if (!request.params[0].isNull() && request.params[0].get_str() !=
"*") {
1464 filter_label = &request.params[0].get_str();
1465 if (filter_label->empty()) {
1470 if (!request.params[1].isNull())
1471 nCount = request.params[1].get_int();
1473 if (!request.params[2].isNull())
1474 nFrom = request.params[2].get_int();
1494 for (CWallet::TxItems::const_reverse_iterator
it = txOrdered.rbegin();
it != txOrdered.rend(); ++
it)
1498 if ((
int)ret.
size() >= (nCount+nFrom))
break;
1504 if (nFrom > (
int)ret.
size())
1506 if ((nFrom + nCount) > (
int)ret.
size())
1507 nCount = ret.
size() - nFrom;
1509 const std::vector<UniValue>& txs = ret.
getValues();
1511 result.push_backV({ txs.rend() - nFrom - nCount, txs.rend() - nFrom });
1520 "\nGet all transactions in blocks since block [blockhash], or all transactions if omitted.\n"
1521 "If \"blockhash\" is no longer a part of the main chain, transactions from the fork point onward are included.\n"
1522 "Additionally, if include_removed is set, transactions affecting the wallet which were removed are returned in the \"removed\" array.\n",
1525 {
"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"},
1526 {
"include_watchonly",
RPCArg::Type::BOOL,
"true for watch-only wallets, otherwise false",
"Include transactions to watch-only addresses (see 'importaddress')"},
1527 {
"include_removed",
RPCArg::Type::BOOL,
"true",
"Show transactions that were removed due to a reorg in the \"removed\" array\n"
1528 "(not guaranteed to work on pruned nodes)"},
1537 {
RPCResult::Type::BOOL,
"involvesWatchonly",
"Only returns true if imported addresses were involved in transaction."},
1540 "\"send\" Transactions sent.\n"
1541 "\"receive\" Non-coinbase transactions received.\n"
1542 "\"generate\" Coinbase transactions received with more than 100 confirmations.\n"
1543 "\"immature\" Coinbase transactions received with 100 or fewer confirmations.\n"
1544 "\"orphan\" Orphaned coinbase transactions received."},
1546 "for all other categories"},
1549 "'send' category of transactions."},
1553 {
RPCResult::Type::BOOL,
"abandoned",
"'true' if the transaction has been abandoned (inputs are respendable). Only available for the \n"
1554 "'send' category of transactions."},
1559 {
RPCResult::Type::ARR,
"removed",
"<structure is the same as \"transactions\" above, only present if include_removed=true>\n"
1560 "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."
1562 {
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"},
1567 +
HelpExampleCli(
"listsinceblock",
"\"000000000000000bacf66f7497b7dc45ef753ee9a7d38571037cdb1a57f663ad\" 6")
1568 +
HelpExampleRpc(
"listsinceblock",
"\"000000000000000bacf66f7497b7dc45ef753ee9a7d38571037cdb1a57f663ad\", 6")
1575 const CWallet& wallet = *pwallet;
1578 wallet.BlockUntilSyncedToCurrentChain();
1585 int target_confirms = 1;
1589 if (!request.params[0].isNull() && !request.params[0].get_str().empty()) {
1590 blockId =
ParseHashV(request.params[0],
"blockhash");
1598 if (!request.params[1].isNull()) {
1599 target_confirms = request.params[1].get_int();
1601 if (target_confirms < 1) {
1610 bool include_removed = (request.params[3].isNull() || request.params[3].get_bool());
1616 for (
const std::pair<const uint256, CWalletTx>& pairWtx : wallet.mapWallet) {
1627 while (include_removed && altheight && *altheight > *height) {
1633 auto it = wallet.mapWallet.find(tx->GetHash());
1634 if (
it != wallet.mapWallet.end()) {
1649 ret.
pushKV(
"transactions", transactions);
1650 if (include_removed) ret.
pushKV(
"removed", removed);
1661 "\nGet detailed information about in-wallet transaction <txid>\n",
1664 {
"include_watchonly",
RPCArg::Type::BOOL,
"true for watch-only wallets, otherwise false",
1665 "Whether to include watch-only addresses in balance calculation and details[]"},
1667 "Whether to include a `decoded` field containing the decoded transaction (equivalent to RPC decoderawtransaction)"},
1674 "'send' category of transactions."},
1682 {
RPCResult::Type::BOOL,
"involvesWatchonly",
"Only returns true if imported addresses were involved in transaction."},
1685 "\"send\" Transactions sent.\n"
1686 "\"receive\" Non-coinbase transactions received.\n"
1687 "\"generate\" Coinbase transactions received with more than 100 confirmations.\n"
1688 "\"immature\" Coinbase transactions received with 100 or fewer confirmations.\n"
1689 "\"orphan\" Orphaned coinbase transactions received."},
1694 "'send' category of transactions."},
1695 {
RPCResult::Type::BOOL,
"abandoned",
"'true' if the transaction has been abandoned (inputs are respendable). Only available for the \n"
1696 "'send' category of transactions."},
1700 {
RPCResult::Type::OBJ,
"decoded",
"Optional, the decoded transaction (only present when `verbose` is passed)",
1702 {
RPCResult::Type::ELISION,
"",
"Equivalent to the RPC decoderawtransaction method, or the RPC getrawtransaction method when `verbose` is passed."},
1707 HelpExampleCli(
"gettransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
1708 +
HelpExampleCli(
"gettransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\" true")
1709 +
HelpExampleCli(
"gettransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\" false true")
1710 +
HelpExampleRpc(
"gettransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
1716 const CWallet*
const pwallet = wallet.get();
1720 pwallet->BlockUntilSyncedToCurrentChain();
1732 bool verbose = request.params[2].isNull() ?
false : request.params[2].get_bool();
1735 auto it = pwallet->mapWallet.find(hash);
1736 if (
it == pwallet->mapWallet.end()) {
1743 CAmount nNet = nCredit - nDebit;
1754 entry.
pushKV(
"details", details);
1757 entry.
pushKV(
"hex", strHex);
1762 entry.
pushKV(
"decoded", decoded);
1773 "\nMark in-wallet transaction <txid> as abandoned\n"
1774 "This will mark this transaction and all its in-wallet descendants as abandoned which will allow\n"
1775 "for their inputs to be respent. It can be used to replace \"stuck\" or evicted transactions.\n"
1776 "It only works on transactions which are not included in a block and are not currently in the mempool.\n"
1777 "It has no effect on transactions which are already abandoned.\n",
1783 HelpExampleCli(
"abandontransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
1784 +
HelpExampleRpc(
"abandontransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
1790 CWallet*
const pwallet = wallet.get();
1794 pwallet->BlockUntilSyncedToCurrentChain();
1800 if (!pwallet->mapWallet.count(hash)) {
1816 "\nSafely copies current wallet file to destination, which can be a directory or a path with filename.\n",
1829 const CWallet*
const pwallet = wallet.get();
1833 pwallet->BlockUntilSyncedToCurrentChain();
1837 std::string strDest = request.params[0].get_str();
1851 "\nFills the keypool."+
1865 CWallet*
const pwallet = wallet.get();
1874 unsigned int kpSize = 0;
1875 if (!request.params[0].isNull()) {
1876 if (request.params[0].get_int() < 0)
1878 kpSize = (
unsigned int)request.params[0].
get_int();
1897 "\nStores the wallet decryption key in memory for 'timeout' seconds.\n"
1898 "This is needed prior to performing transactions related to private keys such as sending bitcoins\n"
1900 "Issuing the walletpassphrase command while the wallet is already unlocked will set a new unlock\n"
1901 "time that overrides the old one.\n",
1908 "\nUnlock the wallet for 60 seconds\n"
1910 "\nLock the wallet again (before 60 seconds)\n"
1912 "\nAs a JSON-RPC call\n"
1919 CWallet*
const pwallet = wallet.get();
1922 int64_t relock_time;
1934 strWalletPass.reserve(100);
1937 strWalletPass = request.params[0].get_str().c_str();
1940 nSleepTime = request.params[1].get_int64();
1942 if (nSleepTime < 0) {
1946 constexpr int64_t MAX_SLEEP_TIME = 100000000;
1947 if (nSleepTime > MAX_SLEEP_TIME) {
1948 nSleepTime = MAX_SLEEP_TIME;
1951 if (strWalletPass.empty()) {
1955 if (!pwallet->
Unlock(strWalletPass)) {
1961 pwallet->nRelockTime =
GetTime() + nSleepTime;
1962 relock_time = pwallet->nRelockTime;
1973 std::weak_ptr<CWallet> weak_wallet = wallet;
1975 if (
auto shared_wallet = weak_wallet.lock()) {
1976 LOCK(shared_wallet->cs_wallet);
1978 if (shared_wallet->nRelockTime != relock_time)
return;
1979 shared_wallet->Lock();
1980 shared_wallet->nRelockTime = 0;
1993 "\nChanges the wallet passphrase from 'oldpassphrase' to 'newpassphrase'.\n",
2000 HelpExampleCli(
"walletpassphrasechange",
"\"old one\" \"new one\"")
2001 +
HelpExampleRpc(
"walletpassphrasechange",
"\"old one\", \"new one\"")
2007 CWallet*
const pwallet = wallet.get();
2018 strOldWalletPass.reserve(100);
2019 strOldWalletPass = request.params[0].get_str().c_str();
2022 strNewWalletPass.reserve(100);
2023 strNewWalletPass = request.params[1].get_str().c_str();
2025 if (strOldWalletPass.empty() || strNewWalletPass.empty()) {
2042 "\nRemoves the wallet encryption key from memory, locking the wallet.\n"
2043 "After calling this method, you will need to call walletpassphrase again\n"
2044 "before being able to call any methods which require the wallet to be unlocked.\n",
2048 "\nSet the passphrase for 2 minutes to perform a transaction\n"
2050 "\nPerform a send (requires passphrase set)\n"
2052 "\nClear the passphrase since we are done before 2 minutes is up\n"
2054 "\nAs a JSON-RPC call\n"
2061 CWallet*
const pwallet = wallet.get();
2070 pwallet->nRelockTime = 0;
2081 "\nEncrypts the wallet with 'passphrase'. This is for first time encryption.\n"
2082 "After this, any calls that interact with private keys such as sending or signing \n"
2083 "will require the passphrase to be set prior the making these calls.\n"
2084 "Use the walletpassphrase call for this, and then walletlock call.\n"
2085 "If the wallet is already encrypted, use the walletpassphrasechange call.\n",
2091 "\nEncrypt your wallet\n"
2093 "\nNow set the passphrase to use the wallet, such as for signing or sending bitcoin\n"
2095 "\nNow we can do something like sign\n"
2096 +
HelpExampleCli(
"signmessage",
"\"address\" \"test message\"") +
2097 "\nNow lock the wallet again by removing the passphrase\n"
2099 "\nAs a JSON-RPC call\n"
2106 CWallet*
const pwallet = wallet.get();
2121 strWalletPass.reserve(100);
2122 strWalletPass = request.params[0].get_str().c_str();
2124 if (strWalletPass.empty()) {
2132 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.";
2140 "\nUpdates list of temporarily unspendable outputs.\n"
2141 "Temporarily lock (unlock=false) or unlock (unlock=true) specified transaction outputs.\n"
2142 "If no transaction outputs are specified when unlocking then all current locked transaction outputs are unlocked.\n"
2143 "A locked transaction output will not be chosen by automatic coin selection, when spending bitcoins.\n"
2144 "Manually selected coins are automatically unlocked.\n"
2145 "Locks are stored in memory only. Nodes start with zero locked outputs, and the locked output list\n"
2146 "is always cleared (by virtue of process exit) when a node stops or fails.\n"
2147 "Also see the listunspent call\n",
2150 {
"transactions",
RPCArg::Type::ARR,
"empty array",
"The transaction outputs and within each, the txid (string) vout (numeric).",
2165 "\nList the unspent transactions\n"
2167 "\nLock an unspent transaction\n"
2168 +
HelpExampleCli(
"lockunspent",
"false \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") +
2169 "\nList the locked transactions\n"
2171 "\nUnlock the transaction again\n"
2172 +
HelpExampleCli(
"lockunspent",
"true \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") +
2173 "\nAs a JSON-RPC call\n"
2174 +
HelpExampleRpc(
"lockunspent",
"false, \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"")
2180 CWallet*
const pwallet = wallet.get();
2184 pwallet->BlockUntilSyncedToCurrentChain();
2190 bool fUnlock = request.params[0].get_bool();
2192 if (request.params[1].isNull()) {
2200 const UniValue& output_params = request.params[1];
2204 std::vector<COutPoint> outputs;
2205 outputs.reserve(output_params.
size());
2207 for (
unsigned int idx = 0; idx < output_params.
size(); idx++) {
2224 const auto it = pwallet->mapWallet.find(outpt.
hash);
2225 if (
it == pwallet->mapWallet.end()) {
2231 if (outpt.
n >= trans.
tx->vout.size()) {
2241 if (fUnlock && !is_locked) {
2245 if (!fUnlock && is_locked) {
2249 outputs.push_back(outpt);
2253 for (
const COutPoint& outpt : outputs) {
2266 "\nReturns list of temporarily unspendable outputs.\n"
2267 "See the lockunspent call to lock and unlock transactions for spending.\n",
2280 "\nList the unspent transactions\n"
2282 "\nLock an unspent transaction\n"
2283 +
HelpExampleCli(
"lockunspent",
"false \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") +
2284 "\nList the locked transactions\n"
2286 "\nUnlock the transaction again\n"
2287 +
HelpExampleCli(
"lockunspent",
"true \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") +
2288 "\nAs a JSON-RPC call\n"
2295 const CWallet*
const pwallet = wallet.get();
2299 std::vector<COutPoint> vOutpts;
2304 for (
const COutPoint& outpt : vOutpts) {
2307 o.
pushKV(
"txid", outpt.hash.GetHex());
2308 o.
pushKV(
"vout", (
int)outpt.n);
2320 "\nSet the transaction fee per kB for this wallet. Overrides the global -paytxfee command line parameter.\n"
2321 "Can be deactivated by passing 0 as the fee. In that case automatic fee selection will be used by default.\n",
2336 CWallet*
const pwallet = wallet.get();
2341 CFeeRate tx_fee_rate(nAmount, 1000);
2345 }
else if (tx_fee_rate < pwallet->chain().relayMinFee()) {
2347 }
else if (tx_fee_rate < pwallet->m_min_fee) {
2349 }
else if (tx_fee_rate > max_tx_fee_rate) {
2363 "Returns an object with all balances in " +
CURRENCY_UNIT +
".\n",
2371 {
RPCResult::Type::STR_AMOUNT,
"untrusted_pending",
"untrusted pending balance (outputs created by others that are in the mempool)"},
2373 {
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)"},
2375 {
RPCResult::Type::OBJ,
"watchonly",
"watchonly balances (not present if wallet does not watch anything)",
2378 {
RPCResult::Type::STR_AMOUNT,
"untrusted_pending",
"untrusted pending balance (outputs created by others that are in the mempool)"},
2390 CWallet& wallet = *rpc_wallet;
2394 wallet.BlockUntilSyncedToCurrentChain();
2403 balances_mine.pushKV(
"untrusted_pending",
ValueFromAmount(bal.m_mine_untrusted_pending));
2404 balances_mine.pushKV(
"immature",
ValueFromAmount(bal.m_mine_immature));
2408 const auto full_bal = wallet.
GetBalance(0,
false);
2409 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));
2411 balances.pushKV(
"mine", balances_mine);
2414 if (spk_man && spk_man->HaveWatchOnly()) {
2416 balances_watchonly.pushKV(
"trusted",
ValueFromAmount(bal.m_watchonly_trusted));
2417 balances_watchonly.pushKV(
"untrusted_pending",
ValueFromAmount(bal.m_watchonly_untrusted_pending));
2418 balances_watchonly.pushKV(
"immature",
ValueFromAmount(bal.m_watchonly_immature));
2419 balances.pushKV(
"watchonly", balances_watchonly);
2429 "Returns an object containing various wallet state info.\n",
2443 {
RPCResult::Type::NUM,
"keypoolsize",
"how many new keys are pre-generated (only counts external keys)"},
2444 {
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)"},
2445 {
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)"},
2448 {
RPCResult::Type::BOOL,
"private_keys_enabled",
"false if privatekeys are disabled for this wallet (enforced watch-only wallet)"},
2449 {
RPCResult::Type::BOOL,
"avoid_reuse",
"whether this wallet tracks clean/dirty coins in terms of reuse"},
2450 {
RPCResult::Type::OBJ,
"scanning",
"current scanning details, or false if no scan is in progress",
2455 {
RPCResult::Type::BOOL,
"descriptors",
"whether this wallet uses descriptors for scriptPubKey management"},
2466 const CWallet*
const pwallet = wallet.get();
2470 pwallet->BlockUntilSyncedToCurrentChain();
2485 obj.
pushKV(
"txcount", (
int)pwallet->mapWallet.size());
2486 if (kp_oldest > 0) {
2487 obj.
pushKV(
"keypoololdest", kp_oldest);
2489 obj.
pushKV(
"keypoolsize", (int64_t)kpExternalSize);
2503 obj.
pushKV(
"unlocked_until", pwallet->nRelockTime);
2512 obj.
pushKV(
"scanning", scanning);
2514 obj.
pushKV(
"scanning",
false);
2525 "Returns a list of wallets in the wallet directory.\n",
2548 wallet.
pushKV(
"name", path.string());
2553 result.
pushKV(
"wallets", wallets);
2562 "Returns a list of currently loaded wallets.\n"
2563 "For full information on the wallet, use \"getwalletinfo\"\n",
2579 for (
const std::shared_ptr<CWallet>& wallet :
GetWallets()) {
2580 LOCK(wallet->cs_wallet);
2592 "\nLoads a wallet from a wallet file or directory."
2593 "\nNote that all wallet command-line options used when starting bitcoind will be"
2594 "\napplied to the new wallet (eg -rescan, etc).\n",
2597 {
"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."},
2613 const std::string
name(request.params[0].get_str());
2619 std::vector<bilingual_str> warnings;
2621 std::shared_ptr<CWallet>
const wallet =
LoadWallet(*context.
chain,
name, load_on_start, options, status, error, warnings);
2630 obj.
pushKV(
"name", wallet->GetName());
2640 std::string
flags =
"";
2643 flags += (flags ==
"" ?
"" :
", ") +
it.first;
2646 "\nChange the state of the given wallet flag for a wallet.\n",
2667 CWallet*
const pwallet = wallet.get();
2669 std::string flag_str = request.params[0].get_str();
2670 bool value = request.params[1].isNull() || request.params[1].get_bool();
2688 res.pushKV(
"flag_name", flag_str);
2689 res.pushKV(
"flag_state", value);
2710 "\nCreates and loads a new wallet.\n",
2713 {
"disable_private_keys",
RPCArg::Type::BOOL,
"false",
"Disable the possibility of private keys (only watchonlys are possible in this mode)."},
2714 {
"blank",
RPCArg::Type::BOOL,
"false",
"Create a blank wallet. A blank wallet has no keys or HD seed. One can be set using sethdseed."},
2716 {
"avoid_reuse",
RPCArg::Type::BOOL,
"false",
"Keep track of coin reuse, and treat dirty and clean coins differently with privacy considerations in mind."},
2717 {
"descriptors",
RPCArg::Type::BOOL,
"false",
"Create a native descriptor wallet. The wallet will use descriptors internally to handle address creation"},
2718 {
"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."},
2723 {
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."},
2735 if (!request.params[1].isNull() && request.params[1].get_bool()) {
2739 if (!request.params[2].isNull() && request.params[2].get_bool()) {
2743 passphrase.reserve(100);
2744 std::vector<bilingual_str> warnings;
2745 if (!request.params[3].isNull()) {
2746 passphrase = request.params[3].get_str().c_str();
2747 if (passphrase.empty()) {
2749 warnings.emplace_back(
Untranslated(
"Empty string given as passphrase, wallet will not be encrypted."));
2753 if (!request.params[4].isNull() && request.params[4].get_bool()) {
2756 if (!request.params[5].isNull() && request.params[5].get_bool()) {
2761 warnings.emplace_back(
Untranslated(
"Wallet is an experimental descriptor wallet"));
2771 std::shared_ptr<CWallet> wallet =
CreateWallet(*context.
chain, request.params[0].get_str(), load_on_start, options, status,
error, warnings);
2778 obj.
pushKV(
"name", wallet->GetName());
2789 "Unloads the wallet referenced by the request endpoint otherwise unloads the wallet specified in the argument.\n"
2790 "Specifying the wallet name on a wallet endpoint is invalid.",
2792 {
"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)."},
2793 {
"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."},
2804 std::string wallet_name;
2806 if (!request.params[0].isNull()) {
2810 wallet_name = request.params[0].get_str();
2813 std::shared_ptr<CWallet> wallet =
GetWallet(wallet_name);
2821 std::vector<bilingual_str> warnings;
2840 "\nReturns array of unspent transaction outputs\n"
2841 "with between minconf and maxconf (inclusive) confirmations.\n"
2842 "Optionally filter to only include txouts paid to specified addresses.\n",
2845 {
"maxconf",
RPCArg::Type::NUM,
"9999999",
"The maximum confirmations to filter"},
2846 {
"addresses",
RPCArg::Type::ARR,
"empty array",
"The bitcoin addresses to filter",
2851 {
"include_unsafe",
RPCArg::Type::BOOL,
"true",
"Include outputs that are not safe to spend\n"
2852 "See description of \"safe\" attribute below."},
2875 {
RPCResult::Type::STR,
"witnessScript",
"witnessScript if the scriptPubKey is P2WSH or P2SH-P2WSH"},
2877 {
RPCResult::Type::BOOL,
"solvable",
"Whether we know how to spend this output, ignoring the lack of keys"},
2878 {
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)"},
2880 {
RPCResult::Type::BOOL,
"safe",
"Whether this output is considered safe to spend. Unconfirmed transactions\n"
2881 "from outside keys and unconfirmed replacement transactions are considered unsafe\n"
2882 "and are not eligible for spending by fundrawtransaction and sendtoaddress."},
2890 +
HelpExampleCli(
"listunspent",
"6 9999999 '[]' true '{ \"minimumAmount\": 0.005 }'")
2891 +
HelpExampleRpc(
"listunspent",
"6, 9999999, [] , true, { \"minimumAmount\": 0.005 } ")
2897 const CWallet*
const pwallet = wallet.get();
2900 if (!request.params[0].isNull()) {
2902 nMinDepth = request.params[0].get_int();
2905 int nMaxDepth = 9999999;
2906 if (!request.params[1].isNull()) {
2908 nMaxDepth = request.params[1].get_int();
2911 std::set<CTxDestination> destinations;
2912 if (!request.params[2].isNull()) {
2915 for (
unsigned int idx = 0; idx < inputs.
size(); idx++) {
2916 const UniValue& input = inputs[idx];
2921 if (!destinations.insert(dest).second) {
2927 bool include_unsafe =
true;
2928 if (!request.params[3].isNull()) {
2930 include_unsafe = request.params[3].get_bool();
2936 uint64_t nMaximumCount = 0;
2938 if (!request.params[4].isNull()) {
2950 if (options.
exists(
"minimumAmount"))
2953 if (options.
exists(
"maximumAmount"))
2956 if (options.
exists(
"minimumSumAmount"))
2959 if (options.
exists(
"maximumCount"))
2960 nMaximumCount = options[
"maximumCount"].get_int64();
2965 pwallet->BlockUntilSyncedToCurrentChain();
2968 std::vector<COutput> vecOutputs;
2975 pwallet->
AvailableCoins(vecOutputs, !include_unsafe, &cctl, nMinimumAmount, nMaximumAmount, nMinimumSumAmount, nMaximumCount);
2982 for (
const COutput& out : vecOutputs) {
2984 const CScript& scriptPubKey = out.tx->tx->vout[out.i].scriptPubKey;
2986 bool reused = avoid_reuse && pwallet->
IsSpentKey(out.tx->GetHash(), out.i);
2988 if (destinations.size() && (!fValidAddress || !destinations.count(address)))
2992 entry.
pushKV(
"txid", out.tx->GetHash().GetHex());
2993 entry.
pushKV(
"vout", out.i);
2995 if (fValidAddress) {
2999 if (address_book_entry) {
3000 entry.
pushKV(
"label", address_book_entry->GetLabel());
3003 std::unique_ptr<SigningProvider> provider = pwallet->
GetSolvingProvider(scriptPubKey);
3008 if (provider->GetCScript(hash, redeemScript)) {
3020 if (provider->GetCScript(
id, witnessScript)) {
3030 if (provider->GetCScript(
id, witnessScript)) {
3039 entry.
pushKV(
"confirmations", out.nDepth);
3040 entry.
pushKV(
"spendable", out.fSpendable);
3041 entry.
pushKV(
"solvable", out.fSolvable);
3042 if (out.fSolvable) {
3043 std::unique_ptr<SigningProvider> provider = pwallet->
GetSolvingProvider(scriptPubKey);
3046 entry.
pushKV(
"desc", descriptor->ToString());
3049 if (avoid_reuse) entry.
pushKV(
"reused", reused);
3050 entry.
pushKV(
"safe", out.fSafe);
3063 pwallet->BlockUntilSyncedToCurrentChain();
3065 change_position = -1;
3066 bool lockUnspents =
false;
3068 std::set<int> setSubtractFeeFromOutputs;
3103 if (options.
exists(
"add_inputs") ) {
3107 if (options.
exists(
"changeAddress") || options.
exists(
"change_address")) {
3108 const std::string change_address_str = (options.
exists(
"change_address") ? options[
"change_address"] : options[
"changeAddress"]).get_str();
3118 if (options.
exists(
"changePosition") || options.
exists(
"change_position")) {
3119 change_position = (options.
exists(
"change_position") ? options[
"change_position"] : options[
"changePosition"]).get_int();
3122 if (options.
exists(
"change_type")) {
3123 if (options.
exists(
"changeAddress") || options.
exists(
"change_address")) {
3133 const UniValue include_watching_option = options.
exists(
"include_watching") ? options[
"include_watching"] : options[
"includeWatching"];
3136 if (options.
exists(
"lockUnspents") || options.
exists(
"lock_unspents")) {
3137 lockUnspents = (options.
exists(
"lock_unspents") ? options[
"lock_unspents"] : options[
"lockUnspents"]).get_bool();
3140 if (options.
exists(
"feeRate")) {
3141 if (options.
exists(
"fee_rate")) {
3144 if (options.
exists(
"conf_target")) {
3145 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.");
3147 if (options.
exists(
"estimate_mode")) {
3154 if (options.
exists(
"subtractFeeFromOutputs") || options.
exists(
"subtract_fee_from_outputs") )
3155 subtractFeeFromOutputs = (options.
exists(
"subtract_fee_from_outputs") ? options[
"subtract_fee_from_outputs"] : options[
"subtractFeeFromOutputs"]).get_array();
3157 if (options.
exists(
"replaceable")) {
3160 SetFeeEstimateMode(*pwallet, coinControl, options[
"conf_target"], options[
"estimate_mode"], options[
"fee_rate"], override_min_fee);
3167 if (tx.
vout.size() == 0)
3170 if (change_position != -1 && (change_position < 0 || (
unsigned int)change_position > tx.
vout.size()))
3173 for (
unsigned int idx = 0; idx < subtractFeeFromOutputs.
size(); idx++) {
3174 int pos = subtractFeeFromOutputs[idx].
get_int();
3175 if (setSubtractFeeFromOutputs.count(pos))
3179 if (pos >=
int(tx.
vout.size()))
3181 setSubtractFeeFromOutputs.insert(pos);
3186 if (!pwallet->
FundTransaction(tx, fee_out, change_position, error, lockUnspents, setSubtractFeeFromOutputs, coinControl)) {
3194 "\nIf the transaction has no inputs, they will be automatically selected to meet its out value.\n"
3195 "It will add at most one change output to the outputs.\n"
3196 "No existing outputs will be modified unless \"subtractFeeFromOutputs\" is specified.\n"
3197 "Note that inputs which were signed may need to be resigned after completion since in/outputs have been added.\n"
3198 "The inputs added will not be signed, use signrawtransactionwithkey\n"
3199 " or signrawtransactionwithwallet for that.\n"
3200 "Note that all existing inputs must have their previous output transaction be in the wallet.\n"
3201 "Note that all inputs selected must be of standard form and P2SH scripts must be\n"
3202 "in the wallet using importaddress or addmultisigaddress (to calculate fees).\n"
3203 "You can see whether this is the case by checking the \"solvable\" field in the listunspent output.\n"
3204 "Only pay-to-pubkey, multisig, and P2SH versions thereof are currently supported for watch-only\n",
3209 {
"add_inputs",
RPCArg::Type::BOOL,
"true",
"For a transaction with existing inputs, automatically include more if they are not enough."},
3210 {
"changeAddress",
RPCArg::Type::STR,
"pool address",
"The bitcoin address to receive the change"},
3211 {
"changePosition",
RPCArg::Type::NUM,
"random",
"The index of the change output"},
3212 {
"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\"."},
3213 {
"includeWatching",
RPCArg::Type::BOOL,
"true for watch-only wallets, otherwise false",
"Also select inputs which are watch only.\n"
3214 "Only solvable inputs can be used. Watch-only destinations are solvable if the public key and/or output script was imported,\n"
3215 "e.g. with 'importpubkey' or 'importmulti' with the 'pubkeys' or 'desc' field."},
3220 "The fee will be equally deducted from the amount of each specified output.\n"
3221 "Those recipients will receive less bitcoins than you enter in their corresponding amount field.\n"
3222 "If no outputs are specified here, the sender pays the fee.",
3227 {
"replaceable",
RPCArg::Type::BOOL,
"wallet default",
"Marks this transaction as BIP125 replaceable.\n"
3228 "Allows this transaction to be replaced by a transaction with higher fees"},
3229 {
"conf_target",
RPCArg::Type::NUM,
"wallet -txconfirmtarget",
"Confirmation target in blocks"},
3230 {
"estimate_mode",
RPCArg::Type::STR,
"unset", std::string() +
"The fee estimate mode, must be one of (case insensitive):\n"
3231 " \"" +
FeeModes(
"\"\n\"") +
"\""},
3234 {
"iswitness",
RPCArg::Type::BOOL,
"depends on heuristic tests",
"Whether the transaction hex is a serialized witness transaction.\n"
3235 "If iswitness is not present, heuristic tests will be used in decoding.\n"
3236 "If true, only witness deserialization will be tried.\n"
3237 "If false, only non-witness deserialization will be tried.\n"
3238 "This boolean should reflect whether the transaction has inputs\n"
3239 "(e.g. fully valid, or on-chain transactions), if known by the caller."
3251 "\nCreate a transaction with no inputs\n"
3252 +
HelpExampleCli(
"createrawtransaction",
"\"[]\" \"{\\\"myaddress\\\":0.01}\"") +
3253 "\nAdd sufficient unsigned inputs to meet the output value\n"
3254 +
HelpExampleCli(
"fundrawtransaction",
"\"rawtransactionhex\"") +
3255 "\nSign the transaction\n"
3256 +
HelpExampleCli(
"signrawtransactionwithwallet",
"\"fundedtransactionhex\"") +
3257 "\nSend the transaction\n"
3258 +
HelpExampleCli(
"sendrawtransaction",
"\"signedtransactionhex\"")
3264 CWallet*
const pwallet = wallet.get();
3266 RPCTypeCheck(request.params, {UniValue::VSTR, UniValueType(), UniValue::VBOOL});
3270 bool try_witness = request.params[2].isNull() ?
true : request.params[2].get_bool();
3271 bool try_no_witness = request.params[2].isNull() ?
true : !request.params[2].get_bool();
3272 if (!
DecodeHexTx(tx, request.params[0].get_str(), try_no_witness, try_witness)) {
3277 int change_position;
3281 FundTransaction(pwallet, tx, fee, change_position, request.params[1], coin_control,
true);
3286 result.
pushKV(
"changepos", change_position);
3295 return RPCHelpMan{
"signrawtransactionwithwallet",
3296 "\nSign inputs for raw transaction (serialized, hex-encoded).\n"
3297 "The second optional argument (may be null) is an array of previous transaction outputs that\n"
3298 "this transaction depends on but may not yet be in the block chain." +
3316 {
"sighashtype",
RPCArg::Type::STR,
"ALL",
"The signature hash type. Must be one of\n"
3320 " \"ALL|ANYONECANPAY\"\n"
3321 " \"NONE|ANYONECANPAY\"\n"
3322 " \"SINGLE|ANYONECANPAY\""},
3350 const CWallet*
const pwallet = wallet.get();
3352 RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VARR, UniValue::VSTR},
true);
3355 if (!
DecodeHexTx(mtx, request.params[0].get_str())) {
3364 std::map<COutPoint, Coin> coins;
3365 for (
const CTxIn& txin : mtx.
vin) {
3376 std::map<int, std::string> input_errors;
3378 bool complete = pwallet->
SignTransaction(mtx, coins, nHashType, input_errors);
3388 bool want_psbt = method_name ==
"psbtbumpfee";
3392 "\nBumps the fee of an opt-in-RBF transaction T, replacing it with a new transaction B.\n"
3393 + std::string(want_psbt ?
"Returns a PSBT instead of creating and signing a new transaction.\n" :
"") +
3394 "An opt-in RBF transaction with the given txid must be in the wallet.\n"
3395 "The command will pay the additional fee by reducing change outputs or adding inputs when necessary.\n"
3396 "It may add a new change output if one does not already exist.\n"
3397 "All inputs in the original transaction will be included in the replacement transaction.\n"
3398 "The command will fail if the wallet or mempool contains a transaction that spends one of T's outputs.\n"
3399 "By default, the new fee will be calculated automatically using the estimatesmartfee RPC.\n"
3400 "The user can specify a confirmation target for estimatesmartfee.\n"
3401 "Alternatively, the user can specify a fee rate in " +
CURRENCY_ATOM +
"/vB for the new transaction.\n"
3402 "At a minimum, the new fee rate must be high enough to pay an additional new relay fee (incrementalfee\n"
3403 "returned by getnetworkinfo) to enter the node's mempool.\n"
3404 "* WARNING: before version 0.21, fee_rate was in " +
CURRENCY_UNIT +
"/kvB. As of 0.21, fee_rate is in " +
CURRENCY_ATOM +
"/vB. *\n",
3409 {
"conf_target",
RPCArg::Type::NUM,
"wallet -txconfirmtarget",
"Confirmation target in blocks\n"},
3411 "\nSpecify a fee rate in " + CURRENCY_ATOM +
"/vB instead of relying on the built-in fee estimator.\n"
3412 "Must be at least " + incremental_fee +
" higher than the current transaction fee rate.\n"
3413 "WARNING: before version 0.21, fee_rate was in " +
CURRENCY_UNIT +
"/kvB. As of 0.21, fee_rate is in " + CURRENCY_ATOM +
"/vB.\n"},
3414 {
"replaceable",
RPCArg::Type::BOOL,
"true",
"Whether the new transaction should still be\n"
3415 "marked bip-125 replaceable. If true, the sequence numbers in the transaction will\n"
3416 "be left unchanged from the original. If false, any input sequence numbers in the\n"
3417 "original transaction that were less than 0xfffffffe will be increased to 0xfffffffe\n"
3418 "so the new transaction will not be explicitly bip-125 replaceable (though it may\n"
3419 "still be replaceable in practice, for example if it has unconfirmed ancestors which\n"
3420 "are replaceable).\n"},
3421 {
"estimate_mode",
RPCArg::Type::STR,
"unset", std::string() +
"The fee estimate mode, must be one of (case insensitive):\n"
3422 " \"" +
FeeModes(
"\"\n\"") +
"\""},
3429 {
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)")},
3431 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."}}
3443 "\nBump the fee, get the new transaction\'s" + std::string(want_psbt ?
"psbt" :
"txid") +
"\n" +
3450 CWallet*
const pwallet = wallet.get();
3454 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");
3459 RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VOBJ});
3467 if (!request.params[1].isNull()) {
3468 UniValue options = request.params[1];
3479 if (options.
exists(
"confTarget") && options.
exists(
"conf_target")) {
3483 auto conf_target = options.
exists(
"confTarget") ? options[
"confTarget"] : options[
"conf_target"];
3485 if (options.
exists(
"replaceable")) {
3488 SetFeeEstimateMode(*pwallet, coin_control, conf_target, options[
"estimate_mode"], options[
"fee_rate"],
false);
3493 pwallet->BlockUntilSyncedToCurrentChain();
3499 std::vector<bilingual_str> errors;
3543 bool complete =
false;
3558 result.
pushKV(
"errors", result_errors);
3571 "\nRescan the local blockchain for wallet related transactions.\n"
3572 "Note: Use \"getwalletinfo\" to query the scanning progress.\n",
3574 {
"start_height",
RPCArg::Type::NUM,
"0",
"block height where the rescan should start"},
3580 {
RPCResult::Type::NUM,
"start_height",
"The block height where the rescan started (the requested height or 0)"},
3581 {
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."},
3592 CWallet*
const pwallet = wallet.get();
3599 int start_height = 0;
3606 if (!request.params[0].isNull()) {
3607 start_height = request.params[0].get_int();
3608 if (start_height < 0 || start_height > tip_height) {
3613 if (!request.params[1].isNull()) {
3614 stop_height = request.params[1].get_int();
3615 if (*stop_height < 0 || *stop_height > tip_height) {
3617 }
else if (*stop_height < start_height) {
3624 throw JSONRPCError(
RPC_MISC_ERROR,
"Can't rescan beyond pruned data. Use RPC call getblockchaininfo to determine your pruned height.");
3642 response.
pushKV(
"start_height", start_height);
3657 std::vector<std::vector<unsigned char>> solutions_data;
3668 UniValue wallet_detail = boost::apply_visitor(*
this, embedded);
3669 subobj.
pushKVs(wallet_detail);
3673 if (subobj.
exists(
"pubkey")) obj.
pushKV(
"pubkey", subobj[
"pubkey"]);
3674 obj.
pushKV(
"embedded", std::move(subobj));
3678 obj.
pushKV(
"sigsrequired", solutions_data[0][0]);
3680 for (
size_t i = 1; i < solutions_data.size() - 1; ++i) {
3681 CPubKey key(solutions_data[i].begin(), solutions_data[i].end());
3684 obj.
pushKV(
"pubkeys", std::move(pubkeys));
3697 if (provider && provider->
GetPubKey(keyID, vchPubKey)) {
3699 obj.
pushKV(
"iscompressed", vchPubKey.IsCompressed());
3709 if (provider && provider->
GetCScript(scriptID, subscript)) {
3746 std::unique_ptr<SigningProvider> provider =
nullptr;
3769 "\nReturn information about the given bitcoin address.\n"
3770 "Some of the information will only be present if the address is in the active wallet.\n",
3781 {
RPCResult::Type::BOOL,
"solvable",
"If we know how to spend coins sent to this address, ignoring the possible lack of private keys."},
3782 {
RPCResult::Type::STR,
"desc",
true,
"A descriptor for spending coins sent to this address (only when solvable)."},
3788 {
RPCResult::Type::STR,
"script",
true,
"The output script type. Only if isscript is true and the redeemscript is known. Possible\n"
3789 "types: nonstandard, pubkey, pubkeyhash, scripthash, multisig, nulldata, witness_v0_keyhash,\n"
3790 "witness_v0_scripthash, witness_unknown."},
3792 {
RPCResult::Type::ARR,
"pubkeys",
true,
"Array of pubkeys associated with the known redeemscript (only if script is multisig).",
3796 {
RPCResult::Type::NUM,
"sigsrequired",
true,
"The number of signatures required to spend multisig output (only if script is multisig)."},
3797 {
RPCResult::Type::STR_HEX,
"pubkey",
true,
"The hex value of the raw public key for single-key addresses (possibly embedded in P2SH or P2WSH)."},
3798 {
RPCResult::Type::OBJ,
"embedded",
true,
"Information about the address embedded in P2SH or P2WSH, if relevant and known.",
3800 {
RPCResult::Type::ELISION,
"",
"Includes all getaddressinfo output fields for the embedded address, excluding metadata (timestamp, hdkeypath, hdseedid)\n"
3801 "and relation to the wallet (ismine, iswatchonly)."},
3808 {
RPCResult::Type::ARR,
"labels",
"Array of labels associated with the address. Currently limited to one label but returned\n"
3809 "as an array to keep the API stable if multiple labels are enabled in the future.",
3823 const CWallet*
const pwallet = wallet.get();
3835 ret.
pushKV(
"address", currentAddress);
3840 std::unique_ptr<SigningProvider> provider = pwallet->
GetSolvingProvider(scriptPubKey);
3845 bool solvable = provider &&
IsSolvable(*provider, scriptPubKey);
3846 ret.
pushKV(
"solvable", solvable);
3861 if (
const std::unique_ptr<CKeyMetadata> meta = spk_man->
GetMetadata(dest)) {
3862 ret.
pushKV(
"timestamp", meta->nCreateTime);
3863 if (meta->has_key_origin) {
3865 ret.
pushKV(
"hdseedid", meta->hd_seed_id.GetHex());
3866 ret.
pushKV(
"hdmasterfingerprint",
HexStr(meta->key_origin.fingerprint));
3878 if (address_book_entry) {
3879 labels.
push_back(address_book_entry->GetLabel());
3881 ret.
pushKV(
"labels", std::move(labels));
3891 "\nReturns the list of addresses assigned the specified label.\n",
3900 {
RPCResult::Type::STR,
"purpose",
"Purpose of address (\"send\" for sending address, \"receive\" for receiving address)"},
3912 const CWallet*
const pwallet = wallet.get();
3920 std::set<std::string> addresses;
3921 for (
const std::pair<const CTxDestination, CAddressBookData>& item : pwallet->m_address_book) {
3922 if (item.second.IsChange())
continue;
3923 if (item.second.GetLabel() == label) {
3928 bool unique = addresses.emplace(address).second;
3950 "\nReturns the list of all labels, or labels that are assigned to addresses with a specific purpose.\n",
3961 "\nList all labels\n"
3963 "\nList labels that have receiving addresses\n"
3965 "\nList labels that have sending addresses\n"
3967 "\nAs a JSON-RPC call\n"
3974 const CWallet*
const pwallet = wallet.get();
3978 std::string purpose;
3979 if (!request.params[0].isNull()) {
3980 purpose = request.params[0].get_str();
3984 std::set<std::string> label_set;
3985 for (
const std::pair<const CTxDestination, CAddressBookData>& entry : pwallet->m_address_book) {
3986 if (entry.second.IsChange())
continue;
3987 if (purpose.empty() || entry.second.purpose == purpose) {
3988 label_set.insert(entry.second.GetLabel());
3993 for (
const std::string&
name : label_set) {
4005 "\nEXPERIMENTAL warning: this call may be changed in future releases.\n"
4006 "\nSend a transaction.\n",
4009 "That is, each address can only appear once and there can only be one 'data' object.\n"
4010 "For convenience, a dictionary, which holds the key-value pairs directly, is also accepted.",
4024 {
"conf_target",
RPCArg::Type::NUM,
"wallet -txconfirmtarget",
"Confirmation target in blocks"},
4025 {
"estimate_mode",
RPCArg::Type::STR,
"unset", std::string() +
"The fee estimate mode, must be one of (case insensitive):\n"
4026 " \"" +
FeeModes(
"\"\n\"") +
"\""},
4030 {
"add_inputs",
RPCArg::Type::BOOL,
"false",
"If inputs are specified, automatically include more if they are not enough."},
4031 {
"add_to_wallet",
RPCArg::Type::BOOL,
"true",
"When false, returns a serialized transaction which will not be added to the wallet or broadcast"},
4032 {
"change_address",
RPCArg::Type::STR_HEX,
"pool address",
"The bitcoin address to receive the change"},
4033 {
"change_position",
RPCArg::Type::NUM,
"random",
"The index of the change output"},
4034 {
"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\"."},
4035 {
"conf_target",
RPCArg::Type::NUM,
"wallet -txconfirmtarget",
"Confirmation target in blocks"},
4036 {
"estimate_mode",
RPCArg::Type::STR,
"unset", std::string() +
"The fee estimate mode, must be one of (case insensitive):\n"
4037 " \"" +
FeeModes(
"\"\n\"") +
"\""},
4039 {
"include_watching",
RPCArg::Type::BOOL,
"true for watch-only wallets, otherwise false",
"Also select inputs which are watch only.\n"
4040 "Only solvable inputs can be used. Watch-only destinations are solvable if the public key and/or output script was imported,\n"
4041 "e.g. with 'importpubkey' or 'importmulti' with the 'pubkeys' or 'desc' field."},
4042 {
"inputs",
RPCArg::Type::ARR,
"empty array",
"Specify inputs instead of adding them automatically. A JSON array of JSON objects",
4049 {
"locktime",
RPCArg::Type::NUM,
"0",
"Raw locktime. Non-0 value also locktime-activates inputs"},
4051 {
"psbt",
RPCArg::Type::BOOL,
"automatic",
"Always return a PSBT, implies add_to_wallet=false."},
4052 {
"subtract_fee_from_outputs",
RPCArg::Type::ARR,
"empty array",
"Outputs to subtract the fee from, specified as integer indices.\n"
4053 "The fee will be equally deducted from the amount of each specified output.\n"
4054 "Those recipients will receive less bitcoins than you enter in their corresponding amount field.\n"
4055 "If no outputs are specified here, the sender pays the fee.",
4060 {
"replaceable",
RPCArg::Type::BOOL,
"wallet default",
"Marks this transaction as BIP125 replaceable.\n"
4061 "Allows this transaction to be replaced by a transaction with higher fees"},
4069 {
RPCResult::Type::STR_HEX,
"txid",
"The transaction id for the send. Only 1 transaction is created regardless of the number of addresses."},
4071 {
RPCResult::Type::STR,
"psbt",
"If more signatures are needed, or if add_to_wallet is false, the base64-encoded (partially) signed transaction"}
4075 "\nSend 0.1 BTC with a confirmation target of 6 blocks in economical fee estimate mode\n"
4077 "Send 0.2 BTC with a fee rate of 1.1 " +
CURRENCY_ATOM +
"/vB using positional arguments\n"
4079 "Send 0.2 BTC with a fee rate of 1 " +
CURRENCY_ATOM +
"/vB using the options argument\n"
4081 "Send 0.3 BTC with a fee rate of 25 " +
CURRENCY_ATOM +
"/vB using named arguments\n"
4083 "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"
4084 +
HelpExampleCli(
"send",
"'{\"" +
EXAMPLE_ADDRESS[0] +
"\": 0.1}' 1 economical '{\"add_to_wallet\": false, \"inputs\": [{\"txid\":\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\", \"vout\":1}]}'")
4099 CWallet*
const pwallet = wallet.get();
4102 if (options.exists(
"conf_target") || options.exists(
"estimate_mode")) {
4103 if (!request.params[1].isNull() || !request.params[2].isNull()) {
4107 options.pushKV(
"conf_target", request.params[1]);
4108 options.pushKV(
"estimate_mode", request.params[2]);
4110 if (options.exists(
"fee_rate")) {
4111 if (!request.params[3].isNull()) {
4115 options.pushKV(
"fee_rate", request.params[3]);
4117 if (!options[
"conf_target"].isNull() && (options[
"estimate_mode"].isNull() || (options[
"estimate_mode"].get_str() ==
"unset"))) {
4120 if (options.exists(
"feeRate")) {
4123 if (options.exists(
"changeAddress")) {
4126 if (options.exists(
"changePosition")) {
4129 if (options.exists(
"includeWatching")) {
4132 if (options.exists(
"lockUnspents")) {
4135 if (options.exists(
"subtractFeeFromOutputs")) {
4139 const bool psbt_opt_in = options.exists(
"psbt") && options[
"psbt"].get_bool();
4142 int change_position;
4144 if (options.exists(
"replaceable")) {
4145 rbf = options[
"replaceable"].get_bool();
4152 FundTransaction(pwallet, rawTx, fee, change_position, options, coin_control,
false);
4154 bool add_to_wallet =
true;
4155 if (options.exists(
"add_to_wallet")) {
4156 add_to_wallet = options[
"add_to_wallet"].get_bool();
4163 bool complete =
true;
4174 if (psbt_opt_in || !complete || !add_to_wallet) {
4182 std::string err_string;
4185 result.
pushKV(
"txid", tx->GetHash().GetHex());
4186 if (add_to_wallet && !psbt_opt_in) {
4189 result.
pushKV(
"hex", hex);
4192 result.
pushKV(
"complete", complete);
4202 "\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"
4203 "HD will have a new HD seed set so that new keys added to the keypool will be derived from this new seed.\n"
4204 "\nNote that you will need to MAKE A NEW BACKUP of your wallet after setting the HD wallet seed." +
4207 {
"newkeypool",
RPCArg::Type::BOOL,
"true",
"Whether to flush old unused addresses, including change addresses, from the keypool and regenerate it.\n"
4208 "If true, the next address from getnewaddress and change address from getrawchangeaddress will be from this new seed.\n"
4209 "If false, addresses (including change addresses if the wallet already had HD Chain Split enabled) from the existing\n"
4210 "keypool will be used until it has been depleted."},
4211 {
"seed",
RPCArg::Type::STR,
"random seed",
"The WIF private key to use as the new HD seed.\n"
4212 "The seed value can be retrieved using the dumpwallet command. It is the private key marked hdseed=1"},
4225 CWallet*
const pwallet = wallet.get();
4237 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");
4242 bool flush_key_pool =
true;
4243 if (!request.params[0].isNull()) {
4244 flush_key_pool = request.params[0].get_bool();
4248 if (request.params[1].isNull()) {
4252 if (!key.IsValid()) {
4274 "\nUpdate a PSBT with input information from our wallet and then sign inputs\n"
4275 "that we can sign for." +
4280 {
"sighashtype",
RPCArg::Type::STR,
"ALL",
"The signature hash type to sign with if not specified by the PSBT. Must be one of\n"
4284 " \"ALL|ANYONECANPAY\"\n"
4285 " \"NONE|ANYONECANPAY\"\n"
4286 " \"SINGLE|ANYONECANPAY\""},
4287 {
"bip32derivs",
RPCArg::Type::BOOL,
"true",
"Include BIP 32 derivation paths for public keys if we know them"},
4303 const CWallet*
const pwallet = wallet.get();
4305 RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL, UniValue::VSTR});
4318 bool sign = request.params[1].isNull() ?
true : request.params[1].get_bool();
4319 bool bip32derivs = request.params[3].isNull() ?
true : request.params[3].get_bool();
4320 bool complete =
true;
4330 result.
pushKV(
"complete", complete);
4340 "\nCreates and funds a transaction in the Partially Signed Transaction format.\n"
4341 "Implements the Creator and Updater roles.\n",
4349 {
"sequence",
RPCArg::Type::NUM,
"depends on the value of the 'locktime' and 'options.replaceable' arguments",
"The sequence number"},
4355 "That is, each address can only appear once and there can only be one 'data' object.\n"
4356 "For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also\n"
4357 "accepted as second parameter.",
4371 {
"locktime",
RPCArg::Type::NUM,
"0",
"Raw locktime. Non-0 value also locktime-activates inputs"},
4374 {
"add_inputs",
RPCArg::Type::BOOL,
"false",
"If inputs are specified, automatically include more if they are not enough."},
4375 {
"changeAddress",
RPCArg::Type::STR_HEX,
"pool address",
"The bitcoin address to receive the change"},
4376 {
"changePosition",
RPCArg::Type::NUM,
"random",
"The index of the change output"},
4377 {
"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\"."},
4378 {
"includeWatching",
RPCArg::Type::BOOL,
"true for watch-only wallets, otherwise false",
"Also select inputs which are watch only"},
4382 {
"subtractFeeFromOutputs",
RPCArg::Type::ARR,
"empty array",
"The outputs to subtract the fee from.\n"
4383 "The fee will be equally deducted from the amount of each specified output.\n"
4384 "Those recipients will receive less bitcoins than you enter in their corresponding amount field.\n"
4385 "If no outputs are specified here, the sender pays the fee.",
4390 {
"replaceable",
RPCArg::Type::BOOL,
"wallet default",
"Marks this transaction as BIP125 replaceable.\n"
4391 "Allows this transaction to be replaced by a transaction with higher fees"},
4392 {
"conf_target",
RPCArg::Type::NUM,
"wallet -txconfirmtarget",
"Confirmation target in blocks"},
4393 {
"estimate_mode",
RPCArg::Type::STR,
"unset", std::string() +
"The fee estimate mode, must be one of (case insensitive):\n"
4394 " \"" +
FeeModes(
"\"\n\"") +
"\""},
4397 {
"bip32derivs",
RPCArg::Type::BOOL,
"true",
"Include BIP 32 derivation paths for public keys if we know them"},
4408 "\nCreate a transaction with no inputs\n"
4409 +
HelpExampleCli(
"walletcreatefundedpsbt",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
4415 CWallet*
const pwallet = wallet.get();
4427 int change_position;
4429 const UniValue &replaceable_arg = request.params[3][
"replaceable"];
4430 if (!replaceable_arg.
isNull()) {
4432 rbf = replaceable_arg.
isTrue();
4439 FundTransaction(pwallet, rawTx, fee, change_position, request.params[3], coin_control,
true);
4445 bool bip32derivs = request.params[4].isNull() ?
true : request.params[4].get_bool();
4446 bool complete =
true;
4459 result.
pushKV(
"changepos", change_position);
4468 "\nUpgrade the wallet. Upgrades to the latest version if no version number is specified.\n"
4469 "New keys may be generated and a new wallet backup will need to be made.",
4491 CWallet*
const pwallet = wallet.get();
4498 if (!request.params[0].isNull()) {
4499 version = request.params[0].get_int();
4502 const int previous_version{pwallet->
GetVersion()};
4503 const bool wallet_upgraded{pwallet->
UpgradeWallet(version, error)};
4504 const int current_version{pwallet->
GetVersion()};
4507 if (wallet_upgraded) {
4508 if (previous_version == current_version) {
4509 result =
"Already at latest version. Wallet version unchanged.";
4511 result =
strprintf(
"Wallet upgraded successfully from version %i to version %i.", previous_version, current_version);
4517 obj.
pushKV(
"previous_version", previous_version);
4518 obj.
pushKV(
"current_version", current_version);
4519 if (!result.empty()) {
4520 obj.
pushKV(
"result", result);
4548 {
"rawtransactions",
"fundrawtransaction", &
fundrawtransaction, {
"hexstring",
"options",
"iswitness"} },
4551 {
"wallet",
"addmultisigaddress", &
addmultisigaddress, {
"nrequired",
"keys",
"label",
"address_type"} },
4552 {
"wallet",
"backupwallet", &
backupwallet, {
"destination"} },
4553 {
"wallet",
"bumpfee", &
bumpfee, {
"txid",
"options"} },
4554 {
"wallet",
"psbtbumpfee", &
psbtbumpfee, {
"txid",
"options"} },
4555 {
"wallet",
"createwallet", &
createwallet, {
"wallet_name",
"disable_private_keys",
"blank",
"passphrase",
"avoid_reuse",
"descriptors",
"load_on_startup"} },
4556 {
"wallet",
"dumpprivkey", &
dumpprivkey, {
"address"} },
4557 {
"wallet",
"dumpwallet", &
dumpwallet, {
"filename"} },
4558 {
"wallet",
"encryptwallet", &
encryptwallet, {
"passphrase"} },
4561 {
"wallet",
"getbalance", &
getbalance, {
"dummy",
"minconf",
"include_watchonly",
"avoid_reuse"} },
4562 {
"wallet",
"getnewaddress", &
getnewaddress, {
"label",
"address_type"} },
4566 {
"wallet",
"gettransaction", &
gettransaction, {
"txid",
"include_watchonly",
"verbose"} },
4570 {
"wallet",
"importaddress", &
importaddress, {
"address",
"label",
"rescan",
"p2sh"} },
4572 {
"wallet",
"importmulti", &
importmulti, {
"requests",
"options"} },
4573 {
"wallet",
"importprivkey", &
importprivkey, {
"privkey",
"label",
"rescan"} },
4574 {
"wallet",
"importprunedfunds", &
importprunedfunds, {
"rawtransaction",
"txoutproof"} },
4575 {
"wallet",
"importpubkey", &
importpubkey, {
"pubkey",
"label",
"rescan"} },
4576 {
"wallet",
"importwallet", &
importwallet, {
"filename"} },
4579 {
"wallet",
"listlabels", &
listlabels, {
"purpose"} },
4581 {
"wallet",
"listreceivedbyaddress", &
listreceivedbyaddress, {
"minconf",
"include_empty",
"include_watchonly",
"address_filter"} },
4582 {
"wallet",
"listreceivedbylabel", &
listreceivedbylabel, {
"minconf",
"include_empty",
"include_watchonly"} },
4583 {
"wallet",
"listsinceblock", &
listsinceblock, {
"blockhash",
"target_confirmations",
"include_watchonly",
"include_removed"} },
4584 {
"wallet",
"listtransactions", &
listtransactions, {
"label|dummy",
"count",
"skip",
"include_watchonly"} },
4585 {
"wallet",
"listunspent", &
listunspent, {
"minconf",
"maxconf",
"addresses",
"include_unsafe",
"query_options"} },
4588 {
"wallet",
"loadwallet", &
loadwallet, {
"filename",
"load_on_startup"} },
4589 {
"wallet",
"lockunspent", &
lockunspent, {
"unlock",
"transactions"} },
4591 {
"wallet",
"rescanblockchain", &
rescanblockchain, {
"start_height",
"stop_height"} },
4592 {
"wallet",
"send", &
send, {
"outputs",
"conf_target",
"estimate_mode",
"fee_rate",
"options"} },
4593 {
"wallet",
"sendmany", &
sendmany, {
"dummy",
"amounts",
"minconf",
"comment",
"subtractfeefrom",
"replaceable",
"conf_target",
"estimate_mode",
"fee_rate",
"verbose"} },
4594 {
"wallet",
"sendtoaddress", &
sendtoaddress, {
"address",
"amount",
"comment",
"comment_to",
"subtractfeefromamount",
"replaceable",
"conf_target",
"estimate_mode",
"avoid_reuse",
"fee_rate",
"verbose"} },
4595 {
"wallet",
"sethdseed", &
sethdseed, {
"newkeypool",
"seed"} },
4596 {
"wallet",
"setlabel", &
setlabel, {
"address",
"label"} },
4597 {
"wallet",
"settxfee", &
settxfee, {
"amount"} },
4598 {
"wallet",
"setwalletflag", &
setwalletflag, {
"flag",
"value"} },
4599 {
"wallet",
"signmessage", &
signmessage, {
"address",
"message"} },
4601 {
"wallet",
"unloadwallet", &
unloadwallet, {
"wallet_name",
"load_on_startup"} },
4603 {
"wallet",
"walletcreatefundedpsbt", &
walletcreatefundedpsbt, {
"inputs",
"outputs",
"locktime",
"options",
"bip32derivs"} },
4605 {
"wallet",
"walletpassphrase", &
walletpassphrase, {
"passphrase",
"timeout"} },
4607 {
"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)