62 int confirms =
wallet.GetTxDepthInMainChain(wtx);
63 entry.
pushKV(
"confirmations", confirms);
65 entry.
pushKV(
"generated",
true);
68 entry.
pushKV(
"blockhash", conf->confirmed_block_hash.GetHex());
69 entry.
pushKV(
"blockheight", conf->confirmed_block_height);
70 entry.
pushKV(
"blockindex", conf->position_in_block);
73 entry.
pushKV(
"blocktime", block_time);
82 entry.
pushKV(
"walletconflicts", conflicts);
87 std::string rbfStatus =
"no";
91 rbfStatus =
"unknown";
95 entry.
pushKV(
"bip125-replaceable", rbfStatus);
97 for (
const std::pair<const std::string, std::string>& item : wtx.
mapValue)
98 entry.
pushKV(item.first, item.second);
118 if (!conf_target.
isNull()) {
119 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.");
121 if (!estimate_mode.
isNull() && estimate_mode.
get_str() !=
"unset") {
134 if (!conf_target.
isNull()) {
142 "\nReturns a new Bitcoin address for receiving payments.\n"
143 "If 'label' is specified, it is added to the address book \n"
144 "so payments received with the address will be associated with 'label'.\n",
146 {
"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."},
147 {
"address_type",
RPCArg::Type::STR,
RPCArg::DefaultHint{
"set by -addresstype"},
"The address type to use. Options are \"legacy\", \"p2sh-segwit\", \"bech32\", and \"bech32m\"."},
161 LOCK(pwallet->cs_wallet);
163 if (!pwallet->CanGetAddresses()) {
169 if (!request.params[0].isNull())
172 OutputType output_type = pwallet->m_default_address_type;
173 if (!request.params[1].isNull()) {
174 std::optional<OutputType> parsed =
ParseOutputType(request.params[1].get_str());
180 output_type = parsed.value();
185 if (!pwallet->GetNewDestination(output_type, label, dest,
error)) {
197 "\nReturns a new Bitcoin address, for receiving change.\n"
198 "This is for use with raw transactions, NOT normal use.\n",
200 {
"address_type",
RPCArg::Type::STR,
RPCArg::DefaultHint{
"set by -changetype"},
"The address type to use. Options are \"legacy\", \"p2sh-segwit\", \"bech32\", and \"bech32m\"."},
214 LOCK(pwallet->cs_wallet);
216 if (!pwallet->CanGetAddresses(
true)) {
220 OutputType output_type = pwallet->m_default_change_type.value_or(pwallet->m_default_address_type);
221 if (!request.params[0].isNull()) {
222 std::optional<OutputType> parsed =
ParseOutputType(request.params[0].get_str());
228 output_type = parsed.value();
233 if (!pwallet->GetNewChangeDestination(output_type, dest,
error)) {
245 "\nSets the label associated with the given address.\n",
260 LOCK(pwallet->cs_wallet);
269 if (pwallet->IsMine(dest)) {
270 pwallet->SetAddressBook(dest, label,
"receive");
272 pwallet->SetAddressBook(dest, label,
"send");
281 std::set<CTxDestination> destinations;
283 for (
const std::string& address: address_amounts.
getKeys()) {
289 if (destinations.count(dest)) {
292 destinations.insert(dest);
297 bool subtract_fee =
false;
298 for (
unsigned int idx = 0; idx < subtract_fee_outputs.
size(); idx++) {
299 const UniValue& addr = subtract_fee_outputs[idx];
300 if (addr.
get_str() == address) {
305 CRecipient recipient = {script_pub_key, amount, subtract_fee};
325 int nChangePosRet = -1;
333 wallet.CommitTransaction(tx, std::move(map_value), {} );
336 entry.
pushKV(
"txid", tx->GetHash().GetHex());
340 return tx->GetHash().GetHex();
346 "\nSend an amount to a given address." +
352 "This is not part of the transaction, just kept in your wallet."},
354 "to which you're sending the transaction. This is not part of the \n"
355 "transaction, just kept in your wallet."},
357 "The recipient will receive less bitcoins than you enter in the amount field."},
362 {
"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"
363 "dirty if they have previously been used in a transaction. If true, this also activates avoidpartialspends, grouping outputs by their addresses."},
368 RPCResult{
"if verbose is not set or set to false",
382 "\nSend 0.1 BTC with a confirmation target of 6 blocks in economical fee estimate mode using positional arguments\n"
384 "\nSend 0.1 BTC with a fee rate of 1.1 " +
CURRENCY_ATOM +
"/vB, subtract fee from amount, BIP125-replaceable, using positional arguments\n"
386 "\nSend 0.2 BTC with a confirmation target of 6 blocks in economical fee estimate mode using named arguments\n"
388 "\nSend 0.5 BTC with a fee rate of 25 " +
CURRENCY_ATOM +
"/vB using named arguments\n"
390 +
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")
399 pwallet->BlockUntilSyncedToCurrentChain();
401 LOCK(pwallet->cs_wallet);
405 if (!request.params[2].isNull() && !request.params[2].get_str().empty())
406 mapValue[
"comment"] = request.params[2].get_str();
407 if (!request.params[3].isNull() && !request.params[3].get_str().empty())
408 mapValue[
"to"] = request.params[3].get_str();
410 bool fSubtractFeeFromAmount =
false;
411 if (!request.params[4].isNull()) {
412 fSubtractFeeFromAmount = request.params[4].get_bool();
416 if (!request.params[5].isNull()) {
424 SetFeeEstimateMode(*pwallet, coin_control, request.params[6], request.params[7], request.params[9],
false);
429 const std::string address = request.params[0].get_str();
430 address_amounts.
pushKV(address, request.params[1]);
432 if (fSubtractFeeFromAmount) {
433 subtractFeeFromAmount.
push_back(address);
436 std::vector<CRecipient> recipients;
438 const bool verbose{request.params[10].isNull() ? false : request.params[10].get_bool()};
440 return SendMoney(*pwallet, coin_control, recipients, mapValue, verbose);
448 "\nLists groups of addresses which have had their common ownership\n"
449 "made public by common use as inputs or as the resulting change\n"
450 "in past transactions\n",
477 pwallet->BlockUntilSyncedToCurrentChain();
479 LOCK(pwallet->cs_wallet);
491 const auto* address_book_entry = pwallet->FindAddressBookEntry(address);
492 if (address_book_entry) {
493 addressInfo.
push_back(address_book_entry->GetLabel());
500 return jsonGroupings;
507 std::set<CTxDestination> address_set;
512 address_set =
wallet.GetLabelAddresses(label);
520 if (!
wallet.IsMine(script_pub_key)) {
523 address_set.insert(dest);
528 if (!params[1].isNull())
529 min_depth = params[1].get_int();
533 for (
const std::pair<const uint256, CWalletTx>& wtx_pair :
wallet.mapWallet) {
539 for (
const CTxOut& txout : wtx.
tx->vout) {
554 "\nReturns the total amount received by the given address in transactions with at least minconf confirmations.\n",
563 "\nThe amount from transactions with at least 1 confirmation\n"
565 "\nThe amount including unconfirmed transactions, zero confirmations\n"
567 "\nThe amount with at least 6 confirmations\n"
569 "\nAs a JSON-RPC call\n"
579 pwallet->BlockUntilSyncedToCurrentChain();
581 LOCK(pwallet->cs_wallet);
592 "\nReturns the total amount received by addresses with <label> in transactions with at least [minconf] confirmations.\n",
601 "\nAmount received by the default label with at least 1 confirmation\n"
603 "\nAmount received at the tabby label including unconfirmed amounts with zero confirmations\n"
605 "\nThe amount with at least 6 confirmations\n"
607 "\nAs a JSON-RPC call\n"
617 pwallet->BlockUntilSyncedToCurrentChain();
619 LOCK(pwallet->cs_wallet);
630 "\nReturns the total available balance.\n"
631 "The available balance is what the wallet considers currently spendable, and is\n"
632 "thus affected by options which limit spendability such as -spendzeroconfchange.\n",
636 {
"include_watchonly",
RPCArg::Type::BOOL,
RPCArg::DefaultHint{
"true for watch-only wallets, otherwise false"},
"Also include balance in watch-only addresses (see 'importaddress')"},
637 {
"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."},
643 "\nThe total amount in the wallet with 0 or more confirmations\n"
645 "\nThe total amount in the wallet with at least 6 confirmations\n"
647 "\nAs a JSON-RPC call\n"
657 pwallet->BlockUntilSyncedToCurrentChain();
659 LOCK(pwallet->cs_wallet);
661 const UniValue& dummy_value = request.params[0];
667 if (!request.params[1].isNull()) {
668 min_depth = request.params[1].get_int();
675 const auto bal =
GetBalance(*pwallet, min_depth, avoid_reuse);
677 return ValueFromAmount(bal.m_mine_trusted + (include_watchonly ? bal.m_watchonly_trusted : 0));
685 "DEPRECATED\nIdentical to getbalances().mine.untrusted_pending\n",
696 pwallet->BlockUntilSyncedToCurrentChain();
698 LOCK(pwallet->cs_wallet);
709 "\nSend multiple times. Amounts are double-precision floating point numbers." +
721 "The fee will be equally deducted from the amount of each selected address.\n"
722 "Those recipients will receive less bitcoins than you enter in their corresponding amount field.\n"
723 "If no addresses are specified here, the sender pays the fee.",
736 RPCResult{
"if verbose is not set or set to false",
738 "the number of addresses."
744 "the number of addresses."},
750 "\nSend two amounts to two different addresses:\n"
752 "\nSend two amounts to two different addresses setting the confirmation and comment:\n"
754 "\nSend two amounts to two different addresses, subtract fee from amount:\n"
756 "\nAs a JSON-RPC call\n"
766 pwallet->BlockUntilSyncedToCurrentChain();
768 LOCK(pwallet->cs_wallet);
770 if (!request.params[0].isNull() && !request.params[0].get_str().empty()) {
776 if (!request.params[3].isNull() && !request.params[3].get_str().empty())
777 mapValue[
"comment"] = request.params[3].
get_str();
780 if (!request.params[4].isNull())
781 subtractFeeFromAmount = request.params[4].
get_array();
784 if (!request.params[5].isNull()) {
788 SetFeeEstimateMode(*pwallet, coin_control, request.params[6], request.params[7], request.params[8],
false);
790 std::vector<CRecipient> recipients;
792 const bool verbose{request.params[9].isNull() ? false : request.params[9].get_bool()};
794 return SendMoney(*pwallet, coin_control, recipients, std::move(mapValue), verbose);
803 "\nAdd an nrequired-to-sign multisignature address to the wallet. Requires a new wallet backup.\n"
804 "Each key is a Bitcoin address or hex-encoded public key.\n"
805 "This functionality is only intended for use with non-watchonly addresses.\n"
806 "See `importaddress` for watchonly p2sh address support.\n"
807 "If 'label' is specified, assign address to that label.\n",
827 "\nAdd a multisig address from 2 addresses\n"
829 "\nAs a JSON-RPC call\n"
842 if (!request.params[2].isNull())
845 int required = request.params[0].get_int();
849 std::vector<CPubKey> pubkeys;
850 for (
unsigned int i = 0; i < keys_or_addrs.
size(); ++i) {
851 if (
IsHex(keys_or_addrs[i].get_str()) && (keys_or_addrs[i].get_str().length() == 66 || keys_or_addrs[i].get_str().length() == 130)) {
854 pubkeys.push_back(
AddrToPubKey(spk_man, keys_or_addrs[i].get_str()));
858 OutputType output_type = pwallet->m_default_address_type;
859 if (!request.params[3].isNull()) {
860 std::optional<OutputType> parsed =
ParseOutputType(request.params[3].get_str());
866 output_type = parsed.value();
872 pwallet->SetAddressBook(dest, label,
"send");
880 result.
pushKV(
"descriptor", descriptor->ToString());
889 int nConf{std::numeric_limits<int>::max()};
901 if (!params[0].isNull())
902 nMinDepth = params[0].get_int();
905 bool fIncludeEmpty =
false;
906 if (!params[1].isNull())
907 fIncludeEmpty = params[1].get_bool();
915 bool has_filtered_address =
false;
917 if (!by_label && params.size() > 3) {
922 has_filtered_address =
true;
926 std::map<CTxDestination, tallyitem> mapTally;
927 for (
const std::pair<const uint256, CWalletTx>& pairWtx :
wallet.mapWallet) {
934 int nDepth =
wallet.GetTxDepthInMainChain(wtx);
935 if (nDepth < nMinDepth)
938 for (
const CTxOut& txout : wtx.
tx->vout)
944 if (has_filtered_address && !(filtered_address == address)) {
963 std::map<std::string, tallyitem> label_tally;
967 auto start =
wallet.m_address_book.begin();
968 auto end =
wallet.m_address_book.end();
970 if (has_filtered_address) {
971 start =
wallet.m_address_book.find(filtered_address);
973 end = std::next(start);
977 for (
auto item_it = start; item_it != end; ++item_it)
979 if (item_it->second.IsChange())
continue;
981 const std::string& label = item_it->second.GetLabel();
982 auto it = mapTally.find(address);
983 if (it == mapTally.end() && !fIncludeEmpty)
987 int nConf = std::numeric_limits<int>::max();
988 bool fIsWatchonly =
false;
989 if (it != mapTally.end())
991 nAmount = (*it).second.nAmount;
992 nConf = (*it).second.nConf;
993 fIsWatchonly = (*it).second.fIsWatchonly;
1007 obj.
pushKV(
"involvesWatchonly",
true);
1010 obj.
pushKV(
"confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
1011 obj.
pushKV(
"label", label);
1013 if (it != mapTally.end())
1015 for (
const uint256& _item : (*it).second.txids)
1020 obj.
pushKV(
"txids", transactions);
1027 for (
const auto& entry : label_tally)
1029 CAmount nAmount = entry.second.nAmount;
1030 int nConf = entry.second.nConf;
1032 if (entry.second.fIsWatchonly)
1033 obj.
pushKV(
"involvesWatchonly",
true);
1035 obj.
pushKV(
"confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
1036 obj.
pushKV(
"label", entry.first);
1047 "\nList balances by receiving address.\n",
1059 {
RPCResult::Type::BOOL,
"involvesWatchonly",
true,
"Only returns true if imported addresses were involved in transaction"},
1062 {
RPCResult::Type::NUM,
"confirmations",
"The number of confirmations of the most recent transaction included"},
1063 {
RPCResult::Type::STR,
"label",
"The label of the receiving address. The default label is \"\""},
1084 pwallet->BlockUntilSyncedToCurrentChain();
1086 LOCK(pwallet->cs_wallet);
1096 "\nList received transactions by label.\n",
1107 {
RPCResult::Type::BOOL,
"involvesWatchonly",
true,
"Only returns true if imported addresses were involved in transaction"},
1109 {
RPCResult::Type::NUM,
"confirmations",
"The number of confirmations of the most recent transaction included"},
1110 {
RPCResult::Type::STR,
"label",
"The label of the receiving address. The default label is \"\""},
1126 pwallet->BlockUntilSyncedToCurrentChain();
1128 LOCK(pwallet->cs_wallet);
1156 std::list<COutputEntry> listReceived;
1157 std::list<COutputEntry> listSent;
1170 entry.
pushKV(
"involvesWatchonly",
true);
1173 entry.
pushKV(
"category",
"send");
1175 const auto* address_book_entry =
wallet.FindAddressBookEntry(s.destination);
1176 if (address_book_entry) {
1177 entry.
pushKV(
"label", address_book_entry->GetLabel());
1179 entry.
pushKV(
"vout", s.vout);
1183 entry.
pushKV(
"abandoned", wtx.isAbandoned());
1184 ret.push_back(entry);
1189 if (listReceived.size() > 0 &&
wallet.GetTxDepthInMainChain(wtx) >= nMinDepth) {
1193 const auto* address_book_entry =
wallet.FindAddressBookEntry(r.destination);
1194 if (address_book_entry) {
1195 label = address_book_entry->GetLabel();
1197 if (filter_label && label != *filter_label) {
1202 entry.
pushKV(
"involvesWatchonly",
true);
1205 if (wtx.IsCoinBase())
1207 if (
wallet.GetTxDepthInMainChain(wtx) < 1)
1208 entry.
pushKV(
"category",
"orphan");
1209 else if (
wallet.IsTxImmatureCoinBase(wtx))
1210 entry.
pushKV(
"category",
"immature");
1212 entry.
pushKV(
"category",
"generate");
1216 entry.
pushKV(
"category",
"receive");
1219 if (address_book_entry) {
1220 entry.
pushKV(
"label", label);
1222 entry.
pushKV(
"vout", r.vout);
1225 ret.push_back(entry);
1232 return{{
RPCResult::Type::NUM,
"confirmations",
"The number of confirmations for the transaction. Negative confirmations means the\n"
1233 "transaction conflicted that many blocks ago."},
1234 {
RPCResult::Type::BOOL,
"generated",
true,
"Only present if the transaction's only input is a coinbase one."},
1235 {
RPCResult::Type::BOOL,
"trusted",
true,
"Whether we consider the transaction to be trusted and safe to spend from.\n"
1236 "Only present when the transaction has 0 confirmations (or negative confirmations, if conflicted)."},
1239 {
RPCResult::Type::NUM,
"blockindex",
true,
"The index of the transaction in the block that includes it."},
1252 {
RPCResult::Type::STR,
"comment",
true,
"If a comment is associated with the transaction, only present if not empty."},
1253 {
RPCResult::Type::STR,
"bip125-replaceable",
"(\"yes|no|unknown\") Whether this transaction could be replaced due to BIP125 (replace-by-fee);\n"
1254 "may be unknown for unconfirmed transactions not in the mempool."}};
1260 "\nIf a label name is provided, this will return only incoming transactions paying to addresses with the specified label.\n"
1261 "\nReturns up to 'count' most recent transactions skipping the first 'from' transactions.\n",
1264 "with the specified label, or \"*\" to disable filtering and return all transactions."},
1267 {
"include_watchonly",
RPCArg::Type::BOOL,
RPCArg::DefaultHint{
"true for watch-only wallets, otherwise false"},
"Include transactions to watch-only addresses (see 'importaddress')"},
1274 {
RPCResult::Type::BOOL,
"involvesWatchonly",
true,
"Only returns true if imported addresses were involved in transaction."},
1277 "\"send\" Transactions sent.\n"
1278 "\"receive\" Non-coinbase transactions received.\n"
1279 "\"generate\" Coinbase transactions received with more than 100 confirmations.\n"
1280 "\"immature\" Coinbase transactions received with 100 or fewer confirmations.\n"
1281 "\"orphan\" Orphaned coinbase transactions received."},
1283 "for all other categories"},
1287 "'send' category of transactions."},
1291 {
RPCResult::Type::BOOL,
"abandoned",
true,
"'true' if the transaction has been abandoned (inputs are respendable). Only available for the \n"
1292 "'send' category of transactions."},
1297 "\nList the most recent 10 transactions in the systems\n"
1299 "\nList transactions 100 to 120\n"
1301 "\nAs a JSON-RPC call\n"
1311 pwallet->BlockUntilSyncedToCurrentChain();
1313 const std::string* filter_label =
nullptr;
1314 if (!request.params[0].isNull() && request.params[0].get_str() !=
"*") {
1315 filter_label = &request.params[0].
get_str();
1316 if (filter_label->empty()) {
1321 if (!request.params[1].isNull())
1322 nCount = request.params[1].get_int();
1324 if (!request.params[2].isNull())
1325 nFrom = request.params[2].get_int();
1340 LOCK(pwallet->cs_wallet);
1345 for (CWallet::TxItems::const_reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it)
1349 if ((
int)ret.
size() >= (nCount+nFrom))
break;
1355 if (nFrom > (
int)ret.
size())
1357 if ((nFrom + nCount) > (
int)ret.
size())
1358 nCount = ret.
size() - nFrom;
1360 const std::vector<UniValue>& txs = ret.
getValues();
1362 result.push_backV({ txs.rend() - nFrom - nCount, txs.rend() - nFrom });
1371 "\nGet all transactions in blocks since block [blockhash], or all transactions if omitted.\n"
1372 "If \"blockhash\" is no longer a part of the main chain, transactions from the fork point onward are included.\n"
1373 "Additionally, if include_removed is set, transactions affecting the wallet which were removed are returned in the \"removed\" array.\n",
1376 {
"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"},
1377 {
"include_watchonly",
RPCArg::Type::BOOL,
RPCArg::DefaultHint{
"true for watch-only wallets, otherwise false"},
"Include transactions to watch-only addresses (see 'importaddress')"},
1379 "(not guaranteed to work on pruned nodes)"},
1388 {
RPCResult::Type::BOOL,
"involvesWatchonly",
true,
"Only returns true if imported addresses were involved in transaction."},
1391 "\"send\" Transactions sent.\n"
1392 "\"receive\" Non-coinbase transactions received.\n"
1393 "\"generate\" Coinbase transactions received with more than 100 confirmations.\n"
1394 "\"immature\" Coinbase transactions received with 100 or fewer confirmations.\n"
1395 "\"orphan\" Orphaned coinbase transactions received."},
1397 "for all other categories"},
1400 "'send' category of transactions."},
1404 {
RPCResult::Type::BOOL,
"abandoned",
true,
"'true' if the transaction has been abandoned (inputs are respendable). Only available for the \n"
1405 "'send' category of transactions."},
1409 {
RPCResult::Type::ARR,
"removed",
true,
"<structure is the same as \"transactions\" above, only present if include_removed=true>\n"
1410 "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."
1412 {
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"},
1417 +
HelpExampleCli(
"listsinceblock",
"\"000000000000000bacf66f7497b7dc45ef753ee9a7d38571037cdb1a57f663ad\" 6")
1418 +
HelpExampleRpc(
"listsinceblock",
"\"000000000000000bacf66f7497b7dc45ef753ee9a7d38571037cdb1a57f663ad\", 6")
1428 wallet.BlockUntilSyncedToCurrentChain();
1432 std::optional<int> height;
1433 std::optional<int> altheight;
1434 int target_confirms = 1;
1438 if (!request.params[0].isNull() && !request.params[0].get_str().empty()) {
1439 blockId =
ParseHashV(request.params[0],
"blockhash");
1447 if (!request.params[1].isNull()) {
1448 target_confirms = request.params[1].get_int();
1450 if (target_confirms < 1) {
1459 bool include_removed = (request.params[3].isNull() || request.params[3].get_bool());
1461 int depth = height ?
wallet.GetLastBlockHeight() + 1 - *height : -1;
1465 for (
const std::pair<const uint256, CWalletTx>& pairWtx :
wallet.mapWallet) {
1468 if (depth == -1 || abs(
wallet.GetTxDepthInMainChain(tx)) < depth) {
1476 while (include_removed && altheight && *altheight > *height) {
1482 auto it =
wallet.mapWallet.find(tx->GetHash());
1483 if (it !=
wallet.mapWallet.end()) {
1494 target_confirms = std::min(target_confirms,
wallet.GetLastBlockHeight() + 1);
1498 ret.
pushKV(
"transactions", transactions);
1499 if (include_removed) ret.
pushKV(
"removed", removed);
1510 "\nGet detailed information about in-wallet transaction <txid>\n",
1514 "Whether to include watch-only addresses in balance calculation and details[]"},
1516 "Whether to include a `decoded` field containing the decoded transaction (equivalent to RPC decoderawtransaction)"},
1523 "'send' category of transactions."},
1531 {
RPCResult::Type::BOOL,
"involvesWatchonly",
true,
"Only returns true if imported addresses were involved in transaction."},
1534 "\"send\" Transactions sent.\n"
1535 "\"receive\" Non-coinbase transactions received.\n"
1536 "\"generate\" Coinbase transactions received with more than 100 confirmations.\n"
1537 "\"immature\" Coinbase transactions received with 100 or fewer confirmations.\n"
1538 "\"orphan\" Orphaned coinbase transactions received."},
1543 "'send' category of transactions."},
1544 {
RPCResult::Type::BOOL,
"abandoned",
true,
"'true' if the transaction has been abandoned (inputs are respendable). Only available for the \n"
1545 "'send' category of transactions."},
1549 {
RPCResult::Type::OBJ,
"decoded",
true,
"The decoded transaction (only present when `verbose` is passed)",
1551 {
RPCResult::Type::ELISION,
"",
"Equivalent to the RPC decoderawtransaction method, or the RPC getrawtransaction method when `verbose` is passed."},
1556 HelpExampleCli(
"gettransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
1557 +
HelpExampleCli(
"gettransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\" true")
1558 +
HelpExampleCli(
"gettransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\" false true")
1559 +
HelpExampleRpc(
"gettransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
1568 pwallet->BlockUntilSyncedToCurrentChain();
1570 LOCK(pwallet->cs_wallet);
1580 bool verbose = request.params[2].isNull() ? false : request.params[2].get_bool();
1583 auto it = pwallet->mapWallet.find(hash);
1584 if (it == pwallet->mapWallet.end()) {
1591 CAmount nNet = nCredit - nDebit;
1602 entry.
pushKV(
"details", details);
1604 std::string strHex =
EncodeHexTx(*wtx.
tx, pwallet->chain().rpcSerializationFlags());
1605 entry.
pushKV(
"hex", strHex);
1610 entry.
pushKV(
"decoded", decoded);
1621 "\nMark in-wallet transaction <txid> as abandoned\n"
1622 "This will mark this transaction and all its in-wallet descendants as abandoned which will allow\n"
1623 "for their inputs to be respent. It can be used to replace \"stuck\" or evicted transactions.\n"
1624 "It only works on transactions which are not included in a block and are not currently in the mempool.\n"
1625 "It has no effect on transactions which are already abandoned.\n",
1631 HelpExampleCli(
"abandontransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
1632 +
HelpExampleRpc(
"abandontransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
1641 pwallet->BlockUntilSyncedToCurrentChain();
1643 LOCK(pwallet->cs_wallet);
1647 if (!pwallet->mapWallet.count(hash)) {
1650 if (!pwallet->AbandonTransaction(hash)) {
1662 "\nFills the keypool."+
1681 LOCK(pwallet->cs_wallet);
1684 unsigned int kpSize = 0;
1685 if (!request.params[0].isNull()) {
1686 if (request.params[0].get_int() < 0)
1688 kpSize = (
unsigned int)request.params[0].get_int();
1692 pwallet->TopUpKeyPool(kpSize);
1694 if (pwallet->GetKeyPoolSize() < kpSize) {
1707 "\nEntirely clears and refills the keypool."+
1720 LOCK(pwallet->cs_wallet);
1733 "\nUpdates list of temporarily unspendable outputs.\n"
1734 "Temporarily lock (unlock=false) or unlock (unlock=true) specified transaction outputs.\n"
1735 "If no transaction outputs are specified when unlocking then all current locked transaction outputs are unlocked.\n"
1736 "A locked transaction output will not be chosen by automatic coin selection, when spending bitcoins.\n"
1737 "Manually selected coins are automatically unlocked.\n"
1738 "Locks are stored in memory only, unless persistent=true, in which case they will be written to the\n"
1739 "wallet database and loaded on node start. Unwritten (persistent=false) locks are always cleared\n"
1740 "(by virtue of process exit) when a node stops or fails. Unlocking will clear both persistent and not.\n"
1741 "Also see the listunspent call\n",
1754 {
"persistent",
RPCArg::Type::BOOL,
RPCArg::Default{
false},
"Whether to write/erase this lock in the wallet database, or keep the change in memory only. Ignored for unlocking."},
1760 "\nList the unspent transactions\n"
1762 "\nLock an unspent transaction\n"
1763 +
HelpExampleCli(
"lockunspent",
"false \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") +
1764 "\nList the locked transactions\n"
1766 "\nUnlock the transaction again\n"
1767 +
HelpExampleCli(
"lockunspent",
"true \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") +
1768 "\nLock the transaction persistently in the wallet database\n"
1769 +
HelpExampleCli(
"lockunspent",
"false \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\" true") +
1770 "\nAs a JSON-RPC call\n"
1771 +
HelpExampleRpc(
"lockunspent",
"false, \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"")
1780 pwallet->BlockUntilSyncedToCurrentChain();
1782 LOCK(pwallet->cs_wallet);
1786 bool fUnlock = request.params[0].get_bool();
1788 const bool persistent{request.params[2].isNull() ? false : request.params[2].get_bool()};
1790 if (request.params[1].isNull()) {
1792 if (!pwallet->UnlockAllCoins())
1800 const UniValue& output_params = request.params[1];
1804 std::vector<COutPoint> outputs;
1805 outputs.reserve(output_params.
size());
1807 for (
unsigned int idx = 0; idx < output_params.
size(); idx++) {
1824 const auto it = pwallet->mapWallet.find(outpt.
hash);
1825 if (it == pwallet->mapWallet.end()) {
1831 if (outpt.
n >= trans.
tx->vout.size()) {
1835 if (pwallet->IsSpent(outpt.
hash, outpt.
n)) {
1839 const bool is_locked = pwallet->IsLockedCoin(outpt.
hash, outpt.
n);
1841 if (fUnlock && !is_locked) {
1845 if (!fUnlock && is_locked && !persistent) {
1849 outputs.push_back(outpt);
1852 std::unique_ptr<WalletBatch> batch =
nullptr;
1854 if (fUnlock || persistent) batch = std::make_unique<WalletBatch>(pwallet->GetDatabase());
1857 for (
const COutPoint& outpt : outputs) {
1873 "\nReturns list of temporarily unspendable outputs.\n"
1874 "See the lockunspent call to lock and unlock transactions for spending.\n",
1887 "\nList the unspent transactions\n"
1889 "\nLock an unspent transaction\n"
1890 +
HelpExampleCli(
"lockunspent",
"false \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") +
1891 "\nList the locked transactions\n"
1893 "\nUnlock the transaction again\n"
1894 +
HelpExampleCli(
"lockunspent",
"true \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") +
1895 "\nAs a JSON-RPC call\n"
1903 LOCK(pwallet->cs_wallet);
1905 std::vector<COutPoint> vOutpts;
1906 pwallet->ListLockedCoins(vOutpts);
1910 for (
const COutPoint& outpt : vOutpts) {
1913 o.
pushKV(
"txid", outpt.hash.GetHex());
1914 o.
pushKV(
"vout", (
int)outpt.n);
1926 "\nSet the transaction fee rate in " +
CURRENCY_UNIT +
"/kvB for this wallet. Overrides the global -paytxfee command line parameter.\n"
1927 "Can be deactivated by passing 0 as the fee. In that case automatic fee selection will be used by default.\n",
1943 LOCK(pwallet->cs_wallet);
1946 CFeeRate tx_fee_rate(nAmount, 1000);
1947 CFeeRate max_tx_fee_rate(pwallet->m_default_max_tx_fee, 1000);
1950 }
else if (tx_fee_rate < pwallet->chain().relayMinFee()) {
1952 }
else if (tx_fee_rate < pwallet->m_min_fee) {
1954 }
else if (tx_fee_rate > max_tx_fee_rate) {
1958 pwallet->m_pay_tx_fee = tx_fee_rate;
1968 "Returns an object with all balances in " +
CURRENCY_UNIT +
".\n",
1976 {
RPCResult::Type::STR_AMOUNT,
"untrusted_pending",
"untrusted pending balance (outputs created by others that are in the mempool)"},
1978 {
RPCResult::Type::STR_AMOUNT,
"used",
true,
"(only present if avoid_reuse is set) balance from coins sent to addresses that were previously spent from (potentially privacy violating)"},
1980 {
RPCResult::Type::OBJ,
"watchonly",
true,
"watchonly balances (not present if wallet does not watch anything)",
1983 {
RPCResult::Type::STR_AMOUNT,
"untrusted_pending",
"untrusted pending balance (outputs created by others that are in the mempool)"},
1999 wallet.BlockUntilSyncedToCurrentChain();
2008 balances_mine.pushKV(
"untrusted_pending",
ValueFromAmount(bal.m_mine_untrusted_pending));
2009 balances_mine.pushKV(
"immature",
ValueFromAmount(bal.m_mine_immature));
2014 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));
2016 balances.pushKV(
"mine", balances_mine);
2018 auto spk_man =
wallet.GetLegacyScriptPubKeyMan();
2019 if (spk_man && spk_man->HaveWatchOnly()) {
2021 balances_watchonly.pushKV(
"trusted",
ValueFromAmount(bal.m_watchonly_trusted));
2022 balances_watchonly.pushKV(
"untrusted_pending",
ValueFromAmount(bal.m_watchonly_untrusted_pending));
2023 balances_watchonly.pushKV(
"immature",
ValueFromAmount(bal.m_watchonly_immature));
2024 balances.pushKV(
"watchonly", balances_watchonly);
2034 "Returns an object containing various wallet state info.\n",
2048 {
RPCResult::Type::NUM,
"keypoolsize",
"how many new keys are pre-generated (only counts external keys)"},
2049 {
RPCResult::Type::NUM,
"keypoolsize_hd_internal",
true,
"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)"},
2050 {
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)"},
2053 {
RPCResult::Type::BOOL,
"private_keys_enabled",
"false if privatekeys are disabled for this wallet (enforced watch-only wallet)"},
2054 {
RPCResult::Type::BOOL,
"avoid_reuse",
"whether this wallet tracks clean/dirty coins in terms of reuse"},
2055 {
RPCResult::Type::OBJ,
"scanning",
"current scanning details, or false if no scan is in progress",
2060 {
RPCResult::Type::BOOL,
"descriptors",
"whether this wallet uses descriptors for scriptPubKey management"},
2074 pwallet->BlockUntilSyncedToCurrentChain();
2076 LOCK(pwallet->cs_wallet);
2080 size_t kpExternalSize = pwallet->KeypoolCountExternalKeys();
2082 obj.
pushKV(
"walletname", pwallet->GetName());
2083 obj.
pushKV(
"walletversion", pwallet->GetVersion());
2084 obj.
pushKV(
"format", pwallet->GetDatabase().Format());
2088 obj.
pushKV(
"txcount", (
int)pwallet->mapWallet.size());
2089 const auto kp_oldest = pwallet->GetOldestKeyPoolTime();
2090 if (kp_oldest.has_value()) {
2091 obj.
pushKV(
"keypoololdest", kp_oldest.value());
2093 obj.
pushKV(
"keypoolsize", (int64_t)kpExternalSize);
2104 obj.
pushKV(
"keypoolsize_hd_internal", (int64_t)(pwallet->GetKeyPoolSize() - kpExternalSize));
2106 if (pwallet->IsCrypted()) {
2107 obj.
pushKV(
"unlocked_until", pwallet->nRelockTime);
2112 if (pwallet->IsScanning()) {
2114 scanning.
pushKV(
"duration", pwallet->ScanningDuration() / 1000);
2115 scanning.
pushKV(
"progress", pwallet->ScanningProgress());
2116 obj.
pushKV(
"scanning", scanning);
2118 obj.
pushKV(
"scanning",
false);
2129 "Returns a list of wallets in the wallet directory.\n",
2152 wallet.pushKV(
"name", path.u8string());
2157 result.
pushKV(
"wallets", wallets);
2166 "Returns a list of currently loaded wallets.\n"
2167 "For full information on the wallet, use \"getwalletinfo\"\n",
2197 "\nLoads a wallet from a wallet file or directory."
2198 "\nNote that all wallet command-line options used when starting bitcoind will be"
2199 "\napplied to the new wallet.\n",
2218 const std::string
name(request.params[0].get_str());
2233 std::string
flags =
"";
2236 flags += (
flags ==
"" ?
"" :
", ") + it.first;
2239 "\nChange the state of the given wallet flag for a wallet.\n",
2261 std::string flag_str = request.params[0].
get_str();
2262 bool value = request.params[1].isNull() || request.params[1].get_bool();
2276 if (pwallet->IsWalletFlagSet(flag) == value) {
2280 res.pushKV(
"flag_name", flag_str);
2281 res.pushKV(
"flag_state", value);
2284 pwallet->SetWalletFlag(flag);
2286 pwallet->UnsetWalletFlag(flag);
2302 "\nCreates and loads a new wallet.\n",
2308 {
"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."},
2309 {
"descriptors",
RPCArg::Type::BOOL,
RPCArg::Default{
true},
"Create a native descriptor wallet. The wallet will use descriptors internally to handle address creation"},
2311 {
"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."},
2316 {
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."},
2323 +
HelpExampleCliNamed(
"createwallet", {{
"wallet_name",
"descriptors"}, {
"avoid_reuse",
true}, {
"descriptors",
true}, {
"load_on_startup",
true}})
2324 +
HelpExampleRpcNamed(
"createwallet", {{
"wallet_name",
"descriptors"}, {
"avoid_reuse",
true}, {
"descriptors",
true}, {
"load_on_startup",
true}})
2330 if (!request.params[1].isNull() && request.params[1].get_bool()) {
2334 if (!request.params[2].isNull() && request.params[2].get_bool()) {
2338 passphrase.reserve(100);
2339 std::vector<bilingual_str> warnings;
2340 if (!request.params[3].isNull()) {
2341 passphrase = request.params[3].get_str().c_str();
2342 if (passphrase.empty()) {
2344 warnings.emplace_back(
Untranslated(
"Empty string given as passphrase, wallet will not be encrypted."));
2348 if (!request.params[4].isNull() && request.params[4].get_bool()) {
2351 if (request.params[5].isNull() || request.params[5].get_bool()) {
2357 if (!request.params[7].isNull() && request.params[7].get_bool()) {
2358 #ifdef ENABLE_EXTERNAL_SIGNER
2377 std::optional<bool> load_on_start = request.params[6].isNull() ? std::nullopt : std::optional<bool>(request.params[6].get_bool());
2378 const std::shared_ptr<CWallet>
wallet =
CreateWallet(context, request.params[0].get_str(), load_on_start, options, status,
error, warnings);
2396 "Unloads the wallet referenced by the request endpoint otherwise unloads the wallet specified in the argument.\n"
2397 "Specifying the wallet name on a wallet endpoint is invalid.",
2399 {
"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."},
2411 std::string wallet_name;
2413 if (!(request.params[0].isNull() || request.params[0].get_str() == wallet_name)) {
2417 wallet_name = request.params[0].get_str();
2429 std::vector<bilingual_str> warnings;
2430 std::optional<bool> load_on_start = request.params[1].isNull() ? std::nullopt : std::optional<bool>(request.params[1].get_bool());
2448 "\nReturns array of unspent transaction outputs\n"
2449 "with between minconf and maxconf (inclusive) confirmations.\n"
2450 "Optionally filter to only include txouts paid to specified addresses.\n",
2460 "See description of \"safe\" attribute below."},
2482 {
RPCResult::Type::NUM,
"ancestorcount",
true,
"The number of in-mempool ancestor transactions, including this one (if transaction is in the mempool)"},
2483 {
RPCResult::Type::NUM,
"ancestorsize",
true,
"The virtual transaction size of in-mempool ancestors, including this one (if transaction is in the mempool)"},
2484 {
RPCResult::Type::STR_AMOUNT,
"ancestorfees",
true,
"The total fees of in-mempool ancestors (including this one) with fee deltas used for mining priority in " +
CURRENCY_ATOM +
" (if transaction is in the mempool)"},
2486 {
RPCResult::Type::STR,
"witnessScript",
true,
"witnessScript if the scriptPubKey is P2WSH or P2SH-P2WSH"},
2488 {
RPCResult::Type::BOOL,
"solvable",
"Whether we know how to spend this output, ignoring the lack of keys"},
2489 {
RPCResult::Type::BOOL,
"reused",
true,
"(only present if avoid_reuse is set) Whether this output is reused/dirty (sent to an address that was previously spent from)"},
2490 {
RPCResult::Type::STR,
"desc",
true,
"(only when solvable) A descriptor for spending this output"},
2491 {
RPCResult::Type::BOOL,
"safe",
"Whether this output is considered safe to spend. Unconfirmed transactions\n"
2492 "from outside keys and unconfirmed replacement transactions are considered unsafe\n"
2493 "and are not eligible for spending by fundrawtransaction and sendtoaddress."},
2501 +
HelpExampleCli(
"listunspent",
"6 9999999 '[]' true '{ \"minimumAmount\": 0.005 }'")
2502 +
HelpExampleRpc(
"listunspent",
"6, 9999999, [] , true, { \"minimumAmount\": 0.005 } ")
2510 if (!request.params[0].isNull()) {
2512 nMinDepth = request.params[0].get_int();
2515 int nMaxDepth = 9999999;
2516 if (!request.params[1].isNull()) {
2518 nMaxDepth = request.params[1].get_int();
2521 std::set<CTxDestination> destinations;
2522 if (!request.params[2].isNull()) {
2525 for (
unsigned int idx = 0; idx < inputs.
size(); idx++) {
2526 const UniValue& input = inputs[idx];
2531 if (!destinations.insert(dest).second) {
2537 bool include_unsafe =
true;
2538 if (!request.params[3].isNull()) {
2540 include_unsafe = request.params[3].get_bool();
2546 uint64_t nMaximumCount = 0;
2548 if (!request.params[4].isNull()) {
2560 if (options.
exists(
"minimumAmount"))
2563 if (options.
exists(
"maximumAmount"))
2566 if (options.
exists(
"minimumSumAmount"))
2569 if (options.
exists(
"maximumCount"))
2570 nMaximumCount = options[
"maximumCount"].get_int64();
2575 pwallet->BlockUntilSyncedToCurrentChain();
2578 std::vector<COutput> vecOutputs;
2585 LOCK(pwallet->cs_wallet);
2586 AvailableCoins(*pwallet, vecOutputs, &cctl, nMinimumAmount, nMaximumAmount, nMinimumSumAmount, nMaximumCount);
2589 LOCK(pwallet->cs_wallet);
2593 for (
const COutput& out : vecOutputs) {
2595 const CScript& scriptPubKey = out.tx->tx->vout[out.i].scriptPubKey;
2597 bool reused = avoid_reuse && pwallet->IsSpentKey(out.tx->GetHash(), out.i);
2599 if (destinations.size() && (!fValidAddress || !destinations.count(address)))
2603 entry.
pushKV(
"txid", out.tx->GetHash().GetHex());
2604 entry.
pushKV(
"vout", out.i);
2606 if (fValidAddress) {
2609 const auto* address_book_entry = pwallet->FindAddressBookEntry(address);
2610 if (address_book_entry) {
2611 entry.
pushKV(
"label", address_book_entry->GetLabel());
2614 std::unique_ptr<SigningProvider> provider = pwallet->GetSolvingProvider(scriptPubKey);
2619 if (provider->GetCScript(hash, redeemScript)) {
2631 if (provider->GetCScript(
id, witnessScript)) {
2641 if (provider->GetCScript(
id, witnessScript)) {
2650 entry.
pushKV(
"confirmations", out.nDepth);
2652 size_t ancestor_count, descendant_count, ancestor_size;
2654 pwallet->chain().getTransactionAncestry(out.tx->GetHash(), ancestor_count, descendant_count, &ancestor_size, &ancestor_fees);
2655 if (ancestor_count) {
2656 entry.
pushKV(
"ancestorcount", uint64_t(ancestor_count));
2657 entry.
pushKV(
"ancestorsize", uint64_t(ancestor_size));
2658 entry.
pushKV(
"ancestorfees", uint64_t(ancestor_fees));
2661 entry.
pushKV(
"spendable", out.fSpendable);
2662 entry.
pushKV(
"solvable", out.fSolvable);
2663 if (out.fSolvable) {
2664 std::unique_ptr<SigningProvider> provider = pwallet->GetSolvingProvider(scriptPubKey);
2667 entry.
pushKV(
"desc", descriptor->ToString());
2670 if (avoid_reuse) entry.
pushKV(
"reused", reused);
2671 entry.
pushKV(
"safe", out.fSafe);
2686 " \"" +
FeeModes(
"\"\n\"") +
"\""},
2688 "Allows this transaction to be replaced by a transaction with higher fees"},
2690 "Used for fee estimation during coin selection.",
2712 wallet.BlockUntilSyncedToCurrentChain();
2714 change_position = -1;
2715 bool lockUnspents =
false;
2717 std::set<int> setSubtractFeeFromOutputs;
2754 if (options.
exists(
"add_inputs") ) {
2758 if (options.
exists(
"changeAddress") || options.
exists(
"change_address")) {
2759 const std::string change_address_str = (options.
exists(
"change_address") ? options[
"change_address"] : options[
"changeAddress"]).get_str();
2769 if (options.
exists(
"changePosition") || options.
exists(
"change_position")) {
2770 change_position = (options.
exists(
"change_position") ? options[
"change_position"] : options[
"changePosition"]).get_int();
2773 if (options.
exists(
"change_type")) {
2774 if (options.
exists(
"changeAddress") || options.
exists(
"change_address")) {
2777 if (std::optional<OutputType> parsed =
ParseOutputType(options[
"change_type"].get_str())) {
2784 const UniValue include_watching_option = options.
exists(
"include_watching") ? options[
"include_watching"] : options[
"includeWatching"];
2787 if (options.
exists(
"lockUnspents") || options.
exists(
"lock_unspents")) {
2788 lockUnspents = (options.
exists(
"lock_unspents") ? options[
"lock_unspents"] : options[
"lockUnspents"]).get_bool();
2791 if (options.
exists(
"include_unsafe")) {
2795 if (options.
exists(
"feeRate")) {
2796 if (options.
exists(
"fee_rate")) {
2799 if (options.
exists(
"conf_target")) {
2800 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.");
2802 if (options.
exists(
"estimate_mode")) {
2809 if (options.
exists(
"subtractFeeFromOutputs") || options.
exists(
"subtract_fee_from_outputs") )
2810 subtractFeeFromOutputs = (options.
exists(
"subtract_fee_from_outputs") ? options[
"subtract_fee_from_outputs"] : options[
"subtractFeeFromOutputs"]).get_array();
2812 if (options.
exists(
"replaceable")) {
2815 SetFeeEstimateMode(
wallet, coinControl, options[
"conf_target"], options[
"estimate_mode"], options[
"fee_rate"], override_min_fee);
2822 if (options.
exists(
"solving_data")) {
2824 if (solving_data.
exists(
"pubkeys")) {
2825 for (
const UniValue& pk_univ : solving_data[
"pubkeys"].get_array().getValues()) {
2826 const std::string& pk_str = pk_univ.
get_str();
2827 if (!
IsHex(pk_str)) {
2830 const std::vector<unsigned char> data(
ParseHex(pk_str));
2831 const CPubKey pubkey(data.begin(), data.end());
2842 if (solving_data.
exists(
"scripts")) {
2843 for (
const UniValue& script_univ : solving_data[
"scripts"].get_array().getValues()) {
2844 const std::string& script_str = script_univ.get_str();
2845 if (!
IsHex(script_str)) {
2848 std::vector<unsigned char> script_data(
ParseHex(script_str));
2849 const CScript script(script_data.begin(), script_data.end());
2854 if (solving_data.
exists(
"descriptors")) {
2855 for (
const UniValue& desc_univ : solving_data[
"descriptors"].get_array().getValues()) {
2856 const std::string& desc_str = desc_univ.get_str();
2859 std::vector<CScript> scripts_temp;
2860 std::unique_ptr<Descriptor> desc =
Parse(desc_str, desc_out,
error,
true);
2864 desc->Expand(0, desc_out, scripts_temp, desc_out);
2870 if (tx.
vout.size() == 0)
2873 if (change_position != -1 && (change_position < 0 || (
unsigned int)change_position > tx.
vout.size()))
2876 for (
unsigned int idx = 0; idx < subtractFeeFromOutputs.
size(); idx++) {
2877 int pos = subtractFeeFromOutputs[idx].
get_int();
2878 if (setSubtractFeeFromOutputs.count(pos))
2882 if (pos >=
int(tx.
vout.size()))
2884 setSubtractFeeFromOutputs.insert(pos);
2889 std::map<COutPoint, Coin> coins;
2893 wallet.chain().findCoins(coins);
2894 for (
const auto& coin : coins) {
2895 if (!coin.second.out.IsNull()) {
2910 "\nIf the transaction has no inputs, they will be automatically selected to meet its out value.\n"
2911 "It will add at most one change output to the outputs.\n"
2912 "No existing outputs will be modified unless \"subtractFeeFromOutputs\" is specified.\n"
2913 "Note that inputs which were signed may need to be resigned after completion since in/outputs have been added.\n"
2914 "The inputs added will not be signed, use signrawtransactionwithkey\n"
2915 "or signrawtransactionwithwallet for that.\n"
2916 "All existing inputs must either have their previous output transaction be in the wallet\n"
2917 "or be in the UTXO set. Solving data must be provided for non-wallet inputs.\n"
2918 "Note that all inputs selected must be of standard form and P2SH scripts must be\n"
2919 "in the wallet using importaddress or addmultisigaddress (to calculate fees).\n"
2920 "You can see whether this is the case by checking the \"solvable\" field in the listunspent output.\n"
2921 "Only pay-to-pubkey, multisig, and P2SH versions thereof are currently supported for watch-only\n",
2925 Cat<std::vector<RPCArg>>(
2928 {
"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"
2929 "Warning: the resulting transaction may become invalid if one of the unsafe inputs disappears.\n"
2930 "If that happens, you will need to fund the transaction with different inputs and republish it."},
2933 {
"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\"."},
2935 "Only solvable inputs can be used. Watch-only destinations are solvable if the public key and/or output script was imported,\n"
2936 "e.g. with 'importpubkey' or 'importmulti' with the 'pubkeys' or 'desc' field."},
2941 "The fee will be equally deducted from the amount of each specified output.\n"
2942 "Those recipients will receive less bitcoins than you enter in their corresponding amount field.\n"
2943 "If no outputs are specified here, the sender pays the fee.",
2952 "If iswitness is not present, heuristic tests will be used in decoding.\n"
2953 "If true, only witness deserialization will be tried.\n"
2954 "If false, only non-witness deserialization will be tried.\n"
2955 "This boolean should reflect whether the transaction has inputs\n"
2956 "(e.g. fully valid, or on-chain transactions), if known by the caller."
2968 "\nCreate a transaction with no inputs\n"
2969 +
HelpExampleCli(
"createrawtransaction",
"\"[]\" \"{\\\"myaddress\\\":0.01}\"") +
2970 "\nAdd sufficient unsigned inputs to meet the output value\n"
2971 +
HelpExampleCli(
"fundrawtransaction",
"\"rawtransactionhex\"") +
2972 "\nSign the transaction\n"
2973 +
HelpExampleCli(
"signrawtransactionwithwallet",
"\"fundedtransactionhex\"") +
2974 "\nSend the transaction\n"
2975 +
HelpExampleCli(
"sendrawtransaction",
"\"signedtransactionhex\"")
2982 RPCTypeCheck(request.params, {UniValue::VSTR, UniValueType(), UniValue::VBOOL});
2986 bool try_witness = request.params[2].isNull() ? true : request.params[2].get_bool();
2987 bool try_no_witness = request.params[2].isNull() ? true : !request.params[2].get_bool();
2988 if (!
DecodeHexTx(tx, request.params[0].get_str(), try_no_witness, try_witness)) {
2993 int change_position;
2997 FundTransaction(*pwallet, tx, fee, change_position, request.params[1], coin_control,
true);
3002 result.
pushKV(
"changepos", change_position);
3011 return RPCHelpMan{
"signrawtransactionwithwallet",
3012 "\nSign inputs for raw transaction (serialized, hex-encoded).\n"
3013 "The second optional argument (may be null) is an array of previous transaction outputs that\n"
3014 "this transaction depends on but may not yet be in the block chain." +
3037 " \"ALL|ANYONECANPAY\"\n"
3038 " \"NONE|ANYONECANPAY\"\n"
3039 " \"SINGLE|ANYONECANPAY\""},
3072 RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VARR, UniValue::VSTR},
true);
3075 if (!
DecodeHexTx(mtx, request.params[0].get_str())) {
3080 LOCK(pwallet->cs_wallet);
3084 std::map<COutPoint, Coin> coins;
3085 for (
const CTxIn& txin : mtx.
vin) {
3088 pwallet->chain().findCoins(coins);
3096 std::map<int, bilingual_str> input_errors;
3098 bool complete = pwallet->SignTransaction(mtx, coins, nHashType, input_errors);
3108 const bool want_psbt = method_name ==
"psbtbumpfee";
3112 "\nBumps the fee of an opt-in-RBF transaction T, replacing it with a new transaction B.\n"
3113 + std::string(want_psbt ?
"Returns a PSBT instead of creating and signing a new transaction.\n" :
"") +
3114 "An opt-in RBF transaction with the given txid must be in the wallet.\n"
3115 "The command will pay the additional fee by reducing change outputs or adding inputs when necessary.\n"
3116 "It may add a new change output if one does not already exist.\n"
3117 "All inputs in the original transaction will be included in the replacement transaction.\n"
3118 "The command will fail if the wallet or mempool contains a transaction that spends one of T's outputs.\n"
3119 "By default, the new fee will be calculated automatically using the estimatesmartfee RPC.\n"
3120 "The user can specify a confirmation target for estimatesmartfee.\n"
3121 "Alternatively, the user can specify a fee rate in " +
CURRENCY_ATOM +
"/vB for the new transaction.\n"
3122 "At a minimum, the new fee rate must be high enough to pay an additional new relay fee (incrementalfee\n"
3123 "returned by getnetworkinfo) to enter the node's mempool.\n"
3124 "* WARNING: before version 0.21, fee_rate was in " +
CURRENCY_UNIT +
"/kvB. As of 0.21, fee_rate is in " +
CURRENCY_ATOM +
"/vB. *\n",
3131 "\nSpecify a fee rate in " +
CURRENCY_ATOM +
"/vB instead of relying on the built-in fee estimator.\n"
3132 "Must be at least " + incremental_fee +
" higher than the current transaction fee rate.\n"
3133 "WARNING: before version 0.21, fee_rate was in " +
CURRENCY_UNIT +
"/kvB. As of 0.21, fee_rate is in " +
CURRENCY_ATOM +
"/vB.\n"},
3135 "marked bip-125 replaceable. If true, the sequence numbers in the transaction will\n"
3136 "be left unchanged from the original. If false, any input sequence numbers in the\n"
3137 "original transaction that were less than 0xfffffffe will be increased to 0xfffffffe\n"
3138 "so the new transaction will not be explicitly bip-125 replaceable (though it may\n"
3139 "still be replaceable in practice, for example if it has unconfirmed ancestors which\n"
3140 "are replaceable).\n"},
3149 std::vector<RPCResult>{{
RPCResult::Type::STR,
"psbt",
"The base64-encoded unsigned PSBT of the new transaction."}} :
3161 "\nBump the fee, get the new transaction\'s " + std::string(want_psbt ?
"psbt" :
"txid") +
"\n" +
3170 throw JSONRPCError(
RPC_WALLET_ERROR,
"bumpfee is not available with wallets that have private keys disabled. Use psbtbumpfee instead.");
3173 RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VOBJ});
3181 if (!request.params[1].isNull()) {
3182 UniValue options = request.params[1];
3193 if (options.
exists(
"confTarget") && options.
exists(
"conf_target")) {
3197 auto conf_target = options.
exists(
"confTarget") ? options[
"confTarget"] : options[
"conf_target"];
3199 if (options.
exists(
"replaceable")) {
3202 SetFeeEstimateMode(*pwallet, coin_control, conf_target, options[
"estimate_mode"], options[
"fee_rate"],
false);
3207 pwallet->BlockUntilSyncedToCurrentChain();
3209 LOCK(pwallet->cs_wallet);
3214 std::vector<bilingual_str> errors;
3258 bool complete =
false;
3273 result.
pushKV(
"errors", result_errors);
3286 "\nRescan the local blockchain for wallet related transactions.\n"
3287 "Note: Use \"getwalletinfo\" to query the scanning progress.\n",
3295 {
RPCResult::Type::NUM,
"start_height",
"The block height where the rescan started (the requested height or 0)"},
3296 {
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."},
3311 wallet.BlockUntilSyncedToCurrentChain();
3318 int start_height = 0;
3319 std::optional<int> stop_height;
3322 LOCK(pwallet->cs_wallet);
3323 int tip_height = pwallet->GetLastBlockHeight();
3325 if (!request.params[0].isNull()) {
3326 start_height = request.params[0].get_int();
3327 if (start_height < 0 || start_height > tip_height) {
3332 if (!request.params[1].isNull()) {
3333 stop_height = request.params[1].get_int();
3334 if (*stop_height < 0 || *stop_height > tip_height) {
3336 }
else if (*stop_height < start_height) {
3342 if (!pwallet->chain().hasBlocks(pwallet->GetLastBlockHash(), start_height, stop_height)) {
3343 throw JSONRPCError(
RPC_MISC_ERROR,
"Can't rescan beyond pruned data. Use RPC call getblockchaininfo to determine your pruned height.");
3346 CHECK_NONFATAL(pwallet->chain().findAncestorByHeight(pwallet->GetLastBlockHash(), start_height,
FoundBlock().hash(start_block)));
3350 pwallet->ScanForWalletTransactions(start_block, start_height, stop_height, reserver,
true );
3361 response.
pushKV(
"start_height", start_height);
3376 std::vector<std::vector<unsigned char>> solutions_data;
3387 UniValue wallet_detail = std::visit(*
this, embedded);
3388 subobj.
pushKVs(wallet_detail);
3392 if (subobj.
exists(
"pubkey")) obj.
pushKV(
"pubkey", subobj[
"pubkey"]);
3393 obj.
pushKV(
"embedded", std::move(subobj));
3396 obj.
pushKV(
"sigsrequired", solutions_data[0][0]);
3398 for (
size_t i = 1; i < solutions_data.size() - 1; ++i) {
3399 CPubKey key(solutions_data[i].begin(), solutions_data[i].end());
3402 obj.
pushKV(
"pubkeys", std::move(pubkeys));
3465 std::unique_ptr<SigningProvider> provider =
nullptr;
3466 provider =
wallet.GetSolvingProvider(script);
3486 "\nReturn information about the given bitcoin address.\n"
3487 "Some of the information will only be present if the address is in the active wallet.\n",
3498 {
RPCResult::Type::BOOL,
"solvable",
"If we know how to spend coins sent to this address, ignoring the possible lack of private keys."},
3499 {
RPCResult::Type::STR,
"desc",
true,
"A descriptor for spending coins sent to this address (only when solvable)."},
3500 {
RPCResult::Type::STR,
"parent_desc",
true,
"The descriptor used to derive this address if this is a descriptor wallet"},
3506 {
RPCResult::Type::STR,
"script",
true,
"The output script type. Only if isscript is true and the redeemscript is known. Possible\n"
3507 "types: nonstandard, pubkey, pubkeyhash, scripthash, multisig, nulldata, witness_v0_keyhash,\n"
3508 "witness_v0_scripthash, witness_unknown."},
3510 {
RPCResult::Type::ARR,
"pubkeys",
true,
"Array of pubkeys associated with the known redeemscript (only if script is multisig).",
3514 {
RPCResult::Type::NUM,
"sigsrequired",
true,
"The number of signatures required to spend multisig output (only if script is multisig)."},
3515 {
RPCResult::Type::STR_HEX,
"pubkey",
true,
"The hex value of the raw public key for single-key addresses (possibly embedded in P2SH or P2WSH)."},
3516 {
RPCResult::Type::OBJ,
"embedded",
true,
"Information about the address embedded in P2SH or P2WSH, if relevant and known.",
3518 {
RPCResult::Type::ELISION,
"",
"Includes all getaddressinfo output fields for the embedded address, excluding metadata (timestamp, hdkeypath, hdseedid)\n"
3519 "and relation to the wallet (ismine, iswatchonly)."},
3526 {
RPCResult::Type::ARR,
"labels",
"Array of labels associated with the address. Currently limited to one label but returned\n"
3527 "as an array to keep the API stable if multiple labels are enabled in the future.",
3542 LOCK(pwallet->cs_wallet);
3544 std::string error_msg;
3550 if (error_msg.empty()) error_msg =
"Invalid address";
3558 ret.
pushKV(
"address", currentAddress);
3563 std::unique_ptr<SigningProvider> provider = pwallet->GetSolvingProvider(scriptPubKey);
3570 bool solvable = inferred->IsSolvable() ||
IsSolvable(*provider, scriptPubKey);
3571 ret.
pushKV(
"solvable", solvable);
3573 ret.
pushKV(
"desc", inferred->ToString());
3576 ret.
pushKV(
"solvable",
false);
3579 const auto& spk_mans = pwallet->GetScriptPubKeyMans(scriptPubKey);
3582 if (spk_mans.size()) spk_man = *spk_mans.begin();
3586 std::string desc_str;
3588 ret.
pushKV(
"parent_desc", desc_str);
3600 if (
const std::unique_ptr<CKeyMetadata> meta = spk_man->GetMetadata(dest)) {
3601 ret.
pushKV(
"timestamp", meta->nCreateTime);
3602 if (meta->has_key_origin) {
3604 ret.
pushKV(
"hdseedid", meta->hd_seed_id.GetHex());
3605 ret.
pushKV(
"hdmasterfingerprint",
HexStr(meta->key_origin.fingerprint));
3616 const auto* address_book_entry = pwallet->FindAddressBookEntry(dest);
3617 if (address_book_entry) {
3618 labels.
push_back(address_book_entry->GetLabel());
3620 ret.
pushKV(
"labels", std::move(labels));
3630 "\nReturns the list of addresses assigned the specified label.\n",
3639 {
RPCResult::Type::STR,
"purpose",
"Purpose of address (\"send\" for sending address, \"receive\" for receiving address)"},
3652 LOCK(pwallet->cs_wallet);
3658 std::set<std::string> addresses;
3659 for (
const std::pair<const CTxDestination, CAddressBookData>& item : pwallet->m_address_book) {
3660 if (item.second.IsChange())
continue;
3661 if (item.second.GetLabel() == label) {
3666 bool unique = addresses.emplace(address).second;
3688 "\nReturns the list of all labels, or labels that are assigned to addresses with a specific purpose.\n",
3699 "\nList all labels\n"
3701 "\nList labels that have receiving addresses\n"
3703 "\nList labels that have sending addresses\n"
3705 "\nAs a JSON-RPC call\n"
3713 LOCK(pwallet->cs_wallet);
3715 std::string purpose;
3716 if (!request.params[0].isNull()) {
3717 purpose = request.params[0].get_str();
3721 std::set<std::string> label_set;
3722 for (
const std::pair<const CTxDestination, CAddressBookData>& entry : pwallet->m_address_book) {
3723 if (entry.second.IsChange())
continue;
3724 if (purpose.empty() || entry.second.purpose == purpose) {
3725 label_set.insert(entry.second.GetLabel());
3730 for (
const std::string&
name : label_set) {
3742 "\nEXPERIMENTAL warning: this call may be changed in future releases.\n"
3743 "\nSend a transaction.\n",
3746 "That is, each address can only appear once and there can only be one 'data' object.\n"
3747 "For convenience, a dictionary, which holds the key-value pairs directly, is also accepted.",
3763 " \"" +
FeeModes(
"\"\n\"") +
"\""},
3766 Cat<std::vector<RPCArg>>(
3769 {
"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"
3770 "Warning: the resulting transaction may become invalid if one of the unsafe inputs disappears.\n"
3771 "If that happens, you will need to fund the transaction with different inputs and republish it."},
3772 {
"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"},
3775 {
"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\"."},
3778 "Only solvable inputs can be used. Watch-only destinations are solvable if the public key and/or output script was imported,\n"
3779 "e.g. with 'importpubkey' or 'importmulti' with the 'pubkeys' or 'desc' field."},
3791 "The fee will be equally deducted from the amount of each specified output.\n"
3792 "Those recipients will receive less bitcoins than you enter in their corresponding amount field.\n"
3793 "If no outputs are specified here, the sender pays the fee.",
3806 {
RPCResult::Type::STR_HEX,
"txid",
true,
"The transaction id for the send. Only 1 transaction is created regardless of the number of addresses."},
3807 {
RPCResult::Type::STR_HEX,
"hex",
true,
"If add_to_wallet is false, the hex-encoded raw transaction with signature(s)"},
3808 {
RPCResult::Type::STR,
"psbt",
true,
"If more signatures are needed, or if add_to_wallet is false, the base64-encoded (partially) signed transaction"}
3812 "\nSend 0.1 BTC with a confirmation target of 6 blocks in economical fee estimate mode\n"
3814 "Send 0.2 BTC with a fee rate of 1.1 " +
CURRENCY_ATOM +
"/vB using positional arguments\n"
3816 "Send 0.2 BTC with a fee rate of 1 " +
CURRENCY_ATOM +
"/vB using the options argument\n"
3818 "Send 0.3 BTC with a fee rate of 25 " +
CURRENCY_ATOM +
"/vB using named arguments\n"
3820 "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"
3821 +
HelpExampleCli(
"send",
"'{\"" +
EXAMPLE_ADDRESS[0] +
"\": 0.1}' 1 economical '{\"add_to_wallet\": false, \"inputs\": [{\"txid\":\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\", \"vout\":1}]}'")
3838 if (options.exists(
"conf_target") || options.exists(
"estimate_mode")) {
3839 if (!request.params[1].isNull() || !request.params[2].isNull()) {
3843 options.pushKV(
"conf_target", request.params[1]);
3844 options.pushKV(
"estimate_mode", request.params[2]);
3846 if (options.exists(
"fee_rate")) {
3847 if (!request.params[3].isNull()) {
3851 options.pushKV(
"fee_rate", request.params[3]);
3853 if (!options[
"conf_target"].isNull() && (options[
"estimate_mode"].isNull() || (options[
"estimate_mode"].get_str() ==
"unset"))) {
3856 if (options.exists(
"feeRate")) {
3859 if (options.exists(
"changeAddress")) {
3862 if (options.exists(
"changePosition")) {
3865 if (options.exists(
"includeWatching")) {
3868 if (options.exists(
"lockUnspents")) {
3871 if (options.exists(
"subtractFeeFromOutputs")) {
3875 const bool psbt_opt_in = options.exists(
"psbt") && options[
"psbt"].get_bool();
3878 int change_position;
3879 bool rbf = pwallet->m_signal_rbf;
3880 if (options.exists(
"replaceable")) {
3881 rbf = options[
"replaceable"].get_bool();
3888 FundTransaction(*pwallet, rawTx, fee, change_position, options, coin_control,
false);
3890 bool add_to_wallet =
true;
3891 if (options.exists(
"add_to_wallet")) {
3892 add_to_wallet = options[
"add_to_wallet"].get_bool();
3912 if (psbt_opt_in || !complete || !add_to_wallet) {
3920 std::string err_string;
3923 result.
pushKV(
"txid", tx->GetHash().GetHex());
3924 if (add_to_wallet && !psbt_opt_in) {
3925 pwallet->CommitTransaction(tx, {}, {} );
3927 result.
pushKV(
"hex", hex);
3930 result.
pushKV(
"complete", complete);
3940 "\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"
3941 "HD will have a new HD seed set so that new keys added to the keypool will be derived from this new seed.\n"
3942 "\nNote that you will need to MAKE A NEW BACKUP of your wallet after setting the HD wallet seed." +
3945 {
"newkeypool",
RPCArg::Type::BOOL,
RPCArg::Default{
true},
"Whether to flush old unused addresses, including change addresses, from the keypool and regenerate it.\n"
3946 "If true, the next address from getnewaddress and change address from getrawchangeaddress will be from this new seed.\n"
3947 "If false, addresses (including change addresses if the wallet already had HD Chain Split enabled) from the existing\n"
3948 "keypool will be used until it has been depleted."},
3950 "The seed value can be retrieved using the dumpwallet command. It is the private key marked hdseed=1"},
3973 if (!pwallet->CanSupportFeature(
FEATURE_HD)) {
3974 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");
3979 bool flush_key_pool =
true;
3980 if (!request.params[0].isNull()) {
3981 flush_key_pool = request.params[0].get_bool();
3985 if (request.params[1].isNull()) {
4011 "\nUpdate a PSBT with input information from our wallet and then sign inputs\n"
4012 "that we can sign for." +
4022 " \"ALL|ANYONECANPAY\"\n"
4023 " \"NONE|ANYONECANPAY\"\n"
4024 " \"SINGLE|ANYONECANPAY\""},
4046 wallet.BlockUntilSyncedToCurrentChain();
4061 bool sign = request.params[1].isNull() ? true : request.params[1].get_bool();
4062 bool bip32derivs = request.params[3].isNull() ? true : request.params[3].get_bool();
4063 bool finalize = request.params[4].isNull() ? true : request.params[4].get_bool();
4064 bool complete =
true;
4068 const TransactionError err{
wallet.FillPSBT(psbtx, complete, nHashType, sign, bip32derivs,
nullptr, finalize)};
4077 result.
pushKV(
"complete", complete);
4087 "\nCreates and funds a transaction in the Partially Signed Transaction format.\n"
4088 "Implements the Creator and Updater roles.\n"
4089 "All existing inputs must either have their previous output transaction be in the wallet\n"
4090 "or be in the UTXO set. Solving data must be provided for non-wallet inputs.\n",
4104 "That is, each address can only appear once and there can only be one 'data' object.\n"
4105 "For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also\n"
4106 "accepted as second parameter.",
4122 Cat<std::vector<RPCArg>>(
4125 {
"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"
4126 "Warning: the resulting transaction may become invalid if one of the unsafe inputs disappears.\n"
4127 "If that happens, you will need to fund the transaction with different inputs and republish it."},
4130 {
"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\"."},
4136 "The fee will be equally deducted from the amount of each specified output.\n"
4137 "Those recipients will receive less bitcoins than you enter in their corresponding amount field.\n"
4138 "If no outputs are specified here, the sender pays the fee.",
4157 "\nCreate a transaction with no inputs\n"
4158 +
HelpExampleCli(
"walletcreatefundedpsbt",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
4168 wallet.BlockUntilSyncedToCurrentChain();
4180 int change_position;
4181 bool rbf{
wallet.m_signal_rbf};
4182 const UniValue &replaceable_arg = request.params[3][
"replaceable"];
4183 if (!replaceable_arg.
isNull()) {
4185 rbf = replaceable_arg.
isTrue();
4198 bool bip32derivs = request.params[4].isNull() ? true : request.params[4].get_bool();
4199 bool complete =
true;
4212 result.
pushKV(
"changepos", change_position);
4221 "\nUpgrade the wallet. Upgrades to the latest version if no version number is specified.\n"
4222 "New keys may be generated and a new wallet backup will need to be made.",
4250 if (!request.params[0].isNull()) {
4251 version = request.params[0].get_int();
4254 const int previous_version{pwallet->GetVersion()};
4255 const bool wallet_upgraded{pwallet->UpgradeWallet(version,
error)};
4256 const int current_version{pwallet->GetVersion()};
4259 if (wallet_upgraded) {
4260 if (previous_version == current_version) {
4261 result =
"Already at latest version. Wallet version unchanged.";
4263 result =
strprintf(
"Wallet upgraded successfully from version %i to version %i.", previous_version, current_version);
4268 obj.
pushKV(
"wallet_name", pwallet->GetName());
4269 obj.
pushKV(
"previous_version", previous_version);
4270 obj.
pushKV(
"current_version", current_version);
4271 if (!result.empty()) {
4272 obj.
pushKV(
"result", result);
4282 #ifdef ENABLE_EXTERNAL_SIGNER
4286 "walletdisplayaddress",
4287 "Display address on an external signer for verification.",
4318 result.
pushKV(
"address", request.params[0].get_str());
4323 #endif // ENABLE_EXTERNAL_SIGNER
4400 {
"wallet", &
send, },
4412 #ifdef ENABLE_EXTERNAL_SIGNER
4414 #endif // ENABLE_EXTERNAL_SIGNER