48 static const std::string
HELP_REQUIRING_PASSPHRASE{
"\nRequires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.\n"};
52 bool avoid_reuse = param.
isNull() ? can_avoid_reuse : param.
get_bool();
54 if (avoid_reuse && !can_avoid_reuse) {
68 if (include_watchonly.
isNull()) {
99 std::string wallet_name;
101 std::shared_ptr<CWallet> pwallet =
GetWallet(wallet_name);
106 std::vector<std::shared_ptr<CWallet>> wallets =
GetWallets();
107 if (wallets.size() == 1) {
111 if (wallets.empty()) {
113 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)");
116 "Wallet file not specified (must request wallet RPC through /wallet/<filename> uri-path).");
128 auto wallet_context = util::AnyPtr<WalletContext>(context);
129 if (!wallet_context) {
132 return *wallet_context;
139 if (!spk_man && also_create) {
140 spk_man =
wallet.GetOrCreateLegacyScriptPubKeyMan();
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") {
229 if (!conf_target.
isNull()) {
237 "\nReturns a new Bitcoin address for receiving payments.\n" 238 "If 'label' is specified, it is added to the address book \n" 239 "so payments received with the address will be associated with 'label'.\n",
241 {
"label",
RPCArg::Type::STR,
RPCArg::Default{
""},
"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."},
256 LOCK(pwallet->cs_wallet);
258 if (!pwallet->CanGetAddresses()) {
264 if (!request.params[0].isNull())
267 OutputType output_type = pwallet->m_default_address_type;
268 if (!request.params[1].isNull()) {
279 if (!pwallet->GetNewDestination(output_type, label, dest,
error)) {
291 "\nReturns a new Bitcoin address, for receiving change.\n" 292 "This is for use with raw transactions, NOT normal use.\n",
308 LOCK(pwallet->cs_wallet);
310 if (!pwallet->CanGetAddresses(
true)) {
314 OutputType output_type = pwallet->m_default_change_type.value_or(pwallet->m_default_address_type);
315 if (!request.params[0].isNull()) {
326 if (!pwallet->GetNewChangeDestination(output_type, dest,
error)) {
338 "\nSets the label associated with the given address.\n",
353 LOCK(pwallet->cs_wallet);
362 if (pwallet->IsMine(dest)) {
363 pwallet->SetAddressBook(dest, label,
"receive");
365 pwallet->SetAddressBook(dest, label,
"send");
374 std::set<CTxDestination> destinations;
376 for (
const std::string& address: address_amounts.
getKeys()) {
382 if (destinations.count(dest)) {
385 destinations.insert(dest);
390 bool subtract_fee =
false;
391 for (
unsigned int idx = 0; idx < subtract_fee_outputs.
size(); idx++) {
392 const UniValue& addr = subtract_fee_outputs[idx];
393 if (addr.
get_str() == address) {
398 CRecipient recipient = {script_pub_key, amount, subtract_fee};
418 int nChangePosRet = -1;
422 const bool fCreated =
wallet.CreateTransaction(recipients, tx, nFeeRequired, nChangePosRet,
error, coin_control, fee_calc_out,
true);
426 wallet.CommitTransaction(tx, std::move(map_value), {} );
429 entry.
pushKV(
"txid", tx->GetHash().GetHex());
433 return tx->GetHash().GetHex();
439 "\nSend an amount to a given address." +
445 "This is not part of the transaction, just kept in your wallet."},
447 "to which you're sending the transaction. This is not part of the \n" 448 "transaction, just kept in your wallet."},
450 "The recipient will receive less bitcoins than you enter in the amount field."},
455 {
"avoid_reuse",
RPCArg::Type::BOOL,
RPCArg::Default{
true},
"(only available if avoid_reuse wallet flag is set) Avoid spending from dirty addresses; addresses are considered\n" 456 "dirty if they have previously been used in a transaction. If true, this also activates avoidpartialspends, grouping outputs by their addresses."},
461 RPCResult{
"if verbose is not set or set to false",
475 "\nSend 0.1 BTC with a confirmation target of 6 blocks in economical fee estimate mode using positional arguments\n" 477 "\nSend 0.1 BTC with a fee rate of 1.1 " +
CURRENCY_ATOM +
"/vB, subtract fee from amount, BIP125-replaceable, using positional arguments\n" 479 "\nSend 0.2 BTC with a confirmation target of 6 blocks in economical fee estimate mode using named arguments\n" 481 "\nSend 0.5 BTC with a fee rate of 25 " +
CURRENCY_ATOM +
"/vB using named arguments\n" 483 +
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")
492 pwallet->BlockUntilSyncedToCurrentChain();
494 LOCK(pwallet->cs_wallet);
498 if (!request.params[2].isNull() && !request.params[2].get_str().empty())
499 mapValue[
"comment"] = request.params[2].get_str();
500 if (!request.params[3].isNull() && !request.params[3].get_str().empty())
501 mapValue[
"to"] = request.params[3].get_str();
503 bool fSubtractFeeFromAmount =
false;
504 if (!request.params[4].isNull()) {
505 fSubtractFeeFromAmount = request.params[4].get_bool();
509 if (!request.params[5].isNull()) {
517 SetFeeEstimateMode(*pwallet, coin_control, request.params[6], request.params[7], request.params[9],
false);
522 const std::string address = request.params[0].get_str();
523 address_amounts.
pushKV(address, request.params[1]);
525 if (fSubtractFeeFromAmount) {
526 subtractFeeFromAmount.
push_back(address);
529 std::vector<CRecipient> recipients;
531 const bool verbose{request.params[10].isNull() ? false : request.params[10].get_bool()};
533 return SendMoney(*pwallet, coin_control, recipients, mapValue, verbose);
541 "\nLists groups of addresses which have had their common ownership\n" 542 "made public by common use as inputs or as the resulting change\n" 543 "in past transactions\n",
570 pwallet->BlockUntilSyncedToCurrentChain();
572 LOCK(pwallet->cs_wallet);
575 std::map<CTxDestination, CAmount> balances = pwallet->GetAddressBalances();
576 for (
const std::set<CTxDestination>& grouping : pwallet->GetAddressGroupings()) {
584 const auto* address_book_entry = pwallet->FindAddressBookEntry(address);
585 if (address_book_entry) {
586 addressInfo.
push_back(address_book_entry->GetLabel());
593 return jsonGroupings;
601 "\nSign a message with the private key of an address" +
611 "\nUnlock the wallet for 30 seconds\n" 613 "\nCreate the signature\n" 614 +
HelpExampleCli(
"signmessage",
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"my message\"") +
615 "\nVerify the signature\n" 616 +
HelpExampleCli(
"verifymessage",
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"signature\" \"my message\"") +
617 "\nAs a JSON-RPC call\n" 618 +
HelpExampleRpc(
"signmessage",
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"my message\"")
625 LOCK(pwallet->cs_wallet);
629 std::string strAddress = request.params[0].get_str();
630 std::string strMessage = request.params[1].get_str();
637 const PKHash* pkhash = std::get_if<PKHash>(&dest);
642 std::string signature;
643 SigningResult err = pwallet->SignMessage(strMessage, *pkhash, signature);
657 std::set<CTxDestination> address_set;
662 address_set =
wallet.GetLabelAddresses(label);
670 if (!
wallet.IsMine(script_pub_key)) {
673 address_set.insert(dest);
678 if (!params[1].isNull())
679 min_depth = params[1].get_int();
683 for (
const std::pair<const uint256, CWalletTx>& wtx_pair :
wallet.mapWallet) {
689 for (
const CTxOut& txout : wtx.
tx->vout) {
704 "\nReturns the total amount received by the given address in transactions with at least minconf confirmations.\n",
713 "\nThe amount from transactions with at least 1 confirmation\n" 715 "\nThe amount including unconfirmed transactions, zero confirmations\n" 717 "\nThe amount with at least 6 confirmations\n" 719 "\nAs a JSON-RPC call\n" 729 pwallet->BlockUntilSyncedToCurrentChain();
731 LOCK(pwallet->cs_wallet);
742 "\nReturns the total amount received by addresses with <label> in transactions with at least [minconf] confirmations.\n",
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" 767 pwallet->BlockUntilSyncedToCurrentChain();
769 LOCK(pwallet->cs_wallet);
780 "\nReturns the total available balance.\n" 781 "The available balance is what the wallet considers currently spendable, and is\n" 782 "thus affected by options which limit spendability such as -spendzeroconfchange.\n",
786 {
"include_watchonly",
RPCArg::Type::BOOL,
RPCArg::DefaultHint{
"true for watch-only wallets, otherwise false"},
"Also include balance in watch-only addresses (see 'importaddress')"},
787 {
"avoid_reuse",
RPCArg::Type::BOOL,
RPCArg::Default{
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."},
793 "\nThe total amount in the wallet with 0 or more confirmations\n" 795 "\nThe total amount in the wallet with at least 6 confirmations\n" 797 "\nAs a JSON-RPC call\n" 807 pwallet->BlockUntilSyncedToCurrentChain();
809 LOCK(pwallet->cs_wallet);
811 const UniValue& dummy_value = request.params[0];
817 if (!request.params[1].isNull()) {
818 min_depth = request.params[1].get_int();
825 const auto bal = pwallet->GetBalance(min_depth, avoid_reuse);
827 return ValueFromAmount(bal.m_mine_trusted + (include_watchonly ? bal.m_watchonly_trusted : 0));
835 "DEPRECATED\nIdentical to getbalances().mine.untrusted_pending\n",
846 pwallet->BlockUntilSyncedToCurrentChain();
848 LOCK(pwallet->cs_wallet);
850 return ValueFromAmount(pwallet->GetBalance().m_mine_untrusted_pending);
859 "\nSend multiple times. Amounts are double-precision floating point numbers." +
871 "The fee will be equally deducted from the amount of each selected address.\n" 872 "Those recipients will receive less bitcoins than you enter in their corresponding amount field.\n" 873 "If no addresses are specified here, the sender pays the fee.",
886 RPCResult{
"if verbose is not set or set to false",
888 "the number of addresses." 894 "the number of addresses."},
900 "\nSend two amounts to two different addresses:\n" 902 "\nSend two amounts to two different addresses setting the confirmation and comment:\n" 904 "\nSend two amounts to two different addresses, subtract fee from amount:\n" 906 "\nAs a JSON-RPC call\n" 916 pwallet->BlockUntilSyncedToCurrentChain();
918 LOCK(pwallet->cs_wallet);
920 if (!request.params[0].isNull() && !request.params[0].get_str().empty()) {
926 if (!request.params[3].isNull() && !request.params[3].get_str().empty())
927 mapValue[
"comment"] = request.params[3].
get_str();
930 if (!request.params[4].isNull())
931 subtractFeeFromAmount = request.params[4].
get_array();
934 if (!request.params[5].isNull()) {
938 SetFeeEstimateMode(*pwallet, coin_control, request.params[6], request.params[7], request.params[8],
false);
940 std::vector<CRecipient> recipients;
942 const bool verbose{request.params[9].isNull() ? false : request.params[9].get_bool()};
944 return SendMoney(*pwallet, coin_control, recipients, std::move(mapValue), verbose);
953 "\nAdd an nrequired-to-sign multisignature address to the wallet. Requires a new wallet backup.\n" 954 "Each key is a Bitcoin address or hex-encoded public key.\n" 955 "This functionality is only intended for use with non-watchonly addresses.\n" 956 "See `importaddress` for watchonly p2sh address support.\n" 957 "If 'label' is specified, assign address to that label.\n",
977 "\nAdd a multisig address from 2 addresses\n" 979 "\nAs a JSON-RPC call\n" 992 if (!request.params[2].isNull())
995 int required = request.params[0].get_int();
999 std::vector<CPubKey> pubkeys;
1000 for (
unsigned int i = 0; i < keys_or_addrs.
size(); ++i) {
1001 if (
IsHex(keys_or_addrs[i].get_str()) && (keys_or_addrs[i].
get_str().length() == 66 || keys_or_addrs[i].
get_str().length() == 130)) {
1004 pubkeys.push_back(
AddrToPubKey(spk_man, keys_or_addrs[i].get_str()));
1008 OutputType output_type = pwallet->m_default_address_type;
1009 if (!request.params[3].isNull()) {
1021 pwallet->SetAddressBook(dest, label,
"send");
1029 result.
pushKV(
"descriptor", descriptor->ToString());
1038 int nConf{std::numeric_limits<int>::max()};
1050 if (!params[0].isNull())
1051 nMinDepth = params[0].get_int();
1054 bool fIncludeEmpty =
false;
1055 if (!params[1].isNull())
1056 fIncludeEmpty = params[1].get_bool();
1064 bool has_filtered_address =
false;
1066 if (!by_label && params.size() > 3) {
1071 has_filtered_address =
true;
1075 std::map<CTxDestination, tallyitem> mapTally;
1076 for (
const std::pair<const uint256, CWalletTx>& pairWtx :
wallet.mapWallet) {
1084 if (nDepth < nMinDepth)
1087 for (
const CTxOut& txout : wtx.
tx->vout)
1093 if (has_filtered_address && !(filtered_address == address)) {
1098 if(!(mine & filter))
1112 std::map<std::string, tallyitem> label_tally;
1116 auto start =
wallet.m_address_book.begin();
1117 auto end =
wallet.m_address_book.end();
1119 if (has_filtered_address) {
1120 start =
wallet.m_address_book.find(filtered_address);
1122 end = std::next(start);
1126 for (
auto item_it = start; item_it != end; ++item_it)
1128 if (item_it->second.IsChange())
continue;
1130 const std::string& label = item_it->second.GetLabel();
1131 auto it = mapTally.find(address);
1132 if (it == mapTally.end() && !fIncludeEmpty)
1136 int nConf = std::numeric_limits<int>::max();
1137 bool fIsWatchonly =
false;
1138 if (it != mapTally.end())
1140 nAmount = (*it).second.nAmount;
1141 nConf = (*it).second.nConf;
1142 fIsWatchonly = (*it).second.fIsWatchonly;
1156 obj.
pushKV(
"involvesWatchonly",
true);
1159 obj.
pushKV(
"confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
1160 obj.
pushKV(
"label", label);
1162 if (it != mapTally.end())
1164 for (
const uint256& _item : (*it).second.txids)
1169 obj.
pushKV(
"txids", transactions);
1176 for (
const auto& entry : label_tally)
1178 CAmount nAmount = entry.second.nAmount;
1179 int nConf = entry.second.nConf;
1181 if (entry.second.fIsWatchonly)
1182 obj.
pushKV(
"involvesWatchonly",
true);
1184 obj.
pushKV(
"confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
1185 obj.
pushKV(
"label", entry.first);
1196 "\nList balances by receiving address.\n",
1208 {
RPCResult::Type::BOOL,
"involvesWatchonly",
"Only returns true if imported addresses were involved in transaction"},
1211 {
RPCResult::Type::NUM,
"confirmations",
"The number of confirmations of the most recent transaction included"},
1212 {
RPCResult::Type::STR,
"label",
"The label of the receiving address. The default label is \"\""},
1233 pwallet->BlockUntilSyncedToCurrentChain();
1235 LOCK(pwallet->cs_wallet);
1245 "\nList received transactions by label.\n",
1256 {
RPCResult::Type::BOOL,
"involvesWatchonly",
"Only returns true if imported addresses were involved in transaction"},
1258 {
RPCResult::Type::NUM,
"confirmations",
"The number of confirmations of the most recent transaction included"},
1259 {
RPCResult::Type::STR,
"label",
"The label of the receiving address. The default label is \"\""},
1275 pwallet->BlockUntilSyncedToCurrentChain();
1277 LOCK(pwallet->cs_wallet);
1305 std::list<COutputEntry> listReceived;
1306 std::list<COutputEntry> listSent;
1308 wtx.GetAmounts(listReceived, listSent, nFee, filter_ismine);
1319 entry.
pushKV(
"involvesWatchonly",
true);
1322 entry.
pushKV(
"category",
"send");
1324 const auto* address_book_entry =
wallet.FindAddressBookEntry(s.destination);
1325 if (address_book_entry) {
1326 entry.
pushKV(
"label", address_book_entry->GetLabel());
1328 entry.
pushKV(
"vout", s.vout);
1332 entry.
pushKV(
"abandoned", wtx.isAbandoned());
1333 ret.push_back(entry);
1338 if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth) {
1342 const auto* address_book_entry =
wallet.FindAddressBookEntry(r.destination);
1343 if (address_book_entry) {
1344 label = address_book_entry->GetLabel();
1346 if (filter_label && label != *filter_label) {
1351 entry.
pushKV(
"involvesWatchonly",
true);
1354 if (wtx.IsCoinBase())
1356 if (wtx.GetDepthInMainChain() < 1)
1357 entry.
pushKV(
"category",
"orphan");
1358 else if (wtx.IsImmatureCoinBase())
1359 entry.
pushKV(
"category",
"immature");
1361 entry.
pushKV(
"category",
"generate");
1365 entry.
pushKV(
"category",
"receive");
1368 if (address_book_entry) {
1369 entry.
pushKV(
"label", label);
1371 entry.
pushKV(
"vout", r.vout);
1374 ret.push_back(entry);
1381 return{{
RPCResult::Type::NUM,
"confirmations",
"The number of confirmations for the transaction. Negative confirmations means the\n" 1382 "transaction conflicted that many blocks ago."},
1384 {
RPCResult::Type::BOOL,
"trusted",
"Only present if we consider transaction to be trusted and so safe to spend from."},
1387 {
RPCResult::Type::NUM,
"blockindex",
"The index of the transaction in the block that includes it."},
1396 {
RPCResult::Type::STR,
"comment",
"If a comment is associated with the transaction, only present if not empty."},
1397 {
RPCResult::Type::STR,
"bip125-replaceable",
"(\"yes|no|unknown\") Whether this transaction could be replaced due to BIP125 (replace-by-fee);\n" 1398 "may be unknown for unconfirmed transactions not in the mempool"}};
1404 "\nIf a label name is provided, this will return only incoming transactions paying to addresses with the specified label.\n" 1405 "\nReturns up to 'count' most recent transactions skipping the first 'from' transactions.\n",
1408 "with the specified label, or \"*\" to disable filtering and return all transactions."},
1411 {
"include_watchonly",
RPCArg::Type::BOOL,
RPCArg::DefaultHint{
"true for watch-only wallets, otherwise false"},
"Include transactions to watch-only addresses (see 'importaddress')"},
1418 {
RPCResult::Type::BOOL,
"involvesWatchonly",
"Only returns true if imported addresses were involved in transaction."},
1421 "\"send\" Transactions sent.\n" 1422 "\"receive\" Non-coinbase transactions received.\n" 1423 "\"generate\" Coinbase transactions received with more than 100 confirmations.\n" 1424 "\"immature\" Coinbase transactions received with 100 or fewer confirmations.\n" 1425 "\"orphan\" Orphaned coinbase transactions received."},
1427 "for all other categories"},
1431 "'send' category of transactions."},
1435 {
RPCResult::Type::BOOL,
"abandoned",
"'true' if the transaction has been abandoned (inputs are respendable). Only available for the \n" 1436 "'send' category of transactions."},
1441 "\nList the most recent 10 transactions in the systems\n" 1443 "\nList transactions 100 to 120\n" 1445 "\nAs a JSON-RPC call\n" 1455 pwallet->BlockUntilSyncedToCurrentChain();
1457 const std::string* filter_label =
nullptr;
1458 if (!request.params[0].isNull() && request.params[0].get_str() !=
"*") {
1459 filter_label = &request.params[0].
get_str();
1460 if (filter_label->empty()) {
1465 if (!request.params[1].isNull())
1466 nCount = request.params[1].get_int();
1468 if (!request.params[2].isNull())
1469 nFrom = request.params[2].get_int();
1484 LOCK(pwallet->cs_wallet);
1489 for (CWallet::TxItems::const_reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it)
1493 if ((
int)ret.
size() >= (nCount+nFrom))
break;
1499 if (nFrom > (
int)ret.
size())
1501 if ((nFrom + nCount) > (
int)ret.
size())
1502 nCount = ret.
size() - nFrom;
1504 const std::vector<UniValue>& txs = ret.
getValues();
1506 result.push_backV({ txs.rend() - nFrom - nCount, txs.rend() - nFrom });
1515 "\nGet all transactions in blocks since block [blockhash], or all transactions if omitted.\n" 1516 "If \"blockhash\" is no longer a part of the main chain, transactions from the fork point onward are included.\n" 1517 "Additionally, if include_removed is set, transactions affecting the wallet which were removed are returned in the \"removed\" array.\n",
1520 {
"target_confirmations",
RPCArg::Type::NUM,
RPCArg::Default{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"},
1521 {
"include_watchonly",
RPCArg::Type::BOOL,
RPCArg::DefaultHint{
"true for watch-only wallets, otherwise false"},
"Include transactions to watch-only addresses (see 'importaddress')"},
1523 "(not guaranteed to work on pruned nodes)"},
1532 {
RPCResult::Type::BOOL,
"involvesWatchonly",
"Only returns true if imported addresses were involved in transaction."},
1535 "\"send\" Transactions sent.\n" 1536 "\"receive\" Non-coinbase transactions received.\n" 1537 "\"generate\" Coinbase transactions received with more than 100 confirmations.\n" 1538 "\"immature\" Coinbase transactions received with 100 or fewer confirmations.\n" 1539 "\"orphan\" Orphaned coinbase transactions received."},
1541 "for all other categories"},
1544 "'send' category of transactions."},
1548 {
RPCResult::Type::BOOL,
"abandoned",
"'true' if the transaction has been abandoned (inputs are respendable). Only available for the \n" 1549 "'send' category of transactions."},
1554 {
RPCResult::Type::ARR,
"removed",
"<structure is the same as \"transactions\" above, only present if include_removed=true>\n" 1555 "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." 1557 {
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"},
1562 +
HelpExampleCli(
"listsinceblock",
"\"000000000000000bacf66f7497b7dc45ef753ee9a7d38571037cdb1a57f663ad\" 6")
1563 +
HelpExampleRpc(
"listsinceblock",
"\"000000000000000bacf66f7497b7dc45ef753ee9a7d38571037cdb1a57f663ad\", 6")
1573 wallet.BlockUntilSyncedToCurrentChain();
1577 std::optional<int> height;
1578 std::optional<int> altheight;
1579 int target_confirms = 1;
1583 if (!request.params[0].isNull() && !request.params[0].get_str().empty()) {
1584 blockId =
ParseHashV(request.params[0],
"blockhash");
1592 if (!request.params[1].isNull()) {
1593 target_confirms = request.params[1].get_int();
1595 if (target_confirms < 1) {
1604 bool include_removed = (request.params[3].isNull() || request.params[3].get_bool());
1606 int depth = height ?
wallet.GetLastBlockHeight() + 1 - *height : -1;
1610 for (
const std::pair<const uint256, CWalletTx>& pairWtx :
wallet.mapWallet) {
1621 while (include_removed && altheight && *altheight > *height) {
1627 auto it =
wallet.mapWallet.find(tx->GetHash());
1628 if (it !=
wallet.mapWallet.end()) {
1639 target_confirms = std::min(target_confirms,
wallet.GetLastBlockHeight() + 1);
1643 ret.
pushKV(
"transactions", transactions);
1644 if (include_removed) ret.
pushKV(
"removed", removed);
1655 "\nGet detailed information about in-wallet transaction <txid>\n",
1659 "Whether to include watch-only addresses in balance calculation and details[]"},
1661 "Whether to include a `decoded` field containing the decoded transaction (equivalent to RPC decoderawtransaction)"},
1668 "'send' category of transactions."},
1676 {
RPCResult::Type::BOOL,
"involvesWatchonly",
"Only returns true if imported addresses were involved in transaction."},
1679 "\"send\" Transactions sent.\n" 1680 "\"receive\" Non-coinbase transactions received.\n" 1681 "\"generate\" Coinbase transactions received with more than 100 confirmations.\n" 1682 "\"immature\" Coinbase transactions received with 100 or fewer confirmations.\n" 1683 "\"orphan\" Orphaned coinbase transactions received."},
1688 "'send' category of transactions."},
1689 {
RPCResult::Type::BOOL,
"abandoned",
"'true' if the transaction has been abandoned (inputs are respendable). Only available for the \n" 1690 "'send' category of transactions."},
1694 {
RPCResult::Type::OBJ,
"decoded",
"Optional, the decoded transaction (only present when `verbose` is passed)",
1696 {
RPCResult::Type::ELISION,
"",
"Equivalent to the RPC decoderawtransaction method, or the RPC getrawtransaction method when `verbose` is passed."},
1701 HelpExampleCli(
"gettransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
1702 +
HelpExampleCli(
"gettransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\" true")
1703 +
HelpExampleCli(
"gettransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\" false true")
1704 +
HelpExampleRpc(
"gettransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
1713 pwallet->BlockUntilSyncedToCurrentChain();
1715 LOCK(pwallet->cs_wallet);
1725 bool verbose = request.params[2].isNull() ? false : request.params[2].get_bool();
1728 auto it = pwallet->mapWallet.find(hash);
1729 if (it == pwallet->mapWallet.end()) {
1736 CAmount nNet = nCredit - nDebit;
1747 entry.
pushKV(
"details", details);
1749 std::string strHex =
EncodeHexTx(*wtx.
tx, pwallet->chain().rpcSerializationFlags());
1750 entry.
pushKV(
"hex", strHex);
1754 TxToUniv(*wtx.
tx,
uint256(), pwallet->chain().rpcEnableDeprecated(
"addresses"), decoded,
false);
1755 entry.
pushKV(
"decoded", decoded);
1766 "\nMark in-wallet transaction <txid> as abandoned\n" 1767 "This will mark this transaction and all its in-wallet descendants as abandoned which will allow\n" 1768 "for their inputs to be respent. It can be used to replace \"stuck\" or evicted transactions.\n" 1769 "It only works on transactions which are not included in a block and are not currently in the mempool.\n" 1770 "It has no effect on transactions which are already abandoned.\n",
1776 HelpExampleCli(
"abandontransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
1777 +
HelpExampleRpc(
"abandontransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
1786 pwallet->BlockUntilSyncedToCurrentChain();
1788 LOCK(pwallet->cs_wallet);
1792 if (!pwallet->mapWallet.count(hash)) {
1795 if (!pwallet->AbandonTransaction(hash)) {
1808 "\nSafely copies current wallet file to destination, which can be a directory or a path with filename.\n",
1824 pwallet->BlockUntilSyncedToCurrentChain();
1826 LOCK(pwallet->cs_wallet);
1828 std::string strDest = request.params[0].get_str();
1829 if (!pwallet->BackupWallet(strDest)) {
1842 "\nFills the keypool."+
1861 LOCK(pwallet->cs_wallet);
1864 unsigned int kpSize = 0;
1865 if (!request.params[0].isNull()) {
1866 if (request.params[0].get_int() < 0)
1868 kpSize = (
unsigned int)request.params[0].
get_int();
1872 pwallet->TopUpKeyPool(kpSize);
1874 if (pwallet->GetKeyPoolSize() < kpSize) {
1887 "\nStores the wallet decryption key in memory for 'timeout' seconds.\n" 1888 "This is needed prior to performing transactions related to private keys such as sending bitcoins\n" 1890 "Issuing the walletpassphrase command while the wallet is already unlocked will set a new unlock\n" 1891 "time that overrides the old one.\n",
1898 "\nUnlock the wallet for 60 seconds\n" 1900 "\nLock the wallet again (before 60 seconds)\n" 1902 "\nAs a JSON-RPC call\n" 1912 int64_t relock_time;
1924 strWalletPass.reserve(100);
1927 strWalletPass = request.params[0].get_str().c_str();
1930 nSleepTime = request.params[1].get_int64();
1932 if (nSleepTime < 0) {
1936 constexpr int64_t MAX_SLEEP_TIME = 100000000;
1937 if (nSleepTime > MAX_SLEEP_TIME) {
1938 nSleepTime = MAX_SLEEP_TIME;
1941 if (strWalletPass.empty()) {
1945 if (!pwallet->
Unlock(strWalletPass)) {
1951 pwallet->nRelockTime =
GetTime() + nSleepTime;
1952 relock_time = pwallet->nRelockTime;
1963 std::weak_ptr<CWallet> weak_wallet =
wallet;
1965 if (
auto shared_wallet = weak_wallet.lock()) {
1966 LOCK(shared_wallet->cs_wallet);
1968 if (shared_wallet->nRelockTime != relock_time)
return;
1969 shared_wallet->Lock();
1970 shared_wallet->nRelockTime = 0;
1983 "\nChanges the wallet passphrase from 'oldpassphrase' to 'newpassphrase'.\n",
1990 HelpExampleCli(
"walletpassphrasechange",
"\"old one\" \"new one\"")
1991 +
HelpExampleRpc(
"walletpassphrasechange",
"\"old one\", \"new one\"")
1998 LOCK(pwallet->cs_wallet);
2000 if (!pwallet->IsCrypted()) {
2007 strOldWalletPass.reserve(100);
2008 strOldWalletPass = request.params[0].get_str().c_str();
2011 strNewWalletPass.reserve(100);
2012 strNewWalletPass = request.params[1].get_str().c_str();
2014 if (strOldWalletPass.empty() || strNewWalletPass.empty()) {
2018 if (!pwallet->ChangeWalletPassphrase(strOldWalletPass, strNewWalletPass)) {
2031 "\nRemoves the wallet encryption key from memory, locking the wallet.\n" 2032 "After calling this method, you will need to call walletpassphrase again\n" 2033 "before being able to call any methods which require the wallet to be unlocked.\n",
2037 "\nSet the passphrase for 2 minutes to perform a transaction\n" 2039 "\nPerform a send (requires passphrase set)\n" 2041 "\nClear the passphrase since we are done before 2 minutes is up\n" 2043 "\nAs a JSON-RPC call\n" 2051 LOCK(pwallet->cs_wallet);
2053 if (!pwallet->IsCrypted()) {
2058 pwallet->nRelockTime = 0;
2069 "\nEncrypts the wallet with 'passphrase'. This is for first time encryption.\n" 2070 "After this, any calls that interact with private keys such as sending or signing \n" 2071 "will require the passphrase to be set prior the making these calls.\n" 2072 "Use the walletpassphrase call for this, and then walletlock call.\n" 2073 "If the wallet is already encrypted, use the walletpassphrasechange call.\n",
2079 "\nEncrypt your wallet\n" 2081 "\nNow set the passphrase to use the wallet, such as for signing or sending bitcoin\n" 2083 "\nNow we can do something like sign\n" 2084 +
HelpExampleCli(
"signmessage",
"\"address\" \"test message\"") +
2085 "\nNow lock the wallet again by removing the passphrase\n" 2087 "\nAs a JSON-RPC call\n" 2095 LOCK(pwallet->cs_wallet);
2101 if (pwallet->IsCrypted()) {
2108 strWalletPass.reserve(100);
2109 strWalletPass = request.params[0].get_str().c_str();
2111 if (strWalletPass.empty()) {
2115 if (!pwallet->EncryptWallet(strWalletPass)) {
2119 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.";
2127 "\nUpdates list of temporarily unspendable outputs.\n" 2128 "Temporarily lock (unlock=false) or unlock (unlock=true) specified transaction outputs.\n" 2129 "If no transaction outputs are specified when unlocking then all current locked transaction outputs are unlocked.\n" 2130 "A locked transaction output will not be chosen by automatic coin selection, when spending bitcoins.\n" 2131 "Manually selected coins are automatically unlocked.\n" 2132 "Locks are stored in memory only. Nodes start with zero locked outputs, and the locked output list\n" 2133 "is always cleared (by virtue of process exit) when a node stops or fails.\n" 2134 "Also see the listunspent call\n",
2152 "\nList the unspent transactions\n" 2154 "\nLock an unspent transaction\n" 2155 +
HelpExampleCli(
"lockunspent",
"false \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") +
2156 "\nList the locked transactions\n" 2158 "\nUnlock the transaction again\n" 2159 +
HelpExampleCli(
"lockunspent",
"true \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") +
2160 "\nAs a JSON-RPC call\n" 2161 +
HelpExampleRpc(
"lockunspent",
"false, \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"")
2170 pwallet->BlockUntilSyncedToCurrentChain();
2172 LOCK(pwallet->cs_wallet);
2176 bool fUnlock = request.params[0].get_bool();
2178 if (request.params[1].isNull()) {
2180 pwallet->UnlockAllCoins();
2186 const UniValue& output_params = request.params[1];
2190 std::vector<COutPoint> outputs;
2191 outputs.reserve(output_params.
size());
2193 for (
unsigned int idx = 0; idx < output_params.
size(); idx++) {
2210 const auto it = pwallet->mapWallet.find(outpt.
hash);
2211 if (it == pwallet->mapWallet.end()) {
2217 if (outpt.
n >= trans.
tx->vout.size()) {
2221 if (pwallet->IsSpent(outpt.
hash, outpt.
n)) {
2225 const bool is_locked = pwallet->IsLockedCoin(outpt.
hash, outpt.
n);
2227 if (fUnlock && !is_locked) {
2231 if (!fUnlock && is_locked) {
2235 outputs.push_back(outpt);
2239 for (
const COutPoint& outpt : outputs) {
2240 if (fUnlock) pwallet->UnlockCoin(outpt);
2241 else pwallet->LockCoin(outpt);
2252 "\nReturns list of temporarily unspendable outputs.\n" 2253 "See the lockunspent call to lock and unlock transactions for spending.\n",
2266 "\nList the unspent transactions\n" 2268 "\nLock an unspent transaction\n" 2269 +
HelpExampleCli(
"lockunspent",
"false \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") +
2270 "\nList the locked transactions\n" 2272 "\nUnlock the transaction again\n" 2273 +
HelpExampleCli(
"lockunspent",
"true \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") +
2274 "\nAs a JSON-RPC call\n" 2282 LOCK(pwallet->cs_wallet);
2284 std::vector<COutPoint> vOutpts;
2285 pwallet->ListLockedCoins(vOutpts);
2289 for (
const COutPoint& outpt : vOutpts) {
2292 o.
pushKV(
"txid", outpt.hash.GetHex());
2293 o.
pushKV(
"vout", (
int)outpt.n);
2305 "\nSet the transaction fee rate in " +
CURRENCY_UNIT +
"/kvB for this wallet. Overrides the global -paytxfee command line parameter.\n" 2306 "Can be deactivated by passing 0 as the fee. In that case automatic fee selection will be used by default.\n",
2322 LOCK(pwallet->cs_wallet);
2325 CFeeRate tx_fee_rate(nAmount, 1000);
2326 CFeeRate max_tx_fee_rate(pwallet->m_default_max_tx_fee, 1000);
2329 }
else if (tx_fee_rate < pwallet->chain().relayMinFee()) {
2331 }
else if (tx_fee_rate < pwallet->m_min_fee) {
2333 }
else if (tx_fee_rate > max_tx_fee_rate) {
2337 pwallet->m_pay_tx_fee = tx_fee_rate;
2347 "Returns an object with all balances in " +
CURRENCY_UNIT +
".\n",
2355 {
RPCResult::Type::STR_AMOUNT,
"untrusted_pending",
"untrusted pending balance (outputs created by others that are in the mempool)"},
2357 {
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)"},
2359 {
RPCResult::Type::OBJ,
"watchonly",
"watchonly balances (not present if wallet does not watch anything)",
2362 {
RPCResult::Type::STR_AMOUNT,
"untrusted_pending",
"untrusted pending balance (outputs created by others that are in the mempool)"},
2378 wallet.BlockUntilSyncedToCurrentChain();
2382 const auto bal =
wallet.GetBalance();
2387 balances_mine.pushKV(
"untrusted_pending",
ValueFromAmount(bal.m_mine_untrusted_pending));
2388 balances_mine.pushKV(
"immature",
ValueFromAmount(bal.m_mine_immature));
2392 const auto full_bal =
wallet.GetBalance(0,
false);
2393 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));
2395 balances.pushKV(
"mine", balances_mine);
2397 auto spk_man =
wallet.GetLegacyScriptPubKeyMan();
2398 if (spk_man && spk_man->HaveWatchOnly()) {
2400 balances_watchonly.pushKV(
"trusted",
ValueFromAmount(bal.m_watchonly_trusted));
2401 balances_watchonly.pushKV(
"untrusted_pending",
ValueFromAmount(bal.m_watchonly_untrusted_pending));
2402 balances_watchonly.pushKV(
"immature",
ValueFromAmount(bal.m_watchonly_immature));
2403 balances.pushKV(
"watchonly", balances_watchonly);
2413 "Returns an object containing various wallet state info.\n",
2427 {
RPCResult::Type::NUM,
"keypoolsize",
"how many new keys are pre-generated (only counts external keys)"},
2428 {
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)"},
2429 {
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)"},
2432 {
RPCResult::Type::BOOL,
"private_keys_enabled",
"false if privatekeys are disabled for this wallet (enforced watch-only wallet)"},
2433 {
RPCResult::Type::BOOL,
"avoid_reuse",
"whether this wallet tracks clean/dirty coins in terms of reuse"},
2434 {
RPCResult::Type::OBJ,
"scanning",
"current scanning details, or false if no scan is in progress",
2439 {
RPCResult::Type::BOOL,
"descriptors",
"whether this wallet uses descriptors for scriptPubKey management"},
2453 pwallet->BlockUntilSyncedToCurrentChain();
2455 LOCK(pwallet->cs_wallet);
2459 size_t kpExternalSize = pwallet->KeypoolCountExternalKeys();
2460 const auto bal = pwallet->GetBalance();
2461 int64_t kp_oldest = pwallet->GetOldestKeyPoolTime();
2462 obj.
pushKV(
"walletname", pwallet->GetName());
2463 obj.
pushKV(
"walletversion", pwallet->GetVersion());
2464 obj.
pushKV(
"format", pwallet->GetDatabase().Format());
2468 obj.
pushKV(
"txcount", (
int)pwallet->mapWallet.size());
2469 if (kp_oldest > 0) {
2470 obj.
pushKV(
"keypoololdest", kp_oldest);
2472 obj.
pushKV(
"keypoolsize", (int64_t)kpExternalSize);
2483 obj.
pushKV(
"keypoolsize_hd_internal", (int64_t)(pwallet->GetKeyPoolSize() - kpExternalSize));
2485 if (pwallet->IsCrypted()) {
2486 obj.
pushKV(
"unlocked_until", pwallet->nRelockTime);
2491 if (pwallet->IsScanning()) {
2493 scanning.
pushKV(
"duration", pwallet->ScanningDuration() / 1000);
2494 scanning.
pushKV(
"progress", pwallet->ScanningProgress());
2495 obj.
pushKV(
"scanning", scanning);
2497 obj.
pushKV(
"scanning",
false);
2508 "Returns a list of wallets in the wallet directory.\n",
2531 wallet.pushKV(
"name", path.string());
2536 result.
pushKV(
"wallets", wallets);
2545 "Returns a list of currently loaded wallets.\n" 2546 "For full information on the wallet, use \"getwalletinfo\"\n",
2575 "\nLoads a wallet from a wallet file or directory." 2576 "\nNote that all wallet command-line options used when starting bitcoind will be" 2577 "\napplied to the new wallet (eg -rescan, etc).\n",
2596 const std::string
name(request.params[0].get_str());
2602 std::vector<bilingual_str> warnings;
2603 std::optional<bool> load_on_start = request.params[1].isNull() ? std::nullopt : std::optional<bool>(request.params[1].get_bool());
2634 std::string
flags =
"";
2637 flags += (
flags ==
"" ?
"" :
", ") + it.first;
2640 "\nChange the state of the given wallet flag for a wallet.\n",
2662 std::string flag_str = request.params[0].
get_str();
2663 bool value = request.params[1].isNull() || request.params[1].get_bool();
2677 if (pwallet->IsWalletFlagSet(flag) == value) {
2681 res.pushKV(
"flag_name", flag_str);
2682 res.pushKV(
"flag_state", value);
2685 pwallet->SetWalletFlag(flag);
2687 pwallet->UnsetWalletFlag(flag);
2703 "\nCreates and loads a new wallet.\n",
2709 {
"avoid_reuse",
RPCArg::Type::BOOL,
RPCArg::Default{
false},
"Keep track of coin reuse, and treat dirty and clean coins differently with privacy considerations in mind."},
2710 {
"descriptors",
RPCArg::Type::BOOL,
RPCArg::Default{
false},
"Create a native descriptor wallet. The wallet will use descriptors internally to handle address creation"},
2712 {
"external_signer",
RPCArg::Type::BOOL,
RPCArg::Default{
false},
"Use an external signer such as a hardware wallet. Requires -signer to be configured. Wallet creation will fail if keys cannot be fetched. Requires disable_private_keys and descriptors set to true."},
2717 {
RPCResult::Type::STR,
"name",
"The wallet name if created successfully. If the wallet was created using a full path, the wallet_name will be the full path."},
2724 +
HelpExampleCliNamed(
"createwallet", {{
"wallet_name",
"descriptors"}, {
"avoid_reuse",
true}, {
"descriptors",
true}, {
"load_on_startup",
true}})
2725 +
HelpExampleRpcNamed(
"createwallet", {{
"wallet_name",
"descriptors"}, {
"avoid_reuse",
true}, {
"descriptors",
true}, {
"load_on_startup",
true}})
2731 if (!request.params[1].isNull() && request.params[1].get_bool()) {
2735 if (!request.params[2].isNull() && request.params[2].get_bool()) {
2739 passphrase.reserve(100);
2740 std::vector<bilingual_str> warnings;
2741 if (!request.params[3].isNull()) {
2742 passphrase = request.params[3].get_str().c_str();
2743 if (passphrase.empty()) {
2745 warnings.emplace_back(
Untranslated(
"Empty string given as passphrase, wallet will not be encrypted."));
2749 if (!request.params[4].isNull() && request.params[4].get_bool()) {
2752 if (!request.params[5].isNull() && request.params[5].get_bool()) {
2757 warnings.emplace_back(
Untranslated(
"Wallet is an experimental descriptor wallet"));
2759 if (!request.params[7].isNull() && request.params[7].get_bool()) {
2760 #ifdef ENABLE_EXTERNAL_SIGNER 2779 std::optional<bool> load_on_start = request.params[6].isNull() ? std::nullopt : std::optional<bool>(request.params[6].get_bool());
2780 std::shared_ptr<CWallet>
wallet =
CreateWallet(*context.
chain, request.params[0].get_str(), load_on_start, options, status,
error, warnings);
2798 "Unloads the wallet referenced by the request endpoint otherwise unloads the wallet specified in the argument.\n" 2799 "Specifying the wallet name on a wallet endpoint is invalid.",
2801 {
"wallet_name",
RPCArg::Type::STR,
RPCArg::DefaultHint{
"the wallet name from the RPC endpoint"},
"The name of the wallet to unload. If provided both here and in the RPC endpoint, the two must be identical."},
2813 std::string wallet_name;
2815 if (!(request.params[0].isNull() || request.params[0].get_str() == wallet_name)) {
2819 wallet_name = request.params[0].get_str();
2830 std::vector<bilingual_str> warnings;
2831 std::optional<bool> load_on_start = request.params[1].isNull() ? std::nullopt : std::optional<bool>(request.params[1].get_bool());
2849 "\nReturns array of unspent transaction outputs\n" 2850 "with between minconf and maxconf (inclusive) confirmations.\n" 2851 "Optionally filter to only include txouts paid to specified addresses.\n",
2861 "See description of \"safe\" attribute below."},
2884 {
RPCResult::Type::STR,
"witnessScript",
"witnessScript if the scriptPubKey is P2WSH or P2SH-P2WSH"},
2886 {
RPCResult::Type::BOOL,
"solvable",
"Whether we know how to spend this output, ignoring the lack of keys"},
2887 {
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)"},
2889 {
RPCResult::Type::BOOL,
"safe",
"Whether this output is considered safe to spend. Unconfirmed transactions\n" 2890 "from outside keys and unconfirmed replacement transactions are considered unsafe\n" 2891 "and are not eligible for spending by fundrawtransaction and sendtoaddress."},
2899 +
HelpExampleCli(
"listunspent",
"6 9999999 '[]' true '{ \"minimumAmount\": 0.005 }'")
2900 +
HelpExampleRpc(
"listunspent",
"6, 9999999, [] , true, { \"minimumAmount\": 0.005 } ")
2908 if (!request.params[0].isNull()) {
2910 nMinDepth = request.params[0].get_int();
2913 int nMaxDepth = 9999999;
2914 if (!request.params[1].isNull()) {
2916 nMaxDepth = request.params[1].get_int();
2919 std::set<CTxDestination> destinations;
2920 if (!request.params[2].isNull()) {
2923 for (
unsigned int idx = 0; idx < inputs.
size(); idx++) {
2924 const UniValue& input = inputs[idx];
2929 if (!destinations.insert(dest).second) {
2935 bool include_unsafe =
true;
2936 if (!request.params[3].isNull()) {
2938 include_unsafe = request.params[3].get_bool();
2944 uint64_t nMaximumCount = 0;
2946 if (!request.params[4].isNull()) {
2958 if (options.
exists(
"minimumAmount"))
2961 if (options.
exists(
"maximumAmount"))
2964 if (options.
exists(
"minimumSumAmount"))
2967 if (options.
exists(
"maximumCount"))
2968 nMaximumCount = options[
"maximumCount"].get_int64();
2973 pwallet->BlockUntilSyncedToCurrentChain();
2976 std::vector<COutput> vecOutputs;
2983 LOCK(pwallet->cs_wallet);
2984 pwallet->AvailableCoins(vecOutputs, &cctl, nMinimumAmount, nMaximumAmount, nMinimumSumAmount, nMaximumCount);
2987 LOCK(pwallet->cs_wallet);
2991 for (
const COutput& out : vecOutputs) {
2993 const CScript& scriptPubKey = out.tx->tx->vout[out.i].scriptPubKey;
2995 bool reused = avoid_reuse && pwallet->IsSpentKey(out.tx->GetHash(), out.i);
2997 if (destinations.size() && (!fValidAddress || !destinations.count(address)))
3001 entry.
pushKV(
"txid", out.tx->GetHash().GetHex());
3002 entry.
pushKV(
"vout", out.i);
3004 if (fValidAddress) {
3007 const auto* address_book_entry = pwallet->FindAddressBookEntry(address);
3008 if (address_book_entry) {
3009 entry.
pushKV(
"label", address_book_entry->GetLabel());
3012 std::unique_ptr<SigningProvider> provider = pwallet->GetSolvingProvider(scriptPubKey);
3017 if (provider->GetCScript(hash, redeemScript)) {
3029 if (provider->GetCScript(
id, witnessScript)) {
3039 if (provider->GetCScript(
id, witnessScript)) {
3048 entry.
pushKV(
"confirmations", out.nDepth);
3049 entry.
pushKV(
"spendable", out.fSpendable);
3050 entry.
pushKV(
"solvable", out.fSolvable);
3051 if (out.fSolvable) {
3052 std::unique_ptr<SigningProvider> provider = pwallet->GetSolvingProvider(scriptPubKey);
3055 entry.
pushKV(
"desc", descriptor->ToString());
3058 if (avoid_reuse) entry.
pushKV(
"reused", reused);
3059 entry.
pushKV(
"safe", out.fSafe);
3072 wallet.BlockUntilSyncedToCurrentChain();
3074 change_position = -1;
3075 bool lockUnspents =
false;
3077 std::set<int> setSubtractFeeFromOutputs;
3113 if (options.
exists(
"add_inputs") ) {
3117 if (options.
exists(
"changeAddress") || options.
exists(
"change_address")) {
3118 const std::string change_address_str = (options.
exists(
"change_address") ? options[
"change_address"] : options[
"changeAddress"]).get_str();
3128 if (options.
exists(
"changePosition") || options.
exists(
"change_position")) {
3129 change_position = (options.
exists(
"change_position") ? options[
"change_position"] : options[
"changePosition"]).get_int();
3132 if (options.
exists(
"change_type")) {
3133 if (options.
exists(
"changeAddress") || options.
exists(
"change_address")) {
3143 const UniValue include_watching_option = options.
exists(
"include_watching") ? options[
"include_watching"] : options[
"includeWatching"];
3146 if (options.
exists(
"lockUnspents") || options.
exists(
"lock_unspents")) {
3147 lockUnspents = (options.
exists(
"lock_unspents") ? options[
"lock_unspents"] : options[
"lockUnspents"]).get_bool();
3150 if (options.
exists(
"include_unsafe")) {
3154 if (options.
exists(
"feeRate")) {
3155 if (options.
exists(
"fee_rate")) {
3158 if (options.
exists(
"conf_target")) {
3159 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.");
3161 if (options.
exists(
"estimate_mode")) {
3168 if (options.
exists(
"subtractFeeFromOutputs") || options.
exists(
"subtract_fee_from_outputs") )
3169 subtractFeeFromOutputs = (options.
exists(
"subtract_fee_from_outputs") ? options[
"subtract_fee_from_outputs"] : options[
"subtractFeeFromOutputs"]).get_array();
3171 if (options.
exists(
"replaceable")) {
3174 SetFeeEstimateMode(
wallet, coinControl, options[
"conf_target"], options[
"estimate_mode"], options[
"fee_rate"], override_min_fee);
3181 if (tx.
vout.size() == 0)
3184 if (change_position != -1 && (change_position < 0 || (
unsigned int)change_position > tx.
vout.size()))
3187 for (
unsigned int idx = 0; idx < subtractFeeFromOutputs.
size(); idx++) {
3188 int pos = subtractFeeFromOutputs[idx].
get_int();
3189 if (setSubtractFeeFromOutputs.count(pos))
3193 if (pos >=
int(tx.
vout.size()))
3195 setSubtractFeeFromOutputs.insert(pos);
3200 if (!
wallet.FundTransaction(tx, fee_out, change_position,
error, lockUnspents, setSubtractFeeFromOutputs, coinControl)) {
3208 "\nIf the transaction has no inputs, they will be automatically selected to meet its out value.\n" 3209 "It will add at most one change output to the outputs.\n" 3210 "No existing outputs will be modified unless \"subtractFeeFromOutputs\" is specified.\n" 3211 "Note that inputs which were signed may need to be resigned after completion since in/outputs have been added.\n" 3212 "The inputs added will not be signed, use signrawtransactionwithkey\n" 3213 " or signrawtransactionwithwallet for that.\n" 3214 "Note that all existing inputs must have their previous output transaction be in the wallet.\n" 3215 "Note that all inputs selected must be of standard form and P2SH scripts must be\n" 3216 "in the wallet using importaddress or addmultisigaddress (to calculate fees).\n" 3217 "You can see whether this is the case by checking the \"solvable\" field in the listunspent output.\n" 3218 "Only pay-to-pubkey, multisig, and P2SH versions thereof are currently supported for watch-only\n",
3224 {
"include_unsafe",
RPCArg::Type::BOOL,
RPCArg::Default{
false},
"Include inputs that are not safe to spend (unconfirmed transactions from outside keys and unconfirmed replacement transactions).\n" 3225 "Warning: the resulting transaction may become invalid if one of the unsafe inputs disappears.\n" 3226 "If that happens, you will need to fund the transaction with different inputs and republish it."},
3229 {
"change_type",
RPCArg::Type::STR,
RPCArg::DefaultHint{
"set by -changetype"},
"The output type to use. Only valid if changeAddress is not specified. Options are \"legacy\", \"p2sh-segwit\", and \"bech32\"."},
3231 "Only solvable inputs can be used. Watch-only destinations are solvable if the public key and/or output script was imported,\n" 3232 "e.g. with 'importpubkey' or 'importmulti' with the 'pubkeys' or 'desc' field."},
3237 "The fee will be equally deducted from the amount of each specified output.\n" 3238 "Those recipients will receive less bitcoins than you enter in their corresponding amount field.\n" 3239 "If no outputs are specified here, the sender pays the fee.",
3245 "Allows this transaction to be replaced by a transaction with higher fees"},
3248 " \"" +
FeeModes(
"\"\n\"") +
"\""},
3252 "If iswitness is not present, heuristic tests will be used in decoding.\n" 3253 "If true, only witness deserialization will be tried.\n" 3254 "If false, only non-witness deserialization will be tried.\n" 3255 "This boolean should reflect whether the transaction has inputs\n" 3256 "(e.g. fully valid, or on-chain transactions), if known by the caller." 3268 "\nCreate a transaction with no inputs\n" 3269 +
HelpExampleCli(
"createrawtransaction",
"\"[]\" \"{\\\"myaddress\\\":0.01}\"") +
3270 "\nAdd sufficient unsigned inputs to meet the output value\n" 3271 +
HelpExampleCli(
"fundrawtransaction",
"\"rawtransactionhex\"") +
3272 "\nSign the transaction\n" 3273 +
HelpExampleCli(
"signrawtransactionwithwallet",
"\"fundedtransactionhex\"") +
3274 "\nSend the transaction\n" 3275 +
HelpExampleCli(
"sendrawtransaction",
"\"signedtransactionhex\"")
3282 RPCTypeCheck(request.params, {UniValue::VSTR, UniValueType(), UniValue::VBOOL});
3286 bool try_witness = request.params[2].isNull() ? true : request.params[2].get_bool();
3287 bool try_no_witness = request.params[2].isNull() ? true : !request.params[2].get_bool();
3288 if (!
DecodeHexTx(tx, request.params[0].get_str(), try_no_witness, try_witness)) {
3293 int change_position;
3297 FundTransaction(*pwallet, tx, fee, change_position, request.params[1], coin_control,
true);
3302 result.
pushKV(
"changepos", change_position);
3311 return RPCHelpMan{
"signrawtransactionwithwallet",
3312 "\nSign inputs for raw transaction (serialized, hex-encoded).\n" 3313 "The second optional argument (may be null) is an array of previous transaction outputs that\n" 3314 "this transaction depends on but may not yet be in the block chain." +
3337 " \"ALL|ANYONECANPAY\"\n" 3338 " \"NONE|ANYONECANPAY\"\n" 3339 " \"SINGLE|ANYONECANPAY\""},
3368 RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VARR, UniValue::VSTR},
true);
3371 if (!
DecodeHexTx(mtx, request.params[0].get_str())) {
3376 LOCK(pwallet->cs_wallet);
3380 std::map<COutPoint, Coin> coins;
3381 for (
const CTxIn& txin : mtx.
vin) {
3384 pwallet->chain().findCoins(coins);
3392 std::map<int, std::string> input_errors;
3394 bool complete = pwallet->SignTransaction(mtx, coins, nHashType, input_errors);
3404 const bool want_psbt = method_name ==
"psbtbumpfee";
3408 "\nBumps the fee of an opt-in-RBF transaction T, replacing it with a new transaction B.\n" 3409 + std::string(want_psbt ?
"Returns a PSBT instead of creating and signing a new transaction.\n" :
"") +
3410 "An opt-in RBF transaction with the given txid must be in the wallet.\n" 3411 "The command will pay the additional fee by reducing change outputs or adding inputs when necessary.\n" 3412 "It may add a new change output if one does not already exist.\n" 3413 "All inputs in the original transaction will be included in the replacement transaction.\n" 3414 "The command will fail if the wallet or mempool contains a transaction that spends one of T's outputs.\n" 3415 "By default, the new fee will be calculated automatically using the estimatesmartfee RPC.\n" 3416 "The user can specify a confirmation target for estimatesmartfee.\n" 3417 "Alternatively, the user can specify a fee rate in " +
CURRENCY_ATOM +
"/vB for the new transaction.\n" 3418 "At a minimum, the new fee rate must be high enough to pay an additional new relay fee (incrementalfee\n" 3419 "returned by getnetworkinfo) to enter the node's mempool.\n" 3420 "* WARNING: before version 0.21, fee_rate was in " +
CURRENCY_UNIT +
"/kvB. As of 0.21, fee_rate is in " +
CURRENCY_ATOM +
"/vB. *\n",
3427 "\nSpecify a fee rate in " +
CURRENCY_ATOM +
"/vB instead of relying on the built-in fee estimator.\n" 3428 "Must be at least " + incremental_fee +
" higher than the current transaction fee rate.\n" 3429 "WARNING: before version 0.21, fee_rate was in " +
CURRENCY_UNIT +
"/kvB. As of 0.21, fee_rate is in " +
CURRENCY_ATOM +
"/vB.\n"},
3431 "marked bip-125 replaceable. If true, the sequence numbers in the transaction will\n" 3432 "be left unchanged from the original. If false, any input sequence numbers in the\n" 3433 "original transaction that were less than 0xfffffffe will be increased to 0xfffffffe\n" 3434 "so the new transaction will not be explicitly bip-125 replaceable (though it may\n" 3435 "still be replaceable in practice, for example if it has unconfirmed ancestors which\n" 3436 "are replaceable).\n"},
3445 std::vector<RPCResult>{{
RPCResult::Type::STR,
"psbt",
"The base64-encoded unsigned PSBT of the new transaction."}} :
3457 "\nBump the fee, get the new transaction\'s " + std::string(want_psbt ?
"psbt" :
"txid") +
"\n" +
3466 throw JSONRPCError(
RPC_WALLET_ERROR,
"bumpfee is not available with wallets that have private keys disabled. Use psbtbumpfee instead.");
3469 RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VOBJ});
3477 if (!request.params[1].isNull()) {
3478 UniValue options = request.params[1];
3489 if (options.
exists(
"confTarget") && options.
exists(
"conf_target")) {
3493 auto conf_target = options.
exists(
"confTarget") ? options[
"confTarget"] : options[
"conf_target"];
3495 if (options.
exists(
"replaceable")) {
3498 SetFeeEstimateMode(*pwallet, coin_control, conf_target, options[
"estimate_mode"], options[
"fee_rate"],
false);
3503 pwallet->BlockUntilSyncedToCurrentChain();
3505 LOCK(pwallet->cs_wallet);
3510 std::vector<bilingual_str> errors;
3554 bool complete =
false;
3569 result.
pushKV(
"errors", result_errors);
3582 "\nRescan the local blockchain for wallet related transactions.\n" 3583 "Note: Use \"getwalletinfo\" to query the scanning progress.\n",
3591 {
RPCResult::Type::NUM,
"start_height",
"The block height where the rescan started (the requested height or 0)"},
3592 {
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."},
3609 int start_height = 0;
3610 std::optional<int> stop_height;
3613 LOCK(pwallet->cs_wallet);
3614 int tip_height = pwallet->GetLastBlockHeight();
3616 if (!request.params[0].isNull()) {
3617 start_height = request.params[0].get_int();
3618 if (start_height < 0 || start_height > tip_height) {
3623 if (!request.params[1].isNull()) {
3624 stop_height = request.params[1].get_int();
3625 if (*stop_height < 0 || *stop_height > tip_height) {
3627 }
else if (*stop_height < start_height) {
3633 if (!pwallet->chain().hasBlocks(pwallet->GetLastBlockHash(), start_height, stop_height)) {
3634 throw JSONRPCError(
RPC_MISC_ERROR,
"Can't rescan beyond pruned data. Use RPC call getblockchaininfo to determine your pruned height.");
3641 pwallet->ScanForWalletTransactions(start_block, start_height, stop_height, reserver,
true );
3652 response.
pushKV(
"start_height", start_height);
3667 std::vector<std::vector<unsigned char>> solutions_data;
3678 UniValue wallet_detail = std::visit(*
this, embedded);
3679 subobj.
pushKVs(wallet_detail);
3683 if (subobj.
exists(
"pubkey")) obj.
pushKV(
"pubkey", subobj[
"pubkey"]);
3684 obj.
pushKV(
"embedded", std::move(subobj));
3688 obj.
pushKV(
"sigsrequired", solutions_data[0][0]);
3690 for (
size_t i = 1; i < solutions_data.size() - 1; ++i) {
3691 CPubKey key(solutions_data[i].begin(), solutions_data[i].end());
3694 obj.
pushKV(
"pubkeys", std::move(pubkeys));
3757 std::unique_ptr<SigningProvider> provider =
nullptr;
3758 provider =
wallet.GetSolvingProvider(script);
3778 "\nReturn information about the given bitcoin address.\n" 3779 "Some of the information will only be present if the address is in the active wallet.\n",
3790 {
RPCResult::Type::BOOL,
"solvable",
"If we know how to spend coins sent to this address, ignoring the possible lack of private keys."},
3791 {
RPCResult::Type::STR,
"desc",
true,
"A descriptor for spending coins sent to this address (only when solvable)."},
3792 {
RPCResult::Type::STR,
"parent_desc",
true,
"The descriptor used to derive this address if this is a descriptor wallet"},
3798 {
RPCResult::Type::STR,
"script",
true,
"The output script type. Only if isscript is true and the redeemscript is known. Possible\n" 3799 "types: nonstandard, pubkey, pubkeyhash, scripthash, multisig, nulldata, witness_v0_keyhash,\n" 3800 "witness_v0_scripthash, witness_unknown."},
3802 {
RPCResult::Type::ARR,
"pubkeys",
true,
"Array of pubkeys associated with the known redeemscript (only if script is multisig).",
3806 {
RPCResult::Type::NUM,
"sigsrequired",
true,
"The number of signatures required to spend multisig output (only if script is multisig)."},
3807 {
RPCResult::Type::STR_HEX,
"pubkey",
true,
"The hex value of the raw public key for single-key addresses (possibly embedded in P2SH or P2WSH)."},
3808 {
RPCResult::Type::OBJ,
"embedded",
true,
"Information about the address embedded in P2SH or P2WSH, if relevant and known.",
3810 {
RPCResult::Type::ELISION,
"",
"Includes all getaddressinfo output fields for the embedded address, excluding metadata (timestamp, hdkeypath, hdseedid)\n" 3811 "and relation to the wallet (ismine, iswatchonly)."},
3818 {
RPCResult::Type::ARR,
"labels",
"Array of labels associated with the address. Currently limited to one label but returned\n" 3819 "as an array to keep the API stable if multiple labels are enabled in the future.",
3834 LOCK(pwallet->cs_wallet);
3836 std::string error_msg;
3842 if (error_msg.empty()) error_msg =
"Invalid address";
3850 ret.
pushKV(
"address", currentAddress);
3855 std::unique_ptr<SigningProvider> provider = pwallet->GetSolvingProvider(scriptPubKey);
3862 bool solvable = inferred->IsSolvable() ||
IsSolvable(*provider, scriptPubKey);
3863 ret.
pushKV(
"solvable", solvable);
3865 ret.
pushKV(
"desc", inferred->ToString());
3868 ret.
pushKV(
"solvable",
false);
3874 std::string desc_str;
3876 ret.
pushKV(
"parent_desc", desc_str);
3885 ret.
pushKV(
"ischange", pwallet->IsChange(scriptPubKey));
3889 if (
const std::unique_ptr<CKeyMetadata> meta = spk_man->
GetMetadata(dest)) {
3890 ret.
pushKV(
"timestamp", meta->nCreateTime);
3891 if (meta->has_key_origin) {
3893 ret.
pushKV(
"hdseedid", meta->hd_seed_id.GetHex());
3894 ret.
pushKV(
"hdmasterfingerprint",
HexStr(meta->key_origin.fingerprint));
3905 const auto* address_book_entry = pwallet->FindAddressBookEntry(dest);
3906 if (address_book_entry) {
3907 labels.
push_back(address_book_entry->GetLabel());
3909 ret.
pushKV(
"labels", std::move(labels));
3919 "\nReturns the list of addresses assigned the specified label.\n",
3928 {
RPCResult::Type::STR,
"purpose",
"Purpose of address (\"send\" for sending address, \"receive\" for receiving address)"},
3941 LOCK(pwallet->cs_wallet);
3947 std::set<std::string> addresses;
3948 for (
const std::pair<const CTxDestination, CAddressBookData>& item : pwallet->m_address_book) {
3949 if (item.second.IsChange())
continue;
3950 if (item.second.GetLabel() == label) {
3955 bool unique = addresses.emplace(address).second;
3977 "\nReturns the list of all labels, or labels that are assigned to addresses with a specific purpose.\n",
3988 "\nList all labels\n" 3990 "\nList labels that have receiving addresses\n" 3992 "\nList labels that have sending addresses\n" 3994 "\nAs a JSON-RPC call\n" 4002 LOCK(pwallet->cs_wallet);
4004 std::string purpose;
4005 if (!request.params[0].isNull()) {
4006 purpose = request.params[0].get_str();
4010 std::set<std::string> label_set;
4011 for (
const std::pair<const CTxDestination, CAddressBookData>& entry : pwallet->m_address_book) {
4012 if (entry.second.IsChange())
continue;
4013 if (purpose.empty() || entry.second.purpose == purpose) {
4014 label_set.insert(entry.second.GetLabel());
4019 for (
const std::string&
name : label_set) {
4031 "\nEXPERIMENTAL warning: this call may be changed in future releases.\n" 4032 "\nSend a transaction.\n",
4035 "That is, each address can only appear once and there can only be one 'data' object.\n" 4036 "For convenience, a dictionary, which holds the key-value pairs directly, is also accepted.",
4052 " \"" +
FeeModes(
"\"\n\"") +
"\""},
4057 {
"include_unsafe",
RPCArg::Type::BOOL,
RPCArg::Default{
false},
"Include inputs that are not safe to spend (unconfirmed transactions from outside keys and unconfirmed replacement transactions).\n" 4058 "Warning: the resulting transaction may become invalid if one of the unsafe inputs disappears.\n" 4059 "If that happens, you will need to fund the transaction with different inputs and republish it."},
4060 {
"add_to_wallet",
RPCArg::Type::BOOL,
RPCArg::Default{
true},
"When false, returns a serialized transaction which will not be added to the wallet or broadcast"},
4063 {
"change_type",
RPCArg::Type::STR,
RPCArg::DefaultHint{
"set by -changetype"},
"The output type to use. Only valid if change_address is not specified. Options are \"legacy\", \"p2sh-segwit\", and \"bech32\"."},
4066 " \"" +
FeeModes(
"\"\n\"") +
"\""},
4069 "Only solvable inputs can be used. Watch-only destinations are solvable if the public key and/or output script was imported,\n" 4070 "e.g. with 'importpubkey' or 'importmulti' with the 'pubkeys' or 'desc' field."},
4082 "The fee will be equally deducted from the amount of each specified output.\n" 4083 "Those recipients will receive less bitcoins than you enter in their corresponding amount field.\n" 4084 "If no outputs are specified here, the sender pays the fee.",
4090 "Allows this transaction to be replaced by a transaction with higher fees"},
4098 {
RPCResult::Type::STR_HEX,
"txid",
"The transaction id for the send. Only 1 transaction is created regardless of the number of addresses."},
4100 {
RPCResult::Type::STR,
"psbt",
"If more signatures are needed, or if add_to_wallet is false, the base64-encoded (partially) signed transaction"}
4104 "\nSend 0.1 BTC with a confirmation target of 6 blocks in economical fee estimate mode\n" 4106 "Send 0.2 BTC with a fee rate of 1.1 " +
CURRENCY_ATOM +
"/vB using positional arguments\n" 4108 "Send 0.2 BTC with a fee rate of 1 " +
CURRENCY_ATOM +
"/vB using the options argument\n" 4110 "Send 0.3 BTC with a fee rate of 25 " +
CURRENCY_ATOM +
"/vB using named arguments\n" 4112 "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" 4113 +
HelpExampleCli(
"send",
"'{\"" +
EXAMPLE_ADDRESS[0] +
"\": 0.1}' 1 economical '{\"add_to_wallet\": false, \"inputs\": [{\"txid\":\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\", \"vout\":1}]}'")
4130 if (options.exists(
"conf_target") || options.exists(
"estimate_mode")) {
4131 if (!request.params[1].isNull() || !request.params[2].isNull()) {
4135 options.pushKV(
"conf_target", request.params[1]);
4136 options.pushKV(
"estimate_mode", request.params[2]);
4138 if (options.exists(
"fee_rate")) {
4139 if (!request.params[3].isNull()) {
4143 options.pushKV(
"fee_rate", request.params[3]);
4145 if (!options[
"conf_target"].isNull() && (options[
"estimate_mode"].isNull() || (options[
"estimate_mode"].get_str() ==
"unset"))) {
4148 if (options.exists(
"feeRate")) {
4151 if (options.exists(
"changeAddress")) {
4154 if (options.exists(
"changePosition")) {
4157 if (options.exists(
"includeWatching")) {
4160 if (options.exists(
"lockUnspents")) {
4163 if (options.exists(
"subtractFeeFromOutputs")) {
4167 const bool psbt_opt_in = options.exists(
"psbt") && options[
"psbt"].get_bool();
4170 int change_position;
4171 bool rbf = pwallet->m_signal_rbf;
4172 if (options.exists(
"replaceable")) {
4173 rbf = options[
"replaceable"].get_bool();
4180 FundTransaction(*pwallet, rawTx, fee, change_position, options, coin_control,
false);
4182 bool add_to_wallet =
true;
4183 if (options.exists(
"add_to_wallet")) {
4184 add_to_wallet = options[
"add_to_wallet"].get_bool();
4204 if (psbt_opt_in || !complete || !add_to_wallet) {
4212 std::string err_string;
4215 result.
pushKV(
"txid", tx->GetHash().GetHex());
4216 if (add_to_wallet && !psbt_opt_in) {
4217 pwallet->CommitTransaction(tx, {}, {} );
4219 result.
pushKV(
"hex", hex);
4222 result.
pushKV(
"complete", complete);
4232 "\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" 4233 "HD will have a new HD seed set so that new keys added to the keypool will be derived from this new seed.\n" 4234 "\nNote that you will need to MAKE A NEW BACKUP of your wallet after setting the HD wallet seed." +
4237 {
"newkeypool",
RPCArg::Type::BOOL,
RPCArg::Default{
true},
"Whether to flush old unused addresses, including change addresses, from the keypool and regenerate it.\n" 4238 "If true, the next address from getnewaddress and change address from getrawchangeaddress will be from this new seed.\n" 4239 "If false, addresses (including change addresses if the wallet already had HD Chain Split enabled) from the existing\n" 4240 "keypool will be used until it has been depleted."},
4242 "The seed value can be retrieved using the dumpwallet command. It is the private key marked hdseed=1"},
4265 if (!pwallet->CanSupportFeature(
FEATURE_HD)) {
4266 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");
4271 bool flush_key_pool =
true;
4272 if (!request.params[0].isNull()) {
4273 flush_key_pool = request.params[0].get_bool();
4277 if (request.params[1].isNull()) {
4303 "\nUpdate a PSBT with input information from our wallet and then sign inputs\n" 4304 "that we can sign for." +
4314 " \"ALL|ANYONECANPAY\"\n" 4315 " \"NONE|ANYONECANPAY\"\n" 4316 " \"SINGLE|ANYONECANPAY\""},
4337 wallet.BlockUntilSyncedToCurrentChain();
4339 RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL, UniValue::VSTR});
4352 bool sign = request.params[1].isNull() ? true : request.params[1].get_bool();
4353 bool bip32derivs = request.params[3].isNull() ? true : request.params[3].get_bool();
4354 bool complete =
true;
4364 result.
pushKV(
"complete", complete);
4374 "\nCreates and funds a transaction in the Partially Signed Transaction format.\n" 4375 "Implements the Creator and Updater roles.\n",
4389 "That is, each address can only appear once and there can only be one 'data' object.\n" 4390 "For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also\n" 4391 "accepted as second parameter.",
4409 {
"include_unsafe",
RPCArg::Type::BOOL,
RPCArg::Default{
false},
"Include inputs that are not safe to spend (unconfirmed transactions from outside keys and unconfirmed replacement transactions).\n" 4410 "Warning: the resulting transaction may become invalid if one of the unsafe inputs disappears.\n" 4411 "If that happens, you will need to fund the transaction with different inputs and republish it."},
4414 {
"change_type",
RPCArg::Type::STR,
RPCArg::DefaultHint{
"set by -changetype"},
"The output type to use. Only valid if changeAddress is not specified. Options are \"legacy\", \"p2sh-segwit\", and \"bech32\"."},
4420 "The fee will be equally deducted from the amount of each specified output.\n" 4421 "Those recipients will receive less bitcoins than you enter in their corresponding amount field.\n" 4422 "If no outputs are specified here, the sender pays the fee.",
4428 "Allows this transaction to be replaced by a transaction with higher fees"},
4431 " \"" +
FeeModes(
"\"\n\"") +
"\""},
4445 "\nCreate a transaction with no inputs\n" 4446 +
HelpExampleCli(
"walletcreatefundedpsbt",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
4456 wallet.BlockUntilSyncedToCurrentChain();
4468 int change_position;
4469 bool rbf{
wallet.m_signal_rbf};
4470 const UniValue &replaceable_arg = request.params[3][
"replaceable"];
4471 if (!replaceable_arg.
isNull()) {
4473 rbf = replaceable_arg.
isTrue();
4486 bool bip32derivs = request.params[4].isNull() ? true : request.params[4].get_bool();
4487 bool complete =
true;
4500 result.
pushKV(
"changepos", change_position);
4509 "\nUpgrade the wallet. Upgrades to the latest version if no version number is specified.\n" 4510 "New keys may be generated and a new wallet backup will need to be made.",
4538 if (!request.params[0].isNull()) {
4539 version = request.params[0].get_int();
4542 const int previous_version{pwallet->GetVersion()};
4543 const bool wallet_upgraded{pwallet->UpgradeWallet(version,
error)};
4544 const int current_version{pwallet->GetVersion()};
4547 if (wallet_upgraded) {
4548 if (previous_version == current_version) {
4549 result =
"Already at latest version. Wallet version unchanged.";
4551 result =
strprintf(
"Wallet upgraded successfully from version %i to version %i.", previous_version, current_version);
4556 obj.
pushKV(
"wallet_name", pwallet->GetName());
4557 obj.
pushKV(
"previous_version", previous_version);
4558 obj.
pushKV(
"current_version", current_version);
4559 if (!result.empty()) {
4560 obj.
pushKV(
"result", result);
4570 #ifdef ENABLE_EXTERNAL_SIGNER 4574 "Display address on an external signer for verification.",
4605 result.
pushKV(
"address", request.params[0].get_str());
4610 #endif // ENABLE_EXTERNAL_SIGNER 4676 {
"wallet", &
send, },
4688 #ifdef ENABLE_EXTERNAL_SIGNER 4690 #endif // ENABLE_EXTERNAL_SIGNER std::shared_ptr< const CTransaction > CTransactionRef
No wallet specified (error when there are multiple wallets loaded)
CPubKey AddrToPubKey(const FillableSigningProvider &keystore, const std::string &addr_in)
static UniValue ListReceived(const CWallet &wallet, const UniValue ¶ms, bool by_label) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
Helper for findBlock to selectively return pieces of block data.
static RPCHelpMan bumpfee_helper(std::string method_name)
RPCHelpMan signrawtransactionwithwallet()
bool DisplayAddress(const CTxDestination &dest) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Display address on an external signer.
bool NewKeyPool()
Mark old keypool keys as used, and generate all new keys.
static RPCHelpMan setlabel()
const CHDChain & GetHDChain() const
void RPCTypeCheck(const UniValue ¶ms, const std::list< UniValueType > &typesExpected, bool fAllowNull)
Type-check arguments; throws JSONRPCError if wrong type given.
UniValue operator()(const CNoDestination &dest) const
bool SignTransaction(CWallet &wallet, CMutableTransaction &mtx)
Sign the new transaction,.
const std::vector< UniValue > & getValues() const
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.
bool RemoveWallet(const std::shared_ptr< CWallet > &wallet, std::optional< bool > load_on_start, std::vector< bilingual_str > &warnings)
static RPCHelpMan listreceivedbylabel()
UniValue operator()(const ScriptHash &scripthash) const
bool fAllowWatchOnly
Includes watch only addresses which are solvable.
Enter the wallet passphrase with walletpassphrase first.
RPCHelpMan importpubkey()
static RPCHelpMan walletpassphrasechange()
UniValue operator()(const WitnessV0ScriptHash &id) const
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.
void EnsureWalletIsUnlocked(const CWallet &wallet)
std::shared_ptr< CWallet > GetWallet(const std::string &name)
void ParseRecipients(const UniValue &address_amounts, const UniValue &subtract_fee_outputs, std::vector< CRecipient > &recipients)
Either this tx or a mempool ancestor signals rbf.
static RPCHelpMan walletdisplayaddress()
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.
const std::string & GetLabel() const
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.
bool IsPayToScriptHash() const
static RPCHelpMan sendmany()
RecursiveMutex cs_KeyStore
bool IsFromMe(const isminefilter &filter) const
void SignTransactionResultToJSON(CMutableTransaction &mtx, bool complete, const std::map< COutPoint, Coin > &coins, const std::map< int, std::string > &input_errors, UniValue &result)
Unconfirmed tx that does not signal rbf and is not in the mempool.
CPubKey GetPubKey() const
Compute the public key from a private key.
static UniValue AddressBookDataToJSON(const CAddressBookData &data, const bool verbose)
Convert CAddressBookData to JSON record.
std::vector< uint256 > txids
static RPCHelpMan getwalletinfo()
std::optional< int > last_scanned_height
static RPCHelpMan getbalance()
static RPCHelpMan getrawchangeaddress()
static RPCHelpMan listsinceblock()
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()
const std::string UNIX_EPOCH_TIME
String used to describe UNIX epoch time in documentation, factored out to a constant for consistency...
#define CHECK_NONFATAL(condition)
Throw a NonFatalCheckError when the condition evaluates to false.
static RPCHelpMan listwalletdir()
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
CAmount GetCredit(const isminefilter &filter) const
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 void ListTransactions(const CWallet &wallet, const CWalletTx &wtx, int nMinDepth, bool fLong, UniValue &ret, const isminefilter &filter_ismine, const std::string *filter_label) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
List transactions based on the given criteria.
static RPCHelpMan psbtbumpfee()
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)
const std::string & get_str() const
int m_min_depth
Minimum chain depth value for coin availability.
Use sat/vB fee rate unit.
static RPCHelpMan listwallets()
static RPCHelpMan gettransaction()
const UniValue & get_array() const
static RPCHelpMan sethdseed()
CTxDestination DecodeDestination(const std::string &str, std::string &error_msg)
A version of CTransaction with the PSBT format.
Double ended buffer combining vector and stream-like interfaces.
Indicates that the wallet needs an external signer.
std::string SigningResultString(const SigningResult res)
static RPCHelpMan listaddressgroupings()
bool pushKVs(const UniValue &obj)
const std::vector< std::string > & getKeys() const
const SigningProvider *const provider
const unsigned char * begin() const
CMutableTransaction ConstructTransaction(const UniValue &inputs_in, const UniValue &outputs_in, const UniValue &locktime, bool rbf)
Create a transaction from univalue parameters.
Taproot only; implied when sighash byte is missing, and equivalent to SIGHASH_ALL.
bool FinalizeAndExtractPSBT(PartiallySignedTransaction &psbtx, CMutableTransaction &result)
Finalizes a PSBT if possible, and extracts it to a CMutableTransaction if it could be finalized...
This same wallet is already loaded.
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
bool fOverrideFeeRate
Override automatic min/max checks on fee, m_feerate must be set if true.
static RPCHelpMan walletlock()
static RPCHelpMan signmessage()
Invalid, missing or duplicate parameter.
static RPCHelpMan settxfee()
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.
mapValue_t mapValue
Key/value map with information about the transaction.
static RPCHelpMan walletpassphrase()
interfaces::Chain & chain() const
Interface for accessing chain state.
int64_t CAmount
Amount in satoshis (Can be negative)
bool m_avoid_partial_spends
Avoid partial use of funds sent to a given address.
UniValue operator()(const WitnessV1Taproot &id) const
static RPCHelpMan abandontransaction()
CPubKey GenerateNewSeed()
The wallet passphrase entered was incorrect.
Special type that is a STR with only hex chars.
std::string EncodeBase64(Span< const unsigned char > input)
void push_back(const T &value)
UniValue SendMoney(CWallet &wallet, const CCoinControl &coin_control, std::vector< CRecipient > &recipients, mapValue_t map_value, bool verbose)
static const std::map< std::string, WalletFlags > WALLET_FLAG_MAP
static const std::string WALLET_ENDPOINT_BASE
UniValue JSONRPCError(int code, const std::string &message)
bool push_back(const UniValue &val)
std::shared_ptr< CWallet > LoadWallet(interfaces::Chain &chain, const std::string &name, std::optional< bool > load_on_start, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error, std::vector< bilingual_str > &warnings)
fs::path GetWalletDir()
Get the path of the wallet directory.
Special string with only hex chars.
static RPCHelpMan bumpfee()
const std::string CURRENCY_ATOM
RPCHelpMan listdescriptors()
static CAmount AmountFromValue(const UniValue &value)
virtual bool GetPubKey(const CKeyID &address, CPubKey &pubkey) const
RPCHelpMan importwallet()
std::string GetTxnOutputType(TxoutType t)
Get the name of a TxoutType as a string.
void ProcessSubScript(const CScript &subscript, UniValue &obj) const
WalletContext & EnsureWalletContext(const std::any &context)
int ParseSighashString(const UniValue &sighash)
An input of a transaction.
bool DecodeBase64PSBT(PartiallySignedTransaction &psbt, const std::string &base64_tx, std::string &error)
Decode a base64ed PSBT into a PartiallySignedTransaction.
static RPCHelpMan unloadwallet()
CTxDestination subtype to encode any future Witness version.
static RPCHelpMan loadwallet()
bool m_add_inputs
If false, only selected inputs are used.
enum JSONRPCRequest::Mode mode
bool exists(const std::string &key) const
Special array that has a fixed number of entries.
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 ToString(const FeeEstimateMode &fee_estimate_mode=FeeEstimateMode::BTC_KVB) const
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
bool IsHex(const std::string &str)
void SetHDSeed(const CPubKey &key)
Unexpected type was passed as parameter.
Special type where the user must set the keys e.g. to define multiple addresses; as opposed to e...
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.".
UniValue operator()(const PKHash &pkhash) const
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()
const std::string CURRENCY_UNIT
bool m_avoid_address_reuse
Forbids inclusion of dirty (previously used) addresses.
static RPCHelpMan upgradewallet()
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
General application defined errors.
static const std::string HELP_REQUIRING_PASSPHRASE
void TxToUniv(const CTransaction &tx, const uint256 &hashBlock, bool include_addresses, UniValue &entry, bool include_hex=true, int serialize_flags=0, const CTxUndo *txundo=nullptr)
bool pushKV(const std::string &key, const UniValue &val)
isminetype
IsMine() return codes, which depend on ScriptPubKeyMan implementation.
void FundTransaction(CWallet &wallet, CMutableTransaction &tx, CAmount &fee_out, int &change_position, const UniValue &options, CCoinControl &coinControl, bool override_min_fee)
bool m_include_unsafe_inputs
If false, only safe inputs will be used.
An output of a transaction.
bool IsCompressed() const
Check whether the public key corresponding to this private key is (to be) compressed.
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
const std::string InvalidEstimateModeErrorMessage()
const uint256 & GetHash() const
std::optional< bool > m_signal_bip125_rbf
Override the wallet's m_signal_rbf if set.
Invalid wallet specified.
An outpoint - a combination of a transaction hash and an index n into its vout.
void UnloadWallet(std::shared_ptr< CWallet > &&wallet)
Explicitly unload and delete the wallet.
std::vector< CTxOut > vout
void Set(const T pbegin, const T pend, bool fCompressedIn)
Initialize using begin and end iterators to byte data.
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)
std::map< std::string, std::string > mapValue_t
const std::map< uint64_t, std::string > WALLET_FLAG_CAVEATS
Special numeric to denote unix epoch time.
virtual bool GetCScript(const CScriptID &scriptid, CScript &script) const
static UniValue DescribeWalletAddress(const CWallet &wallet, const CTxDestination &dest)
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)
static CTransactionRef MakeTransactionRef(Tx &&txIn)
RPC method is deprecated.
bool IsSolvable(const SigningProvider &provider, const CScript &script)
CRIPEMD160 & Write(const unsigned char *data, size_t len)
static RPCHelpMan lockunspent()
RPCHelpMan importdescriptors()
static constexpr uint64_t MUTABLE_WALLET_FLAGS
std::vector< std::shared_ptr< CWallet > > GetWallets()
static RPCHelpMan getunconfirmedbalance()
Failed to encrypt the wallet.
std::string FormatMoney(const CAmount n)
Money parsing/formatting utilities.
std::optional< unsigned int > m_confirm_target
Override the default confirmation target if set.
Optional argument with default value omitted because they are implicitly clear.
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.
std::optional< CFeeRate > m_feerate
Override the wallet's m_pay_tx_fee if set.
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.
virtual std::unique_ptr< CKeyMetadata > GetMetadata(const CTxDestination &dest) const
Result CommitTransaction(CWallet &wallet, const uint256 &txid, CMutableTransaction &&mtx, std::vector< bilingual_str > &errors, uint256 &bumped_txid)
Commit the bumpfee transaction.
interfaces::Chain * chain
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 std::string & GetName() const
Get a name for this wallet for logging/debugging purposes.
Special string to represent a floating point amount.
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()
UniValue operator()(const WitnessUnknown &id) const
int64_t GetTxTime() const
bool TopUpKeyPool(unsigned int kpSize=0)
static const int PROTOCOL_VERSION
network protocol versioning
Not enough funds in wallet or account.
bool GetDescriptorString(std::string &out) const
std::string WriteHDKeypath(const std::vector< uint32_t > &keypath)
Write HD keypaths as strings.
const UniValue & get_obj() const
const unsigned char * end() 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)
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.
bool DecodeHexTx(CMutableTransaction &tx, const std::string &hex_tx, bool try_no_witness=false, bool try_witness=true)
int GetDepthInMainChain() const NO_THREAD_SAFETY_ANALYSIS
Return depth of transaction in blockchain: <0 : conflicts with a transaction this deep in the blockch...
std::string GetHex() const
UniValue ValueFromAmount(const CAmount amount)
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.
CAmount GetDebit(const isminefilter &filter) const
filter decides which addresses will count towards the debit
const UniValue NullUniValue
#define AssertLockNotHeld(cs)
static bool GetAvoidReuseFlag(const CWallet &wallet, const UniValue ¶m)
UrlDecodeFn *const URL_DECODE
CPubKey DeriveNewSeed(const CKey &key)
UniValue operator()(const WitnessV0KeyHash &id) const
RecursiveMutex cs_wallet
Main wallet lock.
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)
std::vector< fs::path > ListDatabases(const fs::path &wallet_dir)
Recursively list database paths in directory.
Standard JSON-RPC 2.0 errors.
A mutable version of CTransaction.
static RPCHelpMan backupwallet()
SecureString create_passphrase
static RPCHelpMan getreceivedbyaddress()
static RPCHelpMan walletprocesspsbt()
UniValue JSONRPCTransactionError(TransactionError terr, const std::string &err_string)
FeeEstimateMode m_fee_mode
Fee estimation mode to control arguments to estimateSmartFee.
std::optional< OutputType > m_change_type
Override the default change type if set, ignored if destChange is set.
FoundBlock & height(int &height)
static RPCHelpMan encryptwallet()
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. ...
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.
Special dictionary with keys that are not literals.
CKey DecodeSecret(const std::string &str)
std::string HelpExampleRpcNamed(const std::string &methodname, const RPCArgList &args)
void Finalize(unsigned char hash[OUTPUT_SIZE])
void __pushKV(const std::string &key, const UniValue &val)
static RPCHelpMan listtransactions()
Indicate that this wallet supports DescriptorScriptPubKeyMan.
CKeyID seed_id
seed hash160
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
bool ParseOutputType(const std::string &type, OutputType &output_type)
bool Unlock(const CKeyingMaterial &vMasterKeyIn, bool accept_no_keys=false)
bool error(const char *fmt, const Args &... args)
std::string StringForFeeReason(FeeReason reason)
const std::string EXAMPLE_ADDRESS[2]
Example bech32 addresses for the RPCExamples help documentation.
enum CWallet::ScanResult::@16 status
Wrapper for UniValue::VType, which includes typeAny: Used to denote don't care type.
std::shared_ptr< CWallet > CreateWallet(interfaces::Chain &chain, const std::string &name, std::optional< bool > load_on_start, DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error, std::vector< bilingual_str > &warnings)
CPubKey HexToPubKey(const std::string &hex_in)
Error parsing or validating structure in raw format.
bool IsPayToWitnessScriptHash() const
static RPCHelpMan listreceivedbyaddress()
A hasher class for RIPEMD-160.
CKeyID ToKeyID(const PKHash &key_hash)
std::string HelpExampleCliNamed(const std::string &methodname, const RPCArgList &args)
bool IsValid() const
Check whether this private key is valid.
Special type to denote elision (...)
V Cat(V v1, V &&v2)
Concatenate two vectors, moving elements.
static RPCHelpMan addmultisigaddress()
Span< A > constexpr MakeSpan(A(&a)[N])
MakeSpan for arrays:
bool IsCompressed() const
Check whether this is a compressed public key.
uint256 ParseHashO(const UniValue &o, std::string strKey)
static bool ParseIncludeWatchonly(const UniValue &include_watchonly, const CWallet &wallet)
Used by RPC commands that have an include_watchonly parameter.