6#include <chainparams.h>
44#include <event2/http.h>
65 int confirms =
wallet.GetTxDepthInMainChain(wtx);
66 entry.pushKV(
"confirmations", confirms);
67 if (wtx.IsCoinBase()) {
68 entry.pushKV(
"generated",
true);
71 entry.pushKV(
"blockhash", wtx.m_confirm.hashBlock.GetHex());
72 entry.pushKV(
"blockheight", wtx.m_confirm.block_height);
73 entry.pushKV(
"blockindex", wtx.m_confirm.nIndex);
77 entry.pushKV(
"blocktime", block_time);
82 entry.pushKV(
"txid", hash.
GetHex());
87 entry.pushKV(
"walletconflicts", conflicts);
88 entry.pushKV(
"time", wtx.GetTxTime());
89 entry.pushKV(
"timereceived", int64_t{wtx.nTimeReceived});
91 for (
const std::pair<const std::string, std::string> &item : wtx.mapValue) {
92 entry.pushKV(item.first, item.second);
99 "Returns a new eCash address for receiving payments.\n"
100 "If 'label' is specified, it is added to the address book \n"
101 "so payments received with the address will be associated with "
105 "The label name for the address to be linked to. If not provided, "
106 "the default label \"\" is used. It can also be set to the empty "
107 "string \"\" to represent the default label. The label does not "
108 "need to exist, it will be created if there is no label by the "
116 std::shared_ptr<CWallet>
const wallet =
126 "Error: This wallet has no available keys");
132 if (!request.params[0].isNull()) {
150 "getrawchangeaddress",
151 "Returns a new Bitcoin address, for receiving change.\n"
152 "This is for use with raw transactions, NOT normal use.\n",
159 std::shared_ptr<CWallet>
const wallet =
170 "Error: This wallet has no available keys");
175 if (!request.params[0].isNull()) {
180 request.params[0].get_str()));
197 "Sets the label associated with the given address.\n",
200 "The bitcoin address to be associated with a label."},
202 "The label to assign to the address."},
207 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"tabby\"") +
210 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"tabby\"")},
213 std::shared_ptr<CWallet>
const wallet =
223 wallet->GetChainParams());
226 "Invalid Bitcoin address");
231 if (pwallet->
IsMine(dest)) {
243 const UniValue &subtract_fee_outputs,
244 std::vector<CRecipient> &recipients,
246 std::set<CTxDestination> destinations;
248 for (
const std::string &address : address_amounts.
getKeys()) {
252 std::string(
"Invalid Bitcoin address: ") +
256 if (destinations.count(dest)) {
259 std::string(
"Invalid parameter, duplicated address: ") +
262 destinations.insert(dest);
267 bool subtract_fee =
false;
268 for (
unsigned int idx = 0; idx < subtract_fee_outputs.
size(); idx++) {
269 const UniValue &addr = subtract_fee_outputs[idx];
270 if (addr.
get_str() == address) {
275 CRecipient recipient = {script_pub_key, amount, subtract_fee};
276 recipients.push_back(recipient);
281 std::vector<CRecipient> &recipients,
mapValue_t map_value,
282 bool broadcast =
true) {
289 constexpr int RANDOM_CHANGE_POSITION = -1;
291 *pwallet, recipients, RANDOM_CHANGE_POSITION, coin_control,
300 return tx->GetId().GetHex();
309 "The bitcoin address to send to."},
313 "A comment used to store what the transaction is for.\n"
314 " This is not part of the "
315 "transaction, just kept in your wallet."},
317 "A comment to store the name of the person or organization\n"
318 " to which you're sending the "
319 "transaction. This is not part of the \n"
320 " transaction, just kept in "
324 "The fee will be deducted from the amount being sent.\n"
325 " The recipient will receive "
326 "less bitcoins than you enter in the amount field."},
328 "(only available if avoid_reuse wallet flag is set) Avoid "
329 "spending from dirty addresses; addresses are considered\n"
330 " dirty if they have previously "
331 "been used in a transaction."},
336 "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 100000") +
337 HelpExampleCli(
"sendtoaddress",
"\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvay"
338 "dd\" 100000 \"donation\" \"seans "
341 "Jvaydd\" 100000 \"\" \"\" true") +
343 "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvay"
344 "dd\", 100000, \"donation\", \"seans "
348 std::shared_ptr<CWallet>
const wallet =
358 pwallet->BlockUntilSyncedToCurrentChain();
364 if (!request.params[2].isNull() &&
365 !request.params[2].get_str().empty()) {
366 mapValue[
"comment"] = request.params[2].get_str();
368 if (!request.params[3].isNull() &&
369 !request.params[3].get_str().empty()) {
370 mapValue[
"to"] = request.params[3].get_str();
373 bool fSubtractFeeFromAmount =
false;
374 if (!request.params[4].isNull()) {
375 fSubtractFeeFromAmount = request.params[4].get_bool();
388 const std::string address = request.params[0].get_str();
389 address_amounts.
pushKV(address, request.params[1]);
391 if (fSubtractFeeFromAmount) {
392 subtractFeeFromAmount.
push_back(address);
395 std::vector<CRecipient> recipients;
397 wallet->GetChainParams());
399 return SendMoney(pwallet, coin_control, recipients, mapValue);
406 "listaddressgroupings",
407 "Lists groups of addresses which have had their common ownership\n"
408 "made public by common use as inputs or as the resulting change\n"
409 "in past transactions\n",
424 "The bitcoin address"},
436 std::shared_ptr<CWallet>
const wallet =
446 pwallet->BlockUntilSyncedToCurrentChain();
451 std::map<CTxDestination, Amount> balances =
453 for (
const std::set<CTxDestination> &grouping :
459 addressInfo.
push_back(balances[address]);
461 const auto *address_book_entry =
463 if (address_book_entry) {
464 addressInfo.
push_back(address_book_entry->GetLabel());
471 return jsonGroupings;
479 std::set<CTxDestination> address_set;
484 address_set =
wallet.GetLabelAddresses(label);
491 "Invalid Bitcoin address");
494 if (!
wallet.IsMine(script_pub_key)) {
497 address_set.insert(dest);
502 if (!params[1].
isNull()) {
503 min_depth = params[1].getInt<
int>();
508 for (
const std::pair<const TxId, CWalletTx> &wtx_pair :
wallet.mapWallet) {
514 for (
const CTxOut &txout : wtx.
tx->vout) {
517 wallet.IsMine(address) && address_set.count(address)) {
528 "getreceivedbyaddress",
529 "Returns the total amount received by the given address in "
530 "transactions with at least minconf confirmations.\n",
533 "The bitcoin address for transactions."},
535 "Only include transactions confirmed at least this many times."},
539 " received at this address."},
541 "\nThe amount from transactions with at least 1 confirmation\n" +
543 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\"") +
544 "\nThe amount including unconfirmed transactions, zero "
547 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" 0") +
548 "\nThe amount with at least 6 confirmations\n" +
550 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" 6") +
551 "\nAs a JSON-RPC call\n" +
553 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", 6")},
556 std::shared_ptr<CWallet>
const wallet =
566 pwallet->BlockUntilSyncedToCurrentChain();
578 "getreceivedbylabel",
579 "Returns the total amount received by addresses with <label> in "
580 "transactions with at least [minconf] confirmations.\n",
583 "The selected label, may be the default label using \"\"."},
585 "Only include transactions confirmed at least this many times."},
589 " received for this label."},
590 RPCExamples{
"\nAmount received by the default label with at least 1 "
593 "\nAmount received at the tabby label including "
594 "unconfirmed amounts with zero confirmations\n" +
596 "\nThe amount with at least 6 confirmations\n" +
598 "\nAs a JSON-RPC call\n" +
602 std::shared_ptr<CWallet>
const wallet =
612 pwallet->BlockUntilSyncedToCurrentChain();
625 "Returns the total available balance.\n"
626 "The available balance is what the wallet considers currently "
627 "spendable, and is\n"
628 "thus affected by options which limit spendability such as "
629 "-spendzeroconfchange.\n",
632 "Remains for backward compatibility. Must be excluded or set to "
635 "Only include transactions confirmed at least this many times."},
638 "true for watch-only wallets, otherwise false"},
639 "Also include balance in watch-only addresses (see "
642 "(only available if avoid_reuse wallet flag is set) Do not "
643 "include balance in dirty outputs; addresses are considered dirty "
644 "if they have previously been used in a transaction."},
648 " received for this wallet."},
650 "\nThe total amount in the wallet with 0 or more confirmations\n" +
652 "\nThe total amount in the wallet with at least 6 confirmations\n" +
653 HelpExampleCli(
"getbalance",
"\"*\" 6") +
"\nAs a JSON-RPC call\n" +
657 std::shared_ptr<CWallet>
const wallet =
667 pwallet->BlockUntilSyncedToCurrentChain();
671 const auto dummy_value{self.
MaybeArg<std::string>(
"dummy")};
672 if (dummy_value && *dummy_value !=
"*") {
675 "dummy first argument must be excluded or set to \"*\".");
678 const auto min_depth{self.
Arg<
int>(
"minconf")};
680 bool include_watchonly =
685 const auto bal =
GetBalance(*pwallet, min_depth, avoid_reuse);
687 return bal.m_mine_trusted + (include_watchonly
688 ? bal.m_watchonly_trusted
696 "getunconfirmedbalance",
697 "DEPRECATED\nIdentical to getbalances().mine.untrusted_pending\n",
703 std::shared_ptr<CWallet>
const wallet =
713 pwallet->BlockUntilSyncedToCurrentChain();
725 "Send multiple times. Amounts are double-precision "
726 "floating point numbers." +
730 "Must be set to \"\" for backwards compatibility.",
732 .oneline_description =
"\"\""}},
737 "The addresses and amounts",
740 "The bitcoin address is the key, the numeric amount (can "
746 "Only use the balance confirmed at least this many times."},
754 " The fee will be equally deducted "
755 "from the amount of each selected address.\n"
756 " Those recipients will receive less "
757 "bitcoins than you enter in their corresponding amount field.\n"
758 " If no addresses are specified "
759 "here, the sender pays the fee.",
762 "Subtract fee from this address"},
767 "The transaction id for the send. Only 1 transaction is "
768 "created regardless of the number of addresses."},
770 "\nSend two amounts to two different addresses:\n" +
774 "\"{\\\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\\\":"
776 "\\\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\\\":0."
778 "\nSend two amounts to two different addresses setting the "
779 "confirmation and comment:\n" +
783 "\"{\\\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\\\":"
785 "\\\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\\\":0."
788 "\nSend two amounts to two different addresses, subtract fee "
793 "\"{\\\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\\\":"
795 "\\\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\\\":0."
797 "\"[\\\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\\\","
798 "\\\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\\\"]"
800 "\nAs a JSON-RPC call\n" +
804 "{\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\":0.01,"
805 "\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\":0.02}, "
810 std::shared_ptr<CWallet>
const wallet =
820 pwallet->BlockUntilSyncedToCurrentChain();
824 if (!request.params[0].isNull() &&
825 !request.params[0].get_str().empty()) {
827 "Dummy value must be set to \"\"");
832 if (!request.params[3].isNull() &&
833 !request.params[3].get_str().empty()) {
834 mapValue[
"comment"] = request.params[3].
get_str();
838 if (!request.params[4].isNull()) {
839 subtractFeeFromAmount = request.params[4].
get_array();
842 std::vector<CRecipient> recipients;
844 wallet->GetChainParams());
847 return SendMoney(pwallet, coin_control, recipients,
848 std::move(mapValue));
855 "addmultisigaddress",
856 "Add an nrequired-to-sign multisignature address to the wallet. "
857 "Requires a new wallet backup.\n"
858 "Each key is a Bitcoin address or hex-encoded public key.\n"
859 "This functionality is only intended for use with non-watchonly "
861 "See `importaddress` for watchonly p2sh address support.\n"
862 "If 'label' is specified (DEPRECATED), assign address to that label.\n"
863 "Note: This command is only compatible with legacy wallets.\n",
866 "The number of required signatures out of the n keys or "
872 "The bitcoin addresses or hex-encoded public keys",
875 "bitcoin address or hex-encoded public key"},
879 "A label to assign the addresses to."},
886 "The value of the new multisig address"},
888 "The string value of the hex-encoded redemption script"},
890 "The descriptor for this multisig"},
893 "\nAdd a multisig address from 2 addresses\n" +
896 "\"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\","
897 "\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") +
898 "\nAs a JSON-RPC call\n" +
901 "\"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\","
902 "\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"")},
905 std::shared_ptr<CWallet>
const wallet =
918 if (!request.params[2].isNull()) {
922 int required = request.params[0].getInt<
int>();
926 std::vector<CPubKey> pubkeys;
927 for (
size_t i = 0; i < keys_or_addrs.size(); ++i) {
928 if (
IsHex(keys_or_addrs[i].get_str()) &&
929 (keys_or_addrs[i].get_str().length() == 66 ||
930 keys_or_addrs[i].get_str().length() == 130)) {
935 keys_or_addrs[i].get_str()));
944 required, pubkeys, output_type, spk_man, inner);
948 std::unique_ptr<Descriptor> descriptor =
954 result.
pushKV(
"descriptor", descriptor->ToString());
962 int nConf{std::numeric_limits<int>::max()};
969 const UniValue ¶ms,
bool by_label)
973 if (!params[0].
isNull()) {
974 nMinDepth = params[0].getInt<
int>();
978 bool fIncludeEmpty =
false;
979 if (!params[1].
isNull()) {
980 fIncludeEmpty = params[1].get_bool();
988 bool has_filtered_address =
false;
990 if (!by_label && params.size() > 3) {
992 pwallet->GetChainParams())) {
994 "address_filter parameter was invalid");
998 has_filtered_address =
true;
1002 std::map<CTxDestination, tallyitem> mapTally;
1003 for (
const std::pair<const TxId, CWalletTx> &pairWtx : pwallet->mapWallet) {
1010 int nDepth = pwallet->GetTxDepthInMainChain(wtx);
1011 if (nDepth < nMinDepth) {
1015 for (
const CTxOut &txout : wtx.
tx->vout) {
1021 if (has_filtered_address && !(filtered_address == address)) {
1026 if (!(mine & filter)) {
1042 std::map<std::string, tallyitem> label_tally;
1046 auto start = pwallet->m_address_book.begin();
1047 auto end = pwallet->m_address_book.end();
1049 if (has_filtered_address) {
1050 start = pwallet->m_address_book.find(filtered_address);
1052 end = std::next(start);
1056 for (
auto item_it = start; item_it != end; ++item_it) {
1057 if (item_it->second.IsChange()) {
1061 const std::string &label = item_it->second.GetLabel();
1062 std::map<CTxDestination, tallyitem>::iterator it =
1063 mapTally.find(address);
1064 if (it == mapTally.end() && !fIncludeEmpty) {
1069 int nConf = std::numeric_limits<int>::max();
1070 bool fIsWatchonly =
false;
1071 if (it != mapTally.end()) {
1072 nAmount = (*it).second.nAmount;
1073 nConf = (*it).second.nConf;
1074 fIsWatchonly = (*it).second.fIsWatchonly;
1085 obj.
pushKV(
"involvesWatchonly",
true);
1088 obj.
pushKV(
"amount", nAmount);
1089 obj.
pushKV(
"confirmations",
1090 (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
1091 obj.
pushKV(
"label", label);
1093 if (it != mapTally.end()) {
1094 for (
const uint256 &_item : (*it).second.txids) {
1098 obj.
pushKV(
"txids", transactions);
1104 for (
const auto &entry : label_tally) {
1105 Amount nAmount = entry.second.nAmount;
1106 int nConf = entry.second.nConf;
1108 if (entry.second.fIsWatchonly) {
1109 obj.
pushKV(
"involvesWatchonly",
true);
1111 obj.
pushKV(
"amount", nAmount);
1112 obj.
pushKV(
"confirmations",
1113 (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
1114 obj.
pushKV(
"label", entry.first);
1124 "listreceivedbyaddress",
1125 "List balances by receiving address.\n",
1128 "The minimum number of confirmations before payments are "
1131 "Whether to include addresses that haven't received any "
1135 "true for watch-only wallets, otherwise false"},
1136 "Whether to include watch-only addresses (see 'importaddress')."},
1138 "If present, only return information on this address."},
1150 "Only returns true if imported addresses were involved "
1155 " received by the address"},
1157 "The number of confirmations of the most recent "
1158 "transaction included"},
1160 "The label of the receiving address. The default label "
1167 "The ids of transactions received with the address"},
1176 "listreceivedbyaddress",
1177 "6, true, true, \"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\"")},
1180 std::shared_ptr<CWallet>
const wallet =
1190 pwallet->BlockUntilSyncedToCurrentChain();
1194 return ListReceived(config, pwallet, request.params,
false);
1201 "listreceivedbylabel",
1202 "List received transactions by label.\n",
1205 "The minimum number of confirmations before payments are "
1208 "Whether to include labels that haven't received any payments."},
1211 "true for watch-only wallets, otherwise false"},
1212 "Whether to include watch-only addresses (see 'importaddress')."},
1224 "Only returns true if imported addresses were involved "
1227 "The total amount received by addresses with this label"},
1229 "The number of confirmations of the most recent "
1230 "transaction included"},
1232 "The label of the receiving address. The default label "
1241 std::shared_ptr<CWallet>
const wallet =
1251 pwallet->BlockUntilSyncedToCurrentChain();
1255 return ListReceived(config, pwallet, request.params,
true);
1280 int nMinDepth,
bool fLong, Vec &ret,
1282 const std::string *filter_label)
1285 std::list<COutputEntry> listReceived;
1286 std::list<COutputEntry> listSent;
1294 if (!filter_label) {
1297 if (involvesWatchonly ||
1299 entry.
pushKV(
"involvesWatchonly",
true);
1302 entry.
pushKV(
"category",
"send");
1303 entry.
pushKV(
"amount", -s.amount);
1304 const auto *address_book_entry =
1305 pwallet->FindAddressBookEntry(s.destination);
1306 if (address_book_entry) {
1307 entry.
pushKV(
"label", address_book_entry->GetLabel());
1309 entry.
pushKV(
"vout", s.vout);
1310 entry.
pushKV(
"fee", -1 * nFee);
1314 entry.
pushKV(
"abandoned", wtx.isAbandoned());
1315 ret.push_back(entry);
1320 if (listReceived.size() > 0 &&
1321 pwallet->GetTxDepthInMainChain(wtx) >= nMinDepth) {
1324 const auto *address_book_entry =
1325 pwallet->FindAddressBookEntry(r.destination);
1326 if (address_book_entry) {
1327 label = address_book_entry->GetLabel();
1329 if (filter_label && label != *filter_label) {
1333 if (involvesWatchonly ||
1335 entry.
pushKV(
"involvesWatchonly",
true);
1338 if (wtx.IsCoinBase()) {
1339 if (pwallet->GetTxDepthInMainChain(wtx) < 1) {
1340 entry.
pushKV(
"category",
"orphan");
1341 }
else if (pwallet->IsTxImmatureCoinBase(wtx)) {
1342 entry.
pushKV(
"category",
"immature");
1344 entry.
pushKV(
"category",
"generate");
1347 entry.
pushKV(
"category",
"receive");
1349 entry.
pushKV(
"amount", r.amount);
1350 if (address_book_entry) {
1351 entry.
pushKV(
"label", label);
1353 entry.
pushKV(
"vout", r.vout);
1357 ret.push_back(entry);
1365 "The number of confirmations for the transaction. Negative "
1366 "confirmations means the\n"
1367 "transaction conflicted that many blocks ago."},
1369 "Only present if transaction only input is a coinbase one."},
1371 "Only present if we consider transaction to be trusted and so safe to "
1374 "The block hash containing the transaction."},
1376 "The block height containing the transaction."},
1378 "The index of the transaction in the block that includes it."},
1384 "Conflicting transaction ids.",
1393 "If a comment is associated with the transaction, only present if not "
1402 "If a label name is provided, this will return only incoming "
1403 "transactions paying to addresses with the specified label.\n"
1404 "\nReturns up to 'count' most recent transactions skipping the first "
1405 "'from' transactions.\n",
1408 "If set, should be a valid label name to return only incoming "
1409 "transactions with the specified label, or \"*\" to disable "
1410 "filtering and return all transactions."},
1412 "The number of transactions to return"},
1414 "The number of transactions to skip"},
1417 "true for watch-only wallets, otherwise false"},
1418 "Include transactions to watch-only addresses (see "
1419 "'importaddress')"},
1427 Cat(
Cat<std::vector<RPCResult>>(
1430 "Only returns true if imported addresses were "
1431 "involved in transaction."},
1433 "The bitcoin address of the transaction."},
1435 "The transaction category.\n"
1436 "\"send\" Transactions sent.\n"
1437 "\"receive\" Non-coinbase "
1438 "transactions received.\n"
1439 "\"generate\" Coinbase transactions "
1440 "received with more than 100 confirmations.\n"
1441 "\"immature\" Coinbase transactions "
1442 "received with 100 or fewer confirmations.\n"
1443 "\"orphan\" Orphaned coinbase "
1444 "transactions received."},
1446 "The amount in " + ticker +
1447 ". This is negative for the 'send' category, "
1449 "for all other categories"},
1451 "A comment for the address/transaction, if any"},
1454 "The amount of the fee in " + ticker +
1455 ". This is negative and only available for "
1457 "'send' category of transactions."},
1462 "'true' if the transaction has been abandoned "
1463 "(inputs are respendable). Only available for the \n"
1464 "'send' category of transactions."},
1467 RPCExamples{
"\nList the most recent 10 transactions in the systems\n" +
1469 "\nList transactions 100 to 120\n" +
1471 "\nAs a JSON-RPC call\n" +
1475 std::shared_ptr<CWallet>
const wallet =
1485 pwallet->BlockUntilSyncedToCurrentChain();
1487 const std::string *filter_label =
nullptr;
1488 if (!request.params[0].isNull() &&
1489 request.params[0].get_str() !=
"*") {
1490 filter_label = &request.params[0].get_str();
1491 if (filter_label->empty()) {
1494 "Label argument must be a valid label name or \"*\".");
1498 if (!request.params[1].isNull()) {
1499 nCount = request.params[1].getInt<
int>();
1503 if (!request.params[2].isNull()) {
1504 nFrom = request.params[2].getInt<
int>();
1519 std::vector<UniValue> ret;
1526 for (CWallet::TxItems::const_reverse_iterator it =
1528 it != txOrdered.rend(); ++it) {
1532 if (
int(ret.size()) >= (nCount + nFrom)) {
1540 if (nFrom > (
int)ret.size()) {
1543 if ((nFrom + nCount) > (
int)ret.size()) {
1544 nCount = ret.size() - nFrom;
1547 auto txs_rev_it{std::make_move_iterator(ret.rend())};
1550 result.push_backV(txs_rev_it - nFrom - nCount, txs_rev_it - nFrom);
1560 "Get all transactions in blocks since block [blockhash], or all "
1561 "transactions if omitted.\n"
1562 "If \"blockhash\" is no longer a part of the main chain, transactions "
1563 "from the fork point onward are included.\n"
1564 "Additionally, if include_removed is set, transactions affecting the "
1565 "wallet which were removed are returned in the \"removed\" array.\n",
1568 "If set, the block hash to list transactions since, otherwise "
1569 "list all transactions."},
1571 "Return the nth block hash from the main chain. e.g. 1 would mean "
1572 "the best block hash. Note: this is not used as a filter, but "
1573 "only affects [lastblock] in the return value"},
1576 "true for watch-only wallets, otherwise false"},
1577 "Include transactions to watch-only addresses (see "
1578 "'importaddress')"},
1580 "Show transactions that were removed due to a reorg in the "
1581 "\"removed\" array\n"
1583 "guaranteed to work on pruned nodes)"},
1595 Cat(
Cat<std::vector<RPCResult>>(
1598 "Only returns true if imported addresses "
1599 "were involved in transaction."},
1601 "The bitcoin address of the transaction."},
1603 "The transaction category.\n"
1604 "\"send\" Transactions "
1606 "\"receive\" Non-coinbase "
1607 "transactions received.\n"
1608 "\"generate\" Coinbase "
1609 "transactions received with more than 100 "
1611 "\"immature\" Coinbase "
1612 "transactions received with 100 or fewer "
1614 "\"orphan\" Orphaned "
1615 "coinbase transactions received."},
1617 "The amount in " + ticker +
1618 ". This is negative for the 'send' "
1619 "category, and is positive\n"
1620 "for all other categories"},
1624 "The amount of the fee in " + ticker +
1625 ". This is negative and only available "
1627 "'send' category of transactions."},
1632 "'true' if the transaction has been abandoned "
1633 "(inputs are respendable). Only available for "
1635 "'send' category of transactions."},
1637 "If a comment is associated with the "
1640 "A comment for the address/transaction, if any"},
1642 "If a comment to is associated with the "
1648 "<structure is the same as \"transactions\" above, only "
1649 "present if include_removed=true>\n"
1650 "Note: transactions that were re-added in the active chain "
1651 "will appear as-is in this array, and may thus have a "
1652 "positive confirmation count.",
1657 "The hash of the block (target_confirmations-1) from the best "
1658 "block on the main chain, or the genesis hash if the "
1659 "referenced block does not exist yet. This is typically used "
1660 "to feed back into listsinceblock the next time you call it. "
1661 "So you would generally use a target_confirmations of say 6, "
1662 "so you will be continually re-notified of transactions until "
1663 "they've reached 6 confirmations plus any new ones"},
1667 "\"000000000000000bacf66f7497b7dc45ef753ee9a"
1668 "7d38571037cdb1a57f663ad\" 6") +
1670 "\"000000000000000bacf66f7497b7dc45ef753ee9a"
1671 "7d38571037cdb1a57f663ad\", 6")},
1674 std::shared_ptr<CWallet>
const pwallet =
1685 wallet.BlockUntilSyncedToCurrentChain();
1691 std::optional<int> height;
1695 std::optional<int> altheight;
1696 int target_confirms = 1;
1700 if (!request.params[0].isNull() &&
1701 !request.params[0].get_str().empty()) {
1705 if (!
wallet.chain().findCommonAncestor(
1706 blockId,
wallet.GetLastBlockHash(),
1714 if (!request.params[1].isNull()) {
1715 target_confirms = request.params[1].getInt<
int>();
1717 if (target_confirms < 1) {
1719 "Invalid parameter");
1727 bool include_removed =
1728 (request.params[3].isNull() || request.params[3].get_bool());
1730 int depth = height ?
wallet.GetLastBlockHeight() + 1 - *height : -1;
1734 for (
const std::pair<const TxId, CWalletTx> &pairWtx :
1738 if (depth == -1 ||
wallet.GetTxDepthInMainChain(tx) < depth) {
1747 while (include_removed && altheight && *altheight > *height) {
1749 if (!
wallet.chain().findBlock(blockId,
1753 "Can't read block from disk");
1756 auto it =
wallet.mapWallet.find(tx->GetId());
1757 if (it !=
wallet.mapWallet.end()) {
1772 std::min(target_confirms,
wallet.GetLastBlockHeight() + 1);
1774 wallet.GetLastBlockHash(),
1775 wallet.GetLastBlockHeight() + 1 - target_confirms,
1779 ret.
pushKV(
"transactions", transactions);
1780 if (include_removed) {
1781 ret.
pushKV(
"removed", removed);
1794 "Get detailed information about in-wallet transaction <txid>\n",
1797 "The transaction id"},
1800 "true for watch-only wallets, otherwise false"},
1801 "Whether to include watch-only addresses in balance calculation "
1804 "Whether to include a `decoded` field containing the decoded "
1805 "transaction (equivalent to RPC decoderawtransaction)"},
1809 Cat(
Cat<std::vector<RPCResult>>(
1812 "The amount in " + ticker},
1814 "The amount of the fee in " + ticker +
1815 ". This is negative and only available for the\n"
1816 "'send' category of transactions."},
1829 "Only returns true if imported addresses were "
1830 "involved in transaction."},
1832 "The bitcoin address involved in the "
1835 "The transaction category.\n"
1836 "\"send\" Transactions sent.\n"
1837 "\"receive\" Non-coinbase "
1838 "transactions received.\n"
1839 "\"generate\" Coinbase "
1840 "transactions received with more than 100 "
1842 "\"immature\" Coinbase "
1843 "transactions received with 100 or fewer "
1845 "\"orphan\" Orphaned coinbase "
1846 "transactions received."},
1848 "The amount in " + ticker},
1850 "A comment for the address/transaction, if any"},
1853 "The amount of the fee in " + ticker +
1854 ". This is negative and only available for "
1856 "'send' category of transactions."},
1858 "'true' if the transaction has been abandoned "
1859 "(inputs are respendable). Only available for "
1861 "'send' category of transactions."},
1865 "Raw data for transaction"},
1868 "Optional, the decoded transaction (only present when "
1869 "`verbose` is passed)",
1872 "Equivalent to the RPC decoderawtransaction method, "
1873 "or the RPC getrawtransaction method when `verbose` "
1878 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1879 "5cf302fc80e9d5fbf5d48d\"") +
1881 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1882 "5cf302fc80e9d5fbf5d48d\" true") +
1884 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1885 "5cf302fc80e9d5fbf5d48d\" false true") +
1887 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1888 "5cf302fc80e9d5fbf5d48d\"")},
1891 std::shared_ptr<CWallet>
const wallet =
1901 pwallet->BlockUntilSyncedToCurrentChain();
1912 bool verbose = request.params[2].isNull()
1914 : request.params[2].get_bool();
1917 auto it = pwallet->mapWallet.find(txid);
1918 if (it == pwallet->mapWallet.end()) {
1920 "Invalid or non-wallet transaction id");
1926 Amount nNet = nCredit - nDebit;
1928 ? wtx.
tx->GetValueOut() - nDebit
1931 entry.
pushKV(
"amount", nNet - nFee);
1933 entry.
pushKV(
"fee", nFee);
1941 entry.
pushKV(
"details", details);
1944 entry.
pushKV(
"hex", strHex);
1949 entry.
pushKV(
"decoded", decoded);
1959 "abandontransaction",
1960 "Mark in-wallet transaction <txid> as abandoned\n"
1961 "This will mark this transaction and all its in-wallet descendants as "
1962 "abandoned which will allow\n"
1963 "for their inputs to be respent. It can be used to replace \"stuck\" "
1964 "or evicted transactions.\n"
1965 "It only works on transactions which are not included in a block and "
1966 "are not currently in the mempool.\n"
1967 "It has no effect on transactions which are already abandoned.\n",
1970 "The transaction id"},
1974 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1975 "5cf302fc80e9d5fbf5d48d\"") +
1977 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1978 "5cf302fc80e9d5fbf5d48d\"")},
1981 std::shared_ptr<CWallet>
const wallet =
1991 pwallet->BlockUntilSyncedToCurrentChain();
1997 if (!pwallet->mapWallet.count(txid)) {
1999 "Invalid or non-wallet transaction id");
2004 "Transaction not eligible for abandonment");
2018 "The new keypool size"},
2025 std::shared_ptr<CWallet>
const wallet =
2036 "Error: Private keys are disabled for this wallet");
2043 unsigned int kpSize = 0;
2044 if (!request.params[0].isNull()) {
2045 if (request.params[0].getInt<
int>() < 0) {
2048 "Invalid parameter, expected valid size.");
2050 kpSize = (
unsigned int)request.params[0].getInt<
int>();
2058 "Error refreshing keypool.");
2069 "Updates list of temporarily unspendable outputs.\n"
2070 "Temporarily lock (unlock=false) or unlock (unlock=true) specified "
2071 "transaction outputs.\n"
2072 "If no transaction outputs are specified when unlocking then all "
2073 "current locked transaction outputs are unlocked.\n"
2074 "A locked transaction output will not be chosen by automatic coin "
2075 "selection, when spending bitcoins.\n"
2076 "Manually selected coins are automatically unlocked.\n"
2077 "Locks are stored in memory only. Nodes start with zero locked "
2078 "outputs, and the locked output list\n"
2079 "is always cleared (by virtue of process exit) when a node stops or "
2081 "Also see the listunspent call\n",
2084 "Whether to unlock (true) or lock (false) the specified "
2090 "The transaction outputs and within each, txid (string) vout "
2102 "The output number"},
2109 "Whether the command was successful or not"},
2111 "\nList the unspent transactions\n" +
2113 "\nLock an unspent transaction\n" +
2116 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2117 "b764ed838b5655e72f463568df1aadf0\\\""
2118 ",\\\"vout\\\":1}]\"") +
2119 "\nList the locked transactions\n" +
2121 "\nUnlock the transaction again\n" +
2124 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2125 "b764ed838b5655e72f463568df1aadf0\\\""
2126 ",\\\"vout\\\":1}]\"") +
2127 "\nAs a JSON-RPC call\n" +
2130 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2131 "b764ed838b5655e72f463568df1aadf0\\\""
2132 ",\\\"vout\\\":1}]\"")},
2135 std::shared_ptr<CWallet>
const wallet =
2145 pwallet->BlockUntilSyncedToCurrentChain();
2149 bool fUnlock = request.params[0].get_bool();
2151 if (request.params[1].isNull()) {
2162 std::vector<COutPoint> outputs;
2165 for (
size_t idx = 0; idx < output_params.
size(); idx++) {
2177 "Invalid parameter, vout cannot be negative");
2181 const auto it = pwallet->mapWallet.find(txid);
2182 if (it == pwallet->mapWallet.end()) {
2185 "Invalid parameter, unknown transaction");
2188 const COutPoint output(txid, nOutput);
2190 if (output.GetN() >= trans.
tx->vout.size()) {
2193 "Invalid parameter, vout index out of bounds");
2196 if (pwallet->
IsSpent(output)) {
2199 "Invalid parameter, expected unspent output");
2203 if (fUnlock && !is_locked) {
2206 "Invalid parameter, expected locked output");
2209 if (!fUnlock && is_locked) {
2212 "Invalid parameter, output already locked");
2215 outputs.push_back(output);
2219 for (
const COutPoint &output : outputs) {
2235 "Returns list of temporarily unspendable outputs.\n"
2236 "See the lockunspent call to lock and unlock transactions for "
2248 "The transaction id locked"},
2253 "\nList the unspent transactions\n" +
2255 "\nLock an unspent transaction\n" +
2258 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2259 "b764ed838b5655e72f463568df1aadf0\\\""
2260 ",\\\"vout\\\":1}]\"") +
2261 "\nList the locked transactions\n" +
2263 "\nUnlock the transaction again\n" +
2266 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2267 "b764ed838b5655e72f463568df1aadf0\\\""
2268 ",\\\"vout\\\":1}]\"") +
2269 "\nAs a JSON-RPC call\n" +
HelpExampleRpc(
"listlockunspent",
"")},
2272 std::shared_ptr<CWallet>
const wallet =
2281 std::vector<COutPoint> vOutpts;
2286 for (
const COutPoint &output : vOutpts) {
2289 o.
pushKV(
"txid", output.GetTxId().GetHex());
2290 o.
pushKV(
"vout",
int(output.GetN()));
2302 "Set the transaction fee per kB for this wallet. Overrides the "
2303 "global -paytxfee command line parameter.\n"
2304 "Can be deactivated by passing 0 as the fee. In that case automatic "
2305 "fee selection will be used by default.\n",
2315 std::shared_ptr<CWallet>
const wallet =
2325 CFeeRate tx_fee_rate(nAmount, 1000);
2329 }
else if (tx_fee_rate < pwallet->chain().relayMinFee()) {
2332 strprintf(
"txfee cannot be less than min relay tx fee (%s)",
2334 }
else if (tx_fee_rate < pwallet->m_min_fee) {
2337 strprintf(
"txfee cannot be less than wallet min fee (%s)",
2339 }
else if (tx_fee_rate > max_tx_fee_rate) {
2343 "txfee cannot be more than wallet max tx fee (%s)",
2365 "balances from outputs that the wallet can sign",
2368 "trusted balance (outputs created by the wallet or "
2369 "confirmed outputs)"},
2371 "untrusted pending balance (outputs created by "
2372 "others that are in the mempool)"},
2374 "balance from immature coinbase outputs"},
2376 "(only present if avoid_reuse is set) balance from "
2377 "coins sent to addresses that were previously "
2378 "spent from (potentially privacy violating)"},
2382 "watchonly balances (not present if wallet does not "
2386 "trusted balance (outputs created by the wallet or "
2387 "confirmed outputs)"},
2389 "untrusted pending balance (outputs created by "
2390 "others that are in the mempool)"},
2392 "balance from immature coinbase outputs"},
2399 std::shared_ptr<CWallet>
const rpc_wallet =
2409 wallet.BlockUntilSyncedToCurrentChain();
2417 balances_mine.pushKV(
"trusted", bal.m_mine_trusted);
2418 balances_mine.pushKV(
"untrusted_pending",
2419 bal.m_mine_untrusted_pending);
2420 balances_mine.pushKV(
"immature", bal.m_mine_immature);
2426 balances_mine.pushKV(
"used",
2427 full_bal.m_mine_trusted +
2428 full_bal.m_mine_untrusted_pending -
2429 bal.m_mine_trusted -
2430 bal.m_mine_untrusted_pending);
2432 balances.pushKV(
"mine", balances_mine);
2434 auto spk_man =
wallet.GetLegacyScriptPubKeyMan();
2435 if (spk_man && spk_man->HaveWatchOnly()) {
2437 balances_watchonly.pushKV(
"trusted", bal.m_watchonly_trusted);
2438 balances_watchonly.pushKV(
"untrusted_pending",
2439 bal.m_watchonly_untrusted_pending);
2440 balances_watchonly.pushKV(
"immature", bal.m_watchonly_immature);
2441 balances.pushKV(
"watchonly", balances_watchonly);
2451 "Returns an object containing various wallet state info.\n",
2461 "DEPRECATED. Identical to getbalances().mine.trusted"},
2463 "DEPRECATED. Identical to "
2464 "getbalances().mine.untrusted_pending"},
2466 "DEPRECATED. Identical to getbalances().mine.immature"},
2468 "the total number of transactions in the wallet"},
2471 " of the oldest pre-generated key in the key pool. "
2472 "Legacy wallets only."},
2474 "how many new keys are pre-generated (only counts external "
2477 "how many new keys are pre-generated for internal use (used "
2478 "for change outputs, only appears if the wallet is using "
2479 "this feature, otherwise external keys are used)"},
2483 " until which the wallet is unlocked for transfers, or 0 "
2484 "if the wallet is locked (only present for "
2485 "passphrase-encrypted wallets)"},
2487 "the transaction fee configuration, set in " +
2490 "the Hash160 of the HD seed (only present when HD is "
2493 "false if privatekeys are disabled for this wallet (enforced "
2494 "watch-only wallet)"},
2497 "current scanning details, or false if no scan is in "
2501 "elapsed seconds since scan start"},
2503 "scanning progress percentage [0.0, 1.0]"},
2507 "whether this wallet tracks clean/dirty coins in terms of "
2510 "whether this wallet uses descriptors for scriptPubKey "
2518 std::shared_ptr<CWallet>
const wallet =
2528 pwallet->BlockUntilSyncedToCurrentChain();
2539 obj.
pushKV(
"balance", bal.m_mine_trusted);
2540 obj.
pushKV(
"unconfirmed_balance", bal.m_mine_untrusted_pending);
2541 obj.
pushKV(
"immature_balance", bal.m_mine_immature);
2542 obj.
pushKV(
"txcount", (
int)pwallet->mapWallet.size());
2543 if (kp_oldest > 0) {
2544 obj.
pushKV(
"keypoololdest", kp_oldest);
2546 obj.
pushKV(
"keypoolsize", (int64_t)kpExternalSize);
2558 obj.
pushKV(
"keypoolsize_hd_internal",
2562 obj.
pushKV(
"unlocked_until", pwallet->nRelockTime);
2566 "private_keys_enabled",
2570 scanning.
pushKV(
"duration", Ticks<std::chrono::seconds>(
2573 obj.
pushKV(
"scanning", scanning);
2575 obj.
pushKV(
"scanning",
false);
2577 obj.
pushKV(
"avoid_reuse",
2579 obj.
pushKV(
"descriptors",
2589 "Returns a list of wallets in the wallet directory.\n",
2615 wallet.pushKV(
"name", path.u8string());
2620 result.
pushKV(
"wallets", wallets);
2629 "Returns a list of currently loaded wallets.\n"
2630 "For full information on the wallet, use \"getwalletinfo\"\n",
2658 "Loads a wallet from a wallet file or directory."
2659 "\nNote that all wallet command-line options used when starting "
2661 "\napplied to the new wallet (eg -rescan, etc).\n",
2664 "The wallet directory or .dat file."},
2666 "Save wallet name to persistent settings and load on startup. "
2667 "True to add wallet to startup list, false to remove, null to "
2668 "leave unchanged."},
2675 "The wallet name if loaded successfully."},
2677 "Warning message if wallet was not loaded cleanly."},
2684 const std::string
name(request.params[0].get_str());
2690 std::vector<bilingual_str> warnings;
2691 std::optional<bool> load_on_start =
2692 request.params[1].isNull()
2694 : std::optional<bool>(request.params[1].get_bool());
2696 context,
name, load_on_start, options, status, error, warnings);
2710 std::string
flags =
"";
2713 flags += (
flags ==
"" ?
"" :
", ") + it.first;
2718 "Change the state of the given wallet flag for a wallet.\n",
2721 "The name of the flag to change. Current available flags: " +
2731 "The name of the flag that was modified"},
2733 "The new state of the flag"},
2735 "Any warnings associated with the change"},
2741 std::shared_ptr<CWallet>
const wallet =
2748 std::string flag_str = request.params[0].get_str();
2750 request.params[1].isNull() || request.params[1].get_bool();
2755 strprintf(
"Unknown wallet flag: %s", flag_str));
2763 strprintf(
"Wallet flag is immutable: %s", flag_str));
2771 strprintf(
"Wallet flag is already set to %s: %s",
2772 value ?
"true" :
"false", flag_str));
2775 res.
pushKV(
"flag_name", flag_str);
2776 res.
pushKV(
"flag_state", value);
2796 "Creates and loads a new wallet.\n",
2799 "The name for the new wallet. If this is a path, the wallet will "
2800 "be created at the path location."},
2802 "Disable the possibility of private keys (only watchonlys are "
2803 "possible in this mode)."},
2805 "Create a blank wallet. A blank wallet has no keys or HD seed. "
2806 "One can be set using sethdseed."},
2808 "Encrypt the wallet with this passphrase."},
2810 "Keep track of coin reuse, and treat dirty and clean coins "
2811 "differently with privacy considerations in mind."},
2813 "Create a native descriptor wallet. The wallet will use "
2814 "descriptors internally to handle address creation"},
2816 "Save wallet name to persistent settings and load on startup. "
2817 "True to add wallet to startup list, false to remove, null to "
2818 "leave unchanged."},
2825 "The wallet name if created successfully. If the wallet "
2826 "was created using a full path, the wallet_name will be "
2829 "Warning message if wallet was not loaded cleanly."},
2835 {
"avoid_reuse",
true},
2836 {
"descriptors",
true},
2837 {
"load_on_startup",
true}}) +
2839 {
"avoid_reuse",
true},
2840 {
"descriptors",
true},
2841 {
"load_on_startup",
true}})},
2846 if (!request.params[1].isNull() && request.params[1].get_bool()) {
2850 if (!request.params[2].isNull() && request.params[2].get_bool()) {
2855 passphrase.reserve(100);
2856 std::vector<bilingual_str> warnings;
2857 if (!request.params[3].isNull()) {
2858 passphrase = request.params[3].get_str().c_str();
2859 if (passphrase.empty()) {
2862 "Empty string given as passphrase, wallet will "
2863 "not be encrypted."));
2867 if (!request.params[4].isNull() && request.params[4].get_bool()) {
2870 if (!request.params[5].isNull() && request.params[5].get_bool()) {
2873 "Wallet is an experimental descriptor wallet"));
2882 std::optional<bool> load_on_start =
2883 request.params[6].isNull()
2885 : std::make_optional<bool>(request.params[6].get_bool());
2886 std::shared_ptr<CWallet>
wallet =
2888 load_on_start, options, status, error, warnings);
2908 "Unloads the wallet referenced by the request endpoint otherwise "
2909 "unloads the wallet specified in the argument.\n"
2910 "Specifying the wallet name on a wallet endpoint is invalid.",
2914 "The name of the wallet to unload."},
2916 "Save wallet name to persistent settings and load on startup. "
2917 "True to add wallet to startup list, false to remove, null to "
2918 "leave unchanged."},
2925 "Warning message if wallet was not unloaded cleanly."},
2931 std::string wallet_name;
2933 if (!request.params[0].isNull()) {
2935 "Cannot unload the requested wallet");
2938 wallet_name = request.params[0].get_str();
2946 "Requested wallet does not exist or is not loaded");
2952 std::vector<bilingual_str> warnings;
2953 std::optional<bool> load_on_start{self.
MaybeArg<
bool>(1)};
2956 "Requested wallet already unloaded");
2973 "Returns array of unspent transaction outputs\n"
2974 "with between minconf and maxconf (inclusive) confirmations.\n"
2975 "Optionally filter to only include txouts paid to specified "
2979 "The minimum confirmations to filter"},
2981 "The maximum confirmations to filter"},
2986 "The bitcoin addresses to filter",
2993 "Include outputs that are not safe to spend\n"
2994 " See description of \"safe\" attribute below."},
2998 "JSON with query options",
3002 "Minimum value of each UTXO in " + ticker +
""},
3005 "Maximum value of each UTXO in " + ticker +
""},
3010 "Minimum sum value of all UTXOs in " + ticker +
""},
3027 "The associated label, or \"\" for the default label"},
3030 "the transaction output amount in " + ticker},
3032 "The number of confirmations"},
3035 "DEPRECATED: The number of in-mempool ancestor "
3036 "transactions, including this one (if transaction is in "
3037 "the mempool). Only displayed if the "
3038 "-deprecatedrpc=mempool_ancestors_descendants option is "
3041 "DEPRECATED: The virtual transaction size of in-mempool "
3042 " ancestors, including this one (if transaction is in "
3043 "the mempool). Only displayed if the "
3044 "-deprecatedrpc=mempool_ancestors_descendants option is "
3048 "DEPRECATED: The total fees of in-mempool ancestors "
3049 "(including this one) with fee deltas used for mining "
3052 " (if transaction is in the mempool). Only "
3054 "-deprecatedrpc=mempool_ancestors_descendants option "
3058 "The redeemScript if scriptPubKey is P2SH"},
3060 "Whether we have the private keys to spend this output"},
3062 "Whether we know how to spend this output, ignoring the "
3065 "(only present if avoid_reuse is set) Whether this "
3066 "output is reused/dirty (sent to an address that was "
3067 "previously spent from)"},
3069 "(only when solvable) A descriptor for spending this "
3072 "Whether this output is considered safe to spend. "
3073 "Unconfirmed transactions\n"
3074 "from outside keys are considered unsafe\n"
3075 "and are not eligible for spending by fundrawtransaction "
3076 "and sendtoaddress."},
3083 "\"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\","
3084 "\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"") +
3087 "\"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\","
3088 "\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"") +
3091 "6 9999999 '[]' true '{ \"minimumAmount\": 0.005 }'") +
3094 "6, 9999999, [] , true, { \"minimumAmount\": 0.005 } ")},
3097 std::shared_ptr<CWallet>
const wallet =
3105 if (!request.params[0].isNull()) {
3106 nMinDepth = request.params[0].getInt<
int>();
3109 int nMaxDepth = 9999999;
3110 if (!request.params[1].isNull()) {
3111 nMaxDepth = request.params[1].getInt<
int>();
3114 std::set<CTxDestination> destinations;
3115 if (!request.params[2].isNull()) {
3117 for (
size_t idx = 0; idx < inputs.
size(); idx++) {
3118 const UniValue &input = inputs[idx];
3124 std::string(
"Invalid Bitcoin address: ") +
3127 if (!destinations.insert(dest).second) {
3131 "Invalid parameter, duplicated address: ") +
3137 bool include_unsafe =
true;
3138 if (!request.params[3].isNull()) {
3139 include_unsafe = request.params[3].get_bool();
3145 uint64_t nMaximumCount = 0;
3147 if (!request.params[4].isNull()) {
3160 if (options.
exists(
"minimumAmount")) {
3164 if (options.
exists(
"maximumAmount")) {
3168 if (options.
exists(
"minimumSumAmount")) {
3173 if (options.
exists(
"maximumCount")) {
3174 nMaximumCount = options[
"maximumCount"].
getInt<int64_t>();
3181 pwallet->BlockUntilSyncedToCurrentChain();
3184 std::vector<COutput> vecOutputs;
3193 nMaximumAmount, nMinimumSumAmount,
3199 const bool avoid_reuse =
3202 for (
const COutput &out : vecOutputs) {
3204 const CScript &scriptPubKey =
3205 out.tx->tx->vout[out.i].scriptPubKey;
3208 avoid_reuse && pwallet->
IsSpentKey(out.tx->GetId(), out.i);
3210 if (destinations.size() &&
3211 (!fValidAddress || !destinations.count(address))) {
3216 entry.
pushKV(
"txid", out.tx->GetId().GetHex());
3217 entry.
pushKV(
"vout", out.i);
3219 if (fValidAddress) {
3222 const auto *address_book_entry =
3224 if (address_book_entry) {
3225 entry.
pushKV(
"label", address_book_entry->GetLabel());
3228 std::unique_ptr<SigningProvider> provider =
3231 if (scriptPubKey.IsPayToScriptHash()) {
3233 CScriptID(std::get<ScriptHash>(address));
3236 entry.
pushKV(
"redeemScript",
3244 entry.
pushKV(
"amount", out.tx->tx->vout[out.i].nValue);
3245 entry.
pushKV(
"confirmations", out.nDepth);
3246 entry.
pushKV(
"spendable", out.fSpendable);
3247 entry.
pushKV(
"solvable", out.fSolvable);
3248 if (out.fSolvable) {
3249 std::unique_ptr<SigningProvider> provider =
3254 entry.
pushKV(
"desc", descriptor->ToString());
3258 entry.
pushKV(
"reused", reused);
3260 entry.
pushKV(
"safe", out.fSafe);
3270 Amount &fee_out,
int &change_position,
3274 pwallet->BlockUntilSyncedToCurrentChain();
3276 change_position = -1;
3277 bool lockUnspents =
false;
3279 std::set<int> setSubtractFeeFromOutputs;
3311 if (options.
exists(
"add_inputs")) {
3315 if (options.
exists(
"changeAddress") ||
3316 options.
exists(
"change_address")) {
3317 const std::string change_address_str =
3318 (options.
exists(
"change_address")
3319 ? options[
"change_address"]
3320 : options[
"changeAddress"])
3328 "Change address must be a valid bitcoin address");
3334 if (options.
exists(
"changePosition") ||
3335 options.
exists(
"change_position")) {
3336 change_position = (options.
exists(
"change_position")
3337 ? options[
"change_position"]
3338 : options[
"changePosition"])
3342 const UniValue include_watching_option =
3343 options.
exists(
"include_watching") ? options[
"include_watching"]
3344 : options[
"includeWatching"];
3348 if (options.
exists(
"lockUnspents") ||
3349 options.
exists(
"lock_unspents")) {
3351 (options.
exists(
"lock_unspents") ? options[
"lock_unspents"]
3352 : options[
"lockUnspents"])
3356 if (options.
exists(
"include_unsafe")) {
3358 options[
"include_unsafe"].
get_bool();
3361 if (options.
exists(
"feeRate") || options.
exists(
"fee_rate")) {
3363 options.
exists(
"fee_rate") ? options[
"fee_rate"]
3364 : options[
"feeRate"]));
3368 if (options.
exists(
"subtractFeeFromOutputs") ||
3369 options.
exists(
"subtract_fee_from_outputs")) {
3370 subtractFeeFromOutputs =
3371 (options.
exists(
"subtract_fee_from_outputs")
3372 ? options[
"subtract_fee_from_outputs"]
3373 : options[
"subtractFeeFromOutputs"])
3383 if (tx.
vout.size() == 0) {
3385 "TX must have at least one output");
3388 if (change_position != -1 &&
3389 (change_position < 0 ||
3390 (
unsigned int)change_position > tx.
vout.size())) {
3392 "changePosition out of bounds");
3395 for (
size_t idx = 0; idx < subtractFeeFromOutputs.
size(); idx++) {
3396 int pos = subtractFeeFromOutputs[idx].
getInt<
int>();
3397 if (setSubtractFeeFromOutputs.count(pos)) {
3400 strprintf(
"Invalid parameter, duplicated position: %d", pos));
3405 strprintf(
"Invalid parameter, negative position: %d", pos));
3407 if (pos >=
int(tx.
vout.size())) {
3410 strprintf(
"Invalid parameter, position too large: %d", pos));
3412 setSubtractFeeFromOutputs.insert(pos);
3418 lockUnspents, setSubtractFeeFromOutputs,
3427 "fundrawtransaction",
3428 "If the transaction has no inputs, they will be automatically selected "
3429 "to meet its out value.\n"
3430 "It will add at most one change output to the outputs.\n"
3431 "No existing outputs will be modified unless "
3432 "\"subtractFeeFromOutputs\" is specified.\n"
3433 "Note that inputs which were signed may need to be resigned after "
3434 "completion since in/outputs have been added.\n"
3435 "The inputs added will not be signed, use signrawtransactionwithkey or "
3436 "signrawtransactionwithwallet for that.\n"
3437 "Note that all existing inputs must have their previous output "
3438 "transaction be in the wallet.\n"
3439 "Note that all inputs selected must be of standard form and P2SH "
3441 "in the wallet using importaddress or addmultisigaddress (to calculate "
3443 "You can see whether this is the case by checking the \"solvable\" "
3444 "field in the listunspent output.\n"
3445 "Only pay-to-pubkey, multisig, and P2SH versions thereof are currently "
3446 "supported for watch-only\n",
3449 "The hex string of the raw transaction"},
3453 "For backward compatibility: passing in a true instead of an "
3454 "object will result in {\"includeWatching\":true}",
3457 "For a transaction with existing inputs, automatically "
3458 "include more if they are not enough."},
3460 "Include inputs that are not safe to spend (unconfirmed "
3461 "transactions from outside keys).\n"
3462 "Warning: the resulting transaction may become invalid if "
3463 "one of the unsafe inputs disappears.\n"
3464 "If that happens, you will need to fund the transaction with "
3465 "different inputs and republish it."},
3468 "The bitcoin address to receive the change"},
3471 "The index of the change output"},
3474 "true for watch-only wallets, otherwise false"},
3475 "Also select inputs which are watch only.\n"
3476 "Only solvable inputs can be used. Watch-only destinations "
3477 "are solvable if the public key and/or output script was "
3479 "e.g. with 'importpubkey' or 'importmulti' with the "
3480 "'pubkeys' or 'desc' field."},
3482 "Lock selected unspent outputs"},
3485 "not set: makes wallet determine the fee"},
3486 "Set a specific fee rate in " + ticker +
"/kB",
3489 "subtractFeeFromOutputs",
3493 " The fee will be equally "
3494 "deducted from the amount of each specified output.\n"
3495 " Those recipients will "
3496 "receive less bitcoins than you enter in their "
3497 "corresponding amount field.\n"
3498 " If no outputs are "
3499 "specified here, the sender pays the fee.",
3503 "The zero-based output index, before a change output "
3509 .oneline_description =
"options"}},
3516 "The resulting raw transaction (hex-encoded string)"},
3518 "Fee in " + ticker +
" the resulting transaction pays"},
3520 "The position of the added change output, or -1"},
3523 "\nCreate a transaction with no inputs\n" +
3525 "\"[]\" \"{\\\"myaddress\\\":10000}\"") +
3526 "\nAdd sufficient unsigned inputs to meet the output value\n" +
3528 "\nSign the transaction\n" +
3530 "\"fundedtransactionhex\"") +
3531 "\nSend the transaction\n" +
3532 HelpExampleCli(
"sendrawtransaction",
"\"signedtransactionhex\"")},
3535 std::shared_ptr<CWallet>
const wallet =
3544 if (!
DecodeHexTx(tx, request.params[0].get_str())) {
3546 "TX decode failed");
3550 int change_position;
3556 request.params[1], coin_control);
3560 result.
pushKV(
"fee", fee);
3561 result.
pushKV(
"changepos", change_position);
3570 "signrawtransactionwithwallet",
3571 "Sign inputs for raw transaction (serialized, hex-encoded).\n"
3572 "The second optional argument (may be null) is an array of previous "
3573 "transaction outputs that\n"
3574 "this transaction depends on but may not yet be in the block chain.\n" +
3578 "The transaction hex string"},
3583 "The previous dependent transaction outputs",
3594 "The output number"},
3606 "The signature hash type. Must be one of\n"
3608 " \"NONE|FORKID\"\n"
3609 " \"SINGLE|FORKID\"\n"
3610 " \"ALL|FORKID|ANYONECANPAY\"\n"
3611 " \"NONE|FORKID|ANYONECANPAY\"\n"
3612 " \"SINGLE|FORKID|ANYONECANPAY\""},
3620 "The hex-encoded raw transaction with signature(s)"},
3622 "If the transaction has a complete set of signatures"},
3626 "Script verification errors (if there are any)",
3633 "The hash of the referenced, previous transaction"},
3635 "The index of the output to spent and used as "
3638 "The hex-encoded signature script"},
3640 "Script sequence number"},
3642 "Verification or signing error related to the "
3652 std::shared_ptr<CWallet>
const wallet =
3660 if (!
DecodeHexTx(mtx, request.params[0].get_str())) {
3662 "TX decode failed");
3670 std::map<COutPoint, Coin> coins;
3671 for (
const CTxIn &txin : mtx.
vin) {
3673 coins[txin.prevout];
3683 "Signature must use SIGHASH_FORKID");
3687 std::map<int, std::string> input_errors;
3702 "Rescan the local blockchain for wallet related transactions.\n"
3703 "Note: Use \"getwalletinfo\" to query the scanning progress.\n",
3706 "block height where the rescan should start"},
3708 "the last block height that should be scanned"},
3716 "The block height where the rescan started (the requested "
3719 "The height of the last rescanned block. May be null in rare "
3720 "cases if there was a reorg and the call didn't scan any "
3721 "blocks because they were already scanned in the background."},
3727 std::shared_ptr<CWallet>
const wallet =
3737 "Wallet is currently rescanning. Abort "
3738 "existing rescan or wait.");
3741 int start_height = 0;
3742 std::optional<int> stop_height;
3748 if (!request.params[0].isNull()) {
3749 start_height = request.params[0].getInt<
int>();
3750 if (start_height < 0 || start_height > tip_height) {
3752 "Invalid start_height");
3756 if (!request.params[1].isNull()) {
3757 stop_height = request.params[1].getInt<
int>();
3758 if (*stop_height < 0 || *stop_height > tip_height) {
3760 "Invalid stop_height");
3761 }
else if (*stop_height < start_height) {
3764 "stop_height must be greater than start_height");
3770 start_height, stop_height)) {
3774 "Can't rescan beyond pruned data. "
3775 "Use RPC call getblockchaininfo to "
3776 "determine your pruned height.");
3781 "Failed to rescan unavailable blocks likely due to "
3782 "an in-progress assumeutxo background sync. Check "
3783 "logs or getchainstates RPC for assumeutxo "
3784 "background sync progress and try again later.");
3788 "Failed to rescan unavailable blocks, potentially "
3789 "caused by data corruption. If the issue persists you "
3790 "may want to reindex (see -reindex option).");
3799 start_block, start_height, stop_height, reserver,
3807 "Rescan failed. Potentially corrupted data files.");
3814 response.pushKV(
"start_height", start_height);
3829 std::vector<std::vector<uint8_t>> solutions_data;
3840 UniValue wallet_detail = std::visit(*
this, embedded);
3841 subobj.
pushKVs(wallet_detail);
3846 if (subobj.
exists(
"pubkey")) {
3847 obj.
pushKV(
"pubkey", subobj[
"pubkey"]);
3849 obj.
pushKV(
"embedded", std::move(subobj));
3855 obj.
pushKV(
"sigsrequired", solutions_data[0][0]);
3857 for (
size_t i = 1; i < solutions_data.size() - 1; ++i) {
3858 CPubKey key(solutions_data[i].begin(), solutions_data[i].end());
3861 obj.
pushKV(
"pubkeys", std::move(pubkeys));
3899 std::unique_ptr<SigningProvider> provider =
nullptr;
3910 const bool verbose) {
3922 "Return information about the given bitcoin address.\n"
3923 "Some of the information will only be present if the address is in the "
3927 "The bitcoin address for which to get information."},
3935 "The bitcoin address validated."},
3937 "The hex-encoded scriptPubKey generated by the address."},
3940 "If the address is watchonly."},
3942 "If we know how to spend coins sent to this address, ignoring "
3943 "the possible lack of private keys."},
3945 "A descriptor for spending coins sent to this address (only "
3949 "If the address was used for change output."},
3951 "The output script type. Only if isscript is true and the "
3952 "redeemscript is known. Possible\n"
3954 "types: nonstandard, pubkey, pubkeyhash, scripthash, "
3955 "multisig, nulldata."},
3957 "The redeemscript for the p2sh address."},
3961 "Array of pubkeys associated with the known redeemscript "
3962 "(only if script is multisig).",
3967 "The number of signatures required to spend multisig output "
3968 "(only if script is multisig)."},
3970 "The hex value of the raw public key for single-key addresses "
3971 "(possibly embedded in P2SH)."},
3975 "Information about the address embedded in P2SH, if "
3976 "relevant and known.",
3979 "Includes all getaddressinfo output fields for the "
3980 "embedded address excluding metadata (timestamp, "
3981 "hdkeypath, hdseedid)\n"
3982 "and relation to the wallet (ismine, iswatchonly)."},
3985 "If the pubkey is compressed."},
3987 "The creation time of the key, if available, expressed in " +
3990 "The HD keypath, if the key is HD and available."},
3992 "The Hash160 of the HD seed."},
3994 true,
"The fingerprint of the master key."},
3997 "Array of labels associated with the address. Currently "
3998 "limited to one label but returned\n"
3999 "as an array to keep the API stable if multiple labels are "
4000 "enabled in the future.",
4003 "Label name (defaults to \"\")."},
4010 std::shared_ptr<CWallet>
const wallet =
4021 wallet->GetChainParams());
4029 ret.
pushKV(
"address", currentAddress);
4034 std::unique_ptr<SigningProvider> provider =
4040 bool solvable = provider &&
IsSolvable(*provider, scriptPubKey);
4041 ret.
pushKV(
"solvable", solvable);
4059 if (
const std::unique_ptr<CKeyMetadata> meta =
4061 ret.
pushKV(
"timestamp", meta->nCreateTime);
4062 if (meta->has_key_origin) {
4065 ret.
pushKV(
"hdseedid", meta->hd_seed_id.GetHex());
4066 ret.
pushKV(
"hdmasterfingerprint",
4067 HexStr(meta->key_origin.fingerprint));
4078 const auto *address_book_entry =
4080 if (address_book_entry) {
4081 labels.
push_back(address_book_entry->GetLabel());
4083 ret.
pushKV(
"labels", std::move(labels));
4092 "getaddressesbylabel",
4093 "Returns the list of addresses assigned the specified label.\n",
4099 "json object with addresses as keys",
4103 "Information about address",
4106 "Purpose of address (\"send\" for sending address, "
4107 "\"receive\" for receiving address)"},
4114 std::shared_ptr<CWallet>
const wallet =
4127 std::set<std::string> addresses;
4128 for (
const std::pair<const CTxDestination, CAddressBookData> &item :
4129 pwallet->m_address_book) {
4130 if (item.second.IsChange()) {
4133 if (item.second.GetLabel() == label) {
4151 std::string(
"No addresses with label " + label));
4162 "Returns the list of all labels, or labels that are assigned to "
4163 "addresses with a specific purpose.\n",
4166 "Address purpose to list labels for ('send','receive'). An empty "
4167 "string is the same as not providing this argument."},
4176 "\nList labels that have receiving addresses\n" +
4178 "\nList labels that have sending addresses\n" +
4180 "\nAs a JSON-RPC call\n" +
4184 std::shared_ptr<CWallet>
const wallet =
4193 std::string purpose;
4194 if (!request.params[0].isNull()) {
4195 purpose = request.params[0].get_str();
4200 std::set<std::string> label_set;
4201 for (
const std::pair<const CTxDestination, CAddressBookData>
4202 &entry : pwallet->m_address_book) {
4203 if (entry.second.IsChange()) {
4206 if (purpose.empty() || entry.second.purpose == purpose) {
4207 label_set.insert(entry.second.GetLabel());
4212 for (
const std::string &
name : label_set) {
4224 "EXPERIMENTAL warning: this call may be changed in future releases.\n"
4225 "\nSend a transaction.\n",
4230 "A JSON array with outputs (key-value pairs), where none of "
4231 "the keys are duplicated.\n"
4232 "That is, each address can only appear once and there can only "
4233 "be one 'data' object.\n"
4234 "For convenience, a dictionary, which holds the key-value "
4235 "pairs directly, is also accepted.",
4244 "A key-value pair. The key (string) is the "
4245 "bitcoin address, the value (float or string) is "
4257 "A key-value pair. The key must be \"data\", the "
4258 "value is hex-encoded data"},
4269 "If inputs are specified, automatically include more if they "
4272 "Include inputs that are not safe to spend (unconfirmed "
4273 "transactions from outside keys).\n"
4274 "Warning: the resulting transaction may become invalid if "
4275 "one of the unsafe inputs disappears.\n"
4276 "If that happens, you will need to fund the transaction with "
4277 "different inputs and republish it."},
4279 "When false, returns a serialized transaction which will not "
4280 "be added to the wallet or broadcast"},
4283 "The bitcoin address to receive the change"},
4286 "The index of the change output"},
4289 "not set: makes wallet determine the fee"},
4295 "true for watch-only wallets, otherwise false"},
4296 "Also select inputs which are watch only.\n"
4297 "Only solvable inputs can be used. Watch-only destinations "
4298 "are solvable if the public key and/or output script was "
4300 "e.g. with 'importpubkey' or 'importmulti' with the "
4301 "'pubkeys' or 'desc' field."},
4306 "Specify inputs instead of adding them automatically. A "
4307 "JSON array of JSON objects",
4310 "The transaction id"},
4312 "The output number"},
4314 "The sequence number"},
4318 "Raw locktime. Non-0 value also locktime-activates inputs"},
4320 "Lock selected unspent outputs"},
4322 "Always return a PSBT, implies add_to_wallet=false."},
4324 "subtract_fee_from_outputs",
4327 "Outputs to subtract the fee from, specified as integer "
4329 "The fee will be equally deducted from the amount of each "
4330 "specified output.\n"
4331 "Those recipients will receive less bitcoins than you "
4332 "enter in their corresponding amount field.\n"
4333 "If no outputs are specified here, the sender pays the "
4338 "The zero-based output index, before a change output "
4350 "If the transaction has a complete set of signatures"},
4352 "The transaction id for the send. Only 1 transaction is created "
4353 "regardless of the number of addresses."},
4355 "If add_to_wallet is false, the hex-encoded raw transaction with "
4358 "If more signatures are needed, or if add_to_wallet is false, "
4359 "the base64-encoded (partially) signed transaction"}}},
4362 "\nSend with a fee rate of 10 XEC/kB\n" +
4364 "\": 100000}' '{\"fee_rate\": 10}'\n") +
4365 "\nCreate a transaction with a specific input, and return "
4366 "result without adding to wallet or broadcasting to the "
4370 "\": 100000}' '{\"add_to_wallet\": "
4371 "false, \"inputs\": "
4373 "\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b565"
4374 "5e72f463568df1aadf0\", \"vout\":1}]}'")},
4377 std::shared_ptr<CWallet>
const wallet =
4384 UniValue options = request.params[1];
4385 if (options.
exists(
"changeAddress")) {
4388 if (options.
exists(
"changePosition")) {
4390 "Use change_position");
4392 if (options.
exists(
"includeWatching")) {
4394 "Use include_watching");
4396 if (options.
exists(
"lockUnspents")) {
4399 if (options.
exists(
"subtractFeeFromOutputs")) {
4401 "Use subtract_fee_from_outputs");
4403 if (options.
exists(
"feeRate")) {
4407 const bool psbt_opt_in =
4411 int change_position;
4413 wallet->GetChainParams(), options[
"inputs"], request.params[0],
4414 options[
"locktime"]);
4422 bool add_to_wallet =
true;
4423 if (options.
exists(
"add_to_wallet")) {
4424 add_to_wallet = options[
"add_to_wallet"].
get_bool();
4431 bool complete =
true;
4433 psbtx, complete,
SigHashType().withForkId(),
true,
false);
4443 if (psbt_opt_in || !complete || !add_to_wallet) {
4451 std::string err_string;
4454 result.
pushKV(
"txid", tx->GetHash().GetHex());
4455 if (add_to_wallet && !psbt_opt_in) {
4458 result.
pushKV(
"hex", hex);
4461 result.
pushKV(
"complete", complete);
4470 "Set or generate a new HD wallet seed. Non-HD wallets will not be "
4471 "upgraded to being a HD wallet. Wallets that are already\n"
4472 "HD will have a new HD seed set so that new keys added to the keypool "
4473 "will be derived from this new seed.\n"
4474 "\nNote that you will need to MAKE A NEW BACKUP of your wallet after "
4475 "setting the HD wallet seed.\n" +
4477 "Note: This command is only compatible with legacy wallets.\n",
4480 "Whether to flush old unused addresses, including change "
4481 "addresses, from the keypool and regenerate it.\n"
4482 " If true, the next address from "
4483 "getnewaddress and change address from getrawchangeaddress will "
4484 "be from this new seed.\n"
4485 " If false, addresses (including "
4486 "change addresses if the wallet already had HD Chain Split "
4487 "enabled) from the existing\n"
4488 " keypool will be used until it has "
4491 "The WIF private key to use as the new HD seed.\n"
4492 " The seed value can be retrieved "
4493 "using the dumpwallet command. It is the private key marked "
4503 std::shared_ptr<CWallet>
const wallet =
4515 "Cannot set a HD seed to a wallet with "
4516 "private keys disabled");
4525 "Cannot set a HD seed on a non-HD wallet. Use the "
4526 "upgradewallet RPC in order to upgrade a non-HD wallet "
4532 bool flush_key_pool =
true;
4533 if (!request.params[0].isNull()) {
4534 flush_key_pool = request.params[0].get_bool();
4538 if (request.params[1].isNull()) {
4544 "Invalid private key");
4550 "Already have this key (either as an HD seed or "
4551 "as a loose private key)");
4558 if (flush_key_pool) {
4569 "walletprocesspsbt",
4570 "Update a PSBT with input information from our wallet and then sign "
4571 "inputs that we can sign for." +
4575 "The transaction base64 string"},
4577 "Also sign the transaction when updating"},
4579 "The signature hash type to sign with if not specified by "
4580 "the PSBT. Must be one of\n"
4582 " \"NONE|FORKID\"\n"
4583 " \"SINGLE|FORKID\"\n"
4584 " \"ALL|FORKID|ANYONECANPAY\"\n"
4585 " \"NONE|FORKID|ANYONECANPAY\"\n"
4586 " \"SINGLE|FORKID|ANYONECANPAY\""},
4588 "Includes the BIP 32 derivation paths for public keys if we know "
4596 "The base64-encoded partially signed transaction"},
4598 "If the transaction has a complete set of signatures"},
4603 std::shared_ptr<CWallet>
const wallet =
4615 strprintf(
"TX decode failed %s", error));
4622 "Signature must use SIGHASH_FORKID");
4626 bool sign = request.params[1].isNull()
4628 : request.params[1].get_bool();
4629 bool bip32derivs = request.params[3].isNull()
4631 : request.params[3].get_bool();
4632 bool complete =
true;
4634 psbtx, complete, nHashType, sign, bip32derivs);
4643 result.
pushKV(
"complete", complete);
4653 "walletcreatefundedpsbt",
4654 "Creates and funds a transaction in the Partially Signed Transaction "
4656 "Implements the Creator and Updater roles.\n",
4662 "Leave empty to add inputs automatically. See add_inputs "
4674 "The output number"},
4677 "depends on the value of the 'locktime' and "
4678 "'options.replaceable' arguments"},
4679 "The sequence number"},
4687 "The outputs (key-value pairs), where none of "
4688 "the keys are duplicated.\n"
4689 "That is, each address can only appear once and there can only "
4690 "be one 'data' object.\n"
4691 "For compatibility reasons, a dictionary, which holds the "
4692 "key-value pairs directly, is also\n"
4693 " accepted as second parameter.",
4702 "A key-value pair. The key (string) is the "
4703 "bitcoin address, the value (float or string) is "
4715 "A key-value pair. The key must be \"data\", the "
4716 "value is hex-encoded data"},
4722 "Raw locktime. Non-0 value also locktime-activates inputs\n"
4723 " Allows this transaction to be "
4724 "replaced by a transaction with higher fees. If provided, it is "
4725 "an error if explicit sequence numbers are incompatible."},
4732 "If inputs are specified, automatically include more if they "
4735 "Include inputs that are not safe to spend (unconfirmed "
4736 "transactions from outside keys).\n"
4737 "Warning: the resulting transaction may become invalid if "
4738 "one of the unsafe inputs disappears.\n"
4739 "If that happens, you will need to fund the transaction with "
4740 "different inputs and republish it."},
4743 "The bitcoin address to receive the change"},
4746 "The index of the change output"},
4749 "true for watch-only wallets, otherwise false"},
4750 "Also select inputs which are watch only"},
4752 "Lock selected unspent outputs"},
4755 "not set: makes wallet determine the fee"},
4756 "Set a specific fee rate in " + ticker +
"/kB",
4759 "subtractFeeFromOutputs",
4762 "The outputs to subtract the fee from.\n"
4763 " The fee will be equally "
4764 "deducted from the amount of each specified output.\n"
4765 " Those recipients will "
4766 "receive less bitcoins than you enter in their "
4767 "corresponding amount field.\n"
4768 " If no outputs are "
4769 "specified here, the sender pays the fee.",
4773 "The zero-based output index, before a change output "
4780 "Includes the BIP 32 derivation paths for public keys if we know "
4788 "The resulting raw transaction (base64-encoded string)"},
4790 "Fee in " + ticker +
" the resulting transaction pays"},
4792 "The position of the added change output, or -1"},
4795 "\nCreate a transaction with no inputs\n" +
4797 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" "
4798 "\"[{\\\"data\\\":\\\"00010203\\\"}]\"")},
4801 std::shared_ptr<CWallet>
const wallet =
4809 int change_position;
4811 wallet->GetChainParams(), request.params[0], request.params[1],
4818 request.params[3], coin_control);
4824 bool bip32derivs = request.params[4].isNull()
4826 : request.params[4].get_bool();
4827 bool complete =
true;
4830 false, bip32derivs);
4841 result.
pushKV(
"fee", fee);
4842 result.
pushKV(
"changepos", change_position);
4851 "Upgrade the wallet. Upgrades to the latest version if no "
4852 "version number is specified\n"
4853 "New keys may be generated and a new wallet backup will need to "
4856 "The version number to upgrade to. Default is the latest "
4863 std::shared_ptr<CWallet>
const wallet =
4873 if (!request.params[0].isNull()) {
4874 version = request.params[0].getInt<
int>();
4889 "createwallettransaction",
4890 "Create a transaction sending an amount to a given address.\n" +
4894 "The bitcoin address to send to."},
4901 "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 100000") +
4903 "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\", 100000")},
4906 std::shared_ptr<CWallet>
const wallet =
4916 pwallet->BlockUntilSyncedToCurrentChain();
4923 const std::string address = request.params[0].get_str();
4924 address_amounts.
pushKV(address, request.params[1]);
4927 std::vector<CRecipient> recipients;
4929 wallet->GetChainParams());
4932 return SendMoney(pwallet, coin_control, recipients, {},
false);
4971 {
"wallet",
send, },
static constexpr Amount MAX_MONEY
No amount larger than this (in satoshi) is valid.
std::string WriteHDKeypath(const std::vector< uint32_t > &keypath)
Write HD keypaths as strings.
const CScript redeemScript
#define CHECK_NONFATAL(condition)
Identity function.
const std::string & GetLabel() const
std::vector< CTransactionRef > vtx
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
int m_max_depth
Maximum chain depth value for coin availability.
bool fAllowWatchOnly
Includes watch only addresses which are solvable.
int m_min_depth
Minimum chain depth value for coin availability.
std::optional< CFeeRate > m_feerate
Override the wallet's m_pay_tx_fee if set.
bool fOverrideFeeRate
Override automatic min/max checks on fee, m_feerate must be set if true.
bool m_add_inputs
If false, only selected inputs are used.
CTxDestination destChange
bool m_avoid_address_reuse
Forbids inclusion of dirty (previously used) addresses.
bool m_include_unsafe_inputs
If false, only safe inputs will be used (confirmed or self transfers)
bool m_avoid_partial_spends
Avoid partial use of funds sent to a given address.
Fee rate in satoshis per kilobyte: Amount / kB.
std::string ToString() const
Amount GetFeePerK() const
Return the fee in satoshis for a size of 1000 bytes.
CKeyID seed_id
seed hash160
An encapsulated secp256k1 private key.
bool IsValid() const
Check whether this private key is valid.
const uint8_t * begin() const
bool IsCompressed() const
Check whether the public key corresponding to this private key is (to be) compressed.
CPubKey GetPubKey() const
Compute the public key from a private key.
void Set(const T pbegin, const T pend, bool fCompressedIn)
Initialize using begin and end iterators to byte data.
const uint8_t * end() const
A reference to a CKey: the Hash160 of its serialized public key.
A mutable version of CTransaction.
std::vector< CTxOut > vout
An encapsulated public key.
bool IsCompressed() const
Check whether this is a compressed public key.
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
A reference to a CScript: the Hash160 of its serialization (see script.h)
An output of a transaction.
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
std::unique_ptr< SigningProvider > GetSolvingProvider(const CScript &script) const
Get the SigningProvider for a script.
BlockHash GetLastBlockHash() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
double ScanningProgress() const
SteadyClock::duration ScanningDuration() const
interfaces::Chain & chain() const
Interface for accessing chain state.
bool IsLegacy() const
Determine if we are a legacy wallet.
int GetLastBlockHeight() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Get last block processed height.
OutputType m_default_address_type
LegacyScriptPubKeyMan * GetLegacyScriptPubKeyMan() const
Get the LegacyScriptPubKeyMan which is used for all types, internal, and external.
const std::string & GetName() const
Get a name for this wallet for logging/debugging purposes.
bool CanSupportFeature(enum WalletFeature wf) const override EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
check whether we are allowed to upgrade (or already support) to the named feature
int GetVersion() const
get the current wallet format (the oldest client version guaranteed to understand this wallet)
Amount m_default_max_tx_fee
Absolute maximum transaction fee (in satoshis) used by default for the wallet.
bool UpgradeWallet(int version, bilingual_str &error)
Upgrade the wallet.
ScriptPubKeyMan * GetScriptPubKeyMan(const OutputType &type, bool internal) const
Get the ScriptPubKeyMan for the given OutputType and internal/external chain.
std::multimap< int64_t, CWalletTx * > TxItems
std::optional< OutputType > m_default_change_type
Default output type for change outputs.
const CAddressBookData * FindAddressBookEntry(const CTxDestination &, bool allow_change=false) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
A transaction with a bunch of additional info that only the owner cares about.
const SigningProvider *const provider
UniValue operator()(const PKHash &pkhash) const
UniValue operator()(const ScriptHash &scripthash) const
void ProcessSubScript(const CScript &subscript, UniValue &obj) const
DescribeWalletAddressVisitor(const SigningProvider *_provider)
UniValue operator()(const CNoDestination &dest) const
RecursiveMutex cs_KeyStore
const CHDChain & GetHDChain() const
void SetHDSeed(const CPubKey &key)
bool NewKeyPool()
Mark old keypool keys as used, and generate all new keys.
CPubKey GenerateNewSeed()
CPubKey DeriveNewSeed(const CKey &key)
auto Arg(size_t i) const
Helper to get a required or default-valued request argument.
auto MaybeArg(size_t i) const
Helper to get an optional request argument.
A class implementing ScriptPubKeyMan manages some (or all) scriptPubKeys used in a wallet.
virtual std::unique_ptr< CKeyMetadata > GetMetadata(const CTxDestination &dest) const
Signature hash type wrapper class.
An interface to be implemented by keystores that support signing.
virtual bool GetCScript(const CScriptID &scriptid, CScript &script) const
virtual bool GetPubKey(const CKeyID &address, CPubKey &pubkey) const
A Span is an object that can refer to a contiguous sequence of objects.
void push_back(UniValue val)
const std::string & get_str() const
const UniValue & find_value(std::string_view key) const
const UniValue & get_obj() const
void pushKVs(UniValue obj)
const std::vector< std::string > & getKeys() const
void pushKVEnd(std::string key, UniValue val)
const UniValue & get_array() const
bool exists(const std::string &key) const
void pushKV(std::string key, UniValue val)
RAII object to check and reserve a wallet rescan.
std::string GetHex() const
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
virtual bool findBlock(const BlockHash &hash, const FoundBlock &block={})=0
Return whether node has the block and optionally return block metadata or contents.
virtual bool havePruned()=0
Check if any block has been pruned.
virtual void findCoins(std::map< COutPoint, Coin > &coins)=0
Look up unspent output information.
virtual bool hasAssumedValidChain()=0
Return true if an assumed-valid chain is in use.
virtual bool hasBlocks(const BlockHash &block_hash, int min_height=0, std::optional< int > max_height={})=0
Return true if data is available for all blocks in the specified range of blocks.
virtual bool findAncestorByHeight(const BlockHash &block_hash, int ancestor_height, const FoundBlock &ancestor_out={})=0
Find ancestor of block at specified height and optionally return ancestor information.
virtual CFeeRate relayMinFee()=0
Relay current minimum fee (from -minrelaytxfee settings).
virtual std::optional< int > getPruneHeight()=0
Get the current prune height.
Helper for findBlock to selectively return pieces of block data.
const Config & GetConfig()
void TxToUniv(const CTransaction &tx, const BlockHash &hashBlock, UniValue &entry, bool include_hex=true, const CTxUndo *txundo=nullptr)
std::string EncodeHexTx(const CTransaction &tx)
bool DecodeHexTx(CMutableTransaction &tx, const std::string &strHexTx)
SigHashType ParseSighashString(const UniValue &sighash)
std::unique_ptr< Descriptor > InferDescriptor(const CScript &script, const SigningProvider &provider)
Find a descriptor for the specified script, using information from provider where possible.
void LockCoin(const COutPoint &output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
size_t KeypoolCountExternalKeys() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
util::Result< CTxDestination > GetNewDestination(const OutputType type, const std::string &label)
util::Result< CTxDestination > GetNewChangeDestination(const OutputType type)
void ListLockedCoins(std::vector< COutPoint > &vOutpts) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
unsigned int GetKeyPoolSize() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool IsLockedCoin(const COutPoint &outpoint) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void UnlockCoin(const COutPoint &output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool SetAddressBook(const CTxDestination &address, const std::string &strName, const std::string &purpose)
bool SignTransaction(CMutableTransaction &tx) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
void UnlockAllCoins() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool TopUpKeyPool(unsigned int kpSize=0)
TransactionError FillPSBT(PartiallySignedTransaction &psbtx, bool &complete, SigHashType sighash_type=SigHashType().withForkId(), bool sign=true, bool bip32derivs=true) const
Fills out a PSBT with information from the wallet.
int64_t GetOldestKeyPoolTime() const
void CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::vector< std::pair< std::string, std::string > > orderForm, bool broadcast=true)
Add the transaction to the wallet and maybe attempt to broadcast it.
void BlockUntilSyncedToCurrentChain() const LOCKS_EXCLUDED(void SetWalletFlag(uint64_t flags)
Blocks until the wallet state is up-to-date to /at least/ the current chain at the time this function...
isminetype IsMine(const CTxDestination &dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool CanGetAddresses(bool internal=false) const
Returns true if the wallet can give out new addresses.
ScanResult ScanForWalletTransactions(const BlockHash &start_block, int start_height, std::optional< int > max_height, const WalletRescanReserver &reserver, bool fUpdate)
Scan the block chain (starting in start_block) for transactions from or to us.
bool IsSpentKey(const TxId &txid, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
const CChainParams & GetChainParams() const override
bool IsSpent(const COutPoint &outpoint) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Outpoint is spent if any non-conflicted transaction, spends it:
void UnsetWalletFlag(uint64_t flag)
Unsets a single wallet flag.
bool IsWalletFlagSet(uint64_t flag) const override
Check if a certain wallet flag is set.
bool AbandonTransaction(const TxId &txid)
Mark a transaction (and it in-wallet descendants) as abandoned so its inputs may be respent.
isminetype
IsMine() return codes.
std::string EncodeDestination(const CTxDestination &dest, const Config &config)
bool IsValidDestinationString(const std::string &str, const CChainParams ¶ms)
CTxDestination DecodeDestination(const std::string &addr, const CChainParams ¶ms)
CKey DecodeSecret(const std::string &str)
std::string FormatMoney(const Amount amt)
Do not use these functions to represent or parse monetary amounts to or from JSON but use AmountFromV...
static bool isNull(const AnyVoteItem &item)
bilingual_str ErrorString(const Result< T > &result)
bool ParseOutputType(const std::string &type, OutputType &output_type)
static CTransactionRef MakeTransactionRef()
std::shared_ptr< const CTransaction > CTransactionRef
bool DecodeBase64PSBT(PartiallySignedTransaction &psbt, const std::string &base64_tx, std::string &error)
Decode a base64ed PSBT into a PartiallySignedTransaction.
bool FinalizeAndExtractPSBT(PartiallySignedTransaction &psbtx, CMutableTransaction &result)
Finalizes a PSBT if possible, and extracts it to a CMutableTransaction if it could be finalized.
void SignTransactionResultToJSON(CMutableTransaction &mtx, bool complete, const std::map< COutPoint, Coin > &coins, const std::map< int, std::string > &input_errors, UniValue &result)
CMutableTransaction ConstructTransaction(const CChainParams ¶ms, const UniValue &inputs_in, const UniValue &outputs_in, const UniValue &locktime)
Create a transaction from univalue parameters.
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.
bool CachedTxIsFromMe(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
std::set< std::set< CTxDestination > > GetAddressGroupings(const CWallet &wallet)
Amount CachedTxGetDebit(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
filter decides which addresses will count towards the debit
bool ScriptIsChange(const CWallet &wallet, const CScript &script)
void CachedTxGetAmounts(const CWallet &wallet, const CWalletTx &wtx, std::list< COutputEntry > &listReceived, std::list< COutputEntry > &listSent, Amount &nFee, const isminefilter &filter)
std::map< CTxDestination, Amount > GetAddressBalances(const CWallet &wallet)
Amount CachedTxGetCredit(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
bool CachedTxIsTrusted(const CWallet &wallet, const CWalletTx &wtx, std::set< TxId > &trusted_parents)
Balance GetBalance(const CWallet &wallet, const int min_depth, bool avoid_reuse)
UniValue JSONRPCError(int code, const std::string &message)
RPCErrorCode
Bitcoin RPC error codes.
@ RPC_WALLET_INVALID_LABEL_NAME
Invalid label name.
@ RPC_MISC_ERROR
General application defined errors std::exception thrown in command handling.
@ RPC_WALLET_INSUFFICIENT_FUNDS
Not enough funds in wallet or account.
@ RPC_WALLET_ENCRYPTION_FAILED
Failed to encrypt the wallet.
@ RPC_METHOD_DEPRECATED
RPC method is deprecated.
@ RPC_INVALID_PARAMETER
Invalid, missing or duplicate parameter.
@ RPC_WALLET_ERROR
Wallet errors Unspecified problem with wallet (key not found etc.)
@ RPC_WALLET_NOT_FOUND
Invalid wallet specified.
@ RPC_WALLET_KEYPOOL_RAN_OUT
Keypool ran out, call keypoolrefill first.
@ RPC_DESERIALIZATION_ERROR
Error parsing or validating structure in raw format.
@ RPC_INVALID_ADDRESS_OR_KEY
Invalid address or key.
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
CTxDestination AddAndGetMultisigDestination(const int required, const std::vector< CPubKey > &pubkeys, OutputType type, FillableSigningProvider &keystore, CScript &script_out)
std::string HelpExampleRpcNamed(const std::string &methodname, const RPCArgList &args)
UniValue JSONRPCTransactionError(TransactionError terr, const std::string &err_string)
Amount AmountFromValue(const UniValue &value)
const std::string EXAMPLE_ADDRESS
Example CashAddr address used in multiple RPCExamples.
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
const std::string UNIX_EPOCH_TIME
String used to describe UNIX epoch time in documentation, factored out to a constant for consistency.
CPubKey HexToPubKey(const std::string &hex_in)
CPubKey AddrToPubKey(const CChainParams &chainparams, const FillableSigningProvider &keystore, const std::string &addr_in)
uint256 ParseHashO(const UniValue &o, std::string strKey)
uint256 ParseHashV(const UniValue &v, std::string strName)
Utilities: convert hex-encoded values (throws error if not hex).
void RPCTypeCheckObj(const UniValue &o, const std::map< std::string, UniValueType > &typesExpected, bool fAllowNull, bool fStrict)
Check for expected keys/value types in an Object.
std::string HelpExampleCliNamed(const std::string &methodname, const RPCArgList &args)
UniValue DescribeAddress(const CTxDestination &dest)
static RPCHelpMan createwallet()
static RPCHelpMan getnewaddress()
static RPCHelpMan sethdseed()
static RPCHelpMan listreceivedbylabel()
static RPCHelpMan sendtoaddress()
Span< const CRPCCommand > GetWalletRPCCommands()
static RPCHelpMan listunspent()
static RPCHelpMan getrawchangeaddress()
static RPCHelpMan walletprocesspsbt()
static void ListTransactions(const CWallet *const pwallet, const CWalletTx &wtx, int nMinDepth, bool fLong, Vec &ret, const isminefilter &filter_ismine, const std::string *filter_label) EXCLUSIVE_LOCKS_REQUIRED(pwallet -> cs_wallet)
List transactions based on the given criteria.
static RPCHelpMan fundrawtransaction()
static RPCHelpMan gettransaction()
static UniValue ListReceived(const Config &config, const CWallet *const pwallet, const UniValue ¶ms, bool by_label) EXCLUSIVE_LOCKS_REQUIRED(pwallet -> cs_wallet)
static UniValue AddressBookDataToJSON(const CAddressBookData &data, const bool verbose)
Convert CAddressBookData to JSON record.
static RPCHelpMan listaddressgroupings()
static void WalletTxToJSON(const CWallet &wallet, const CWalletTx &wtx, UniValue &entry) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
static RPCHelpMan addmultisigaddress()
RPCHelpMan getaddressesbylabel()
static RPCHelpMan listlockunspent()
static Amount GetReceived(const CWallet &wallet, const UniValue ¶ms, bool by_label) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
static RPCHelpMan getunconfirmedbalance()
static RPCHelpMan listwallets()
RPCHelpMan rescanblockchain()
static RPCHelpMan upgradewallet()
static RPCHelpMan unloadwallet()
static RPCHelpMan walletcreatefundedpsbt()
static RPCHelpMan getbalances()
static RPCHelpMan listwalletdir()
static RPCHelpMan keypoolrefill()
bool HaveKey(const SigningProvider &wallet, const CKey &key)
Checks if a CKey is in the given CWallet compressed or otherwise.
RPCHelpMan getaddressinfo()
static std::vector< RPCResult > TransactionDescriptionString()
static RPCHelpMan getwalletinfo()
static RPCHelpMan lockunspent()
UniValue SendMoney(CWallet *const pwallet, const CCoinControl &coin_control, std::vector< CRecipient > &recipients, mapValue_t map_value, bool broadcast=true)
static RPCHelpMan setwalletflag()
RPCHelpMan signrawtransactionwithwallet()
static RPCHelpMan createwallettransaction()
static RPCHelpMan setlabel()
static RPCHelpMan getreceivedbyaddress()
static RPCHelpMan getreceivedbylabel()
static void MaybePushAddress(UniValue &entry, const CTxDestination &dest)
static RPCHelpMan getbalance()
static RPCHelpMan loadwallet()
static RPCHelpMan listsinceblock()
static RPCHelpMan settxfee()
static RPCHelpMan listreceivedbyaddress()
static RPCHelpMan sendmany()
RPCHelpMan listtransactions()
static UniValue DescribeWalletAddress(const CWallet *const pwallet, const CTxDestination &dest)
void ParseRecipients(const UniValue &address_amounts, const UniValue &subtract_fee_outputs, std::vector< CRecipient > &recipients, const CChainParams &chainParams)
void FundTransaction(CWallet *const pwallet, CMutableTransaction &tx, Amount &fee_out, int &change_position, const UniValue &options, CCoinControl &coinControl)
static RPCHelpMan abandontransaction()
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
bool IsSolvable(const SigningProvider &provider, const CScript &script)
Check whether we know how to sign for an output like this, assuming we have all private keys.
util::Result< CreatedTransactionResult > CreateTransaction(CWallet &wallet, const std::vector< CRecipient > &vecSend, int change_pos, const CCoinControl &coin_control, bool sign)
Create a new transaction paying the recipients with a set of coins selected by SelectCoins(); Also cr...
void AvailableCoins(const CWallet &wallet, std::vector< COutput > &vCoins, const CCoinControl *coinControl, const Amount nMinimumAmount, const Amount nMaximumAmount, const Amount nMinimumSumAmount, const uint64_t nMaximumCount)
populate vCoins with vector of available COutputs.
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
TxoutType Solver(const CScript &scriptPubKey, std::vector< std::vector< uint8_t > > &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
std::string GetTxnOutputType(TxoutType t)
Get the name of a TxoutType as a string.
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
CKeyID ToKeyID(const PKHash &key_hash)
std::variant< CNoDestination, PKHash, ScriptHash > CTxDestination
A txout script template with a specific destination.
auto Join(const std::vector< T > &list, const BaseType &separator, UnaryOp unary_op) -> decltype(unary_op(list.at(0)))
Join a list of items.
std::string ToString(const T &t)
Locale-independent version of std::to_string.
static constexpr Amount zero() noexcept
Amount m_mine_untrusted_pending
Untrusted, but in mempool (pending)
A BlockHash is a unqiue identifier for a block.
std::optional< int > last_scanned_height
enum CWallet::ScanResult::@20 status
static const Currency & get()
SecureString create_passphrase
A version of CTransaction with the PSBT format.
@ OBJ_USER_KEYS
Special type where the user must set the keys e.g.
@ STR_HEX
Special type that is a STR with only hex chars.
@ AMOUNT
Special type representing a floating point amount (can be either NUM or STR)
@ OBJ_NAMED_PARAMS
Special type that behaves almost exactly like OBJ, defining an options object with a list of pre-defi...
std::string DefaultHint
Hint for default value.
@ OMITTED
Optional argument for which the default value is omitted from help text for one of two reasons:
std::string oneline_description
Should be empty unless it is supposed to override the auto-generated summary line.
bool also_positional
If set allows a named-parameter field in an OBJ_NAMED_PARAM options object to have the same name as a...
@ ELISION
Special type to denote elision (...)
@ NUM_TIME
Special numeric to denote unix epoch time.
@ ARR_FIXED
Special array that has a fixed number of entries.
@ OBJ_DYN
Special dictionary with keys that are not literals.
@ STR_HEX
Special string with only hex chars.
@ STR_AMOUNT
Special string to represent a floating point amount.
A TxId is the identifier of a transaction.
Wrapper for UniValue::VType, which includes typeAny: used to denote don't care type.
WalletContext struct containing references to state shared between CWallet instances,...
std::vector< uint256 > txids
#define EXCLUSIVE_LOCKS_REQUIRED(...)
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
const UniValue NullUniValue
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
std::string EncodeBase64(Span< const uint8_t > input)
bool IsHex(std::string_view str)
Returns true if each character in str is a hex character, and has an even number of hex digits.
V Cat(V v1, V &&v2)
Concatenate two vectors, moving elements.
static const int PROTOCOL_VERSION
network protocol versioning
void EnsureWalletIsUnlocked(const CWallet *pwallet)
std::shared_ptr< CWallet > GetWalletForJSONRPCRequest(const JSONRPCRequest &request)
Figures out what wallet, if any, to use for a JSONRPCRequest.
LegacyScriptPubKeyMan & EnsureLegacyScriptPubKeyMan(CWallet &wallet, bool also_create)
bool GetAvoidReuseFlag(const CWallet *const pwallet, const UniValue ¶m)
void HandleWalletError(const std::shared_ptr< CWallet > wallet, DatabaseStatus &status, bilingual_str &error)
bool ParseIncludeWatchonly(const UniValue &include_watchonly, const CWallet &pwallet)
Used by RPC commands that have an include_watchonly parameter.
WalletContext & EnsureWalletContext(const std::any &context)
const std::string HELP_REQUIRING_PASSPHRASE
std::string LabelFromValue(const UniValue &value)
bool GetWalletNameFromJSONRPCRequest(const JSONRPCRequest &request, std::string &wallet_name)
std::map< std::string, std::string > mapValue_t
static constexpr uint64_t MUTABLE_WALLET_FLAGS
static const std::map< std::string, WalletFlags > WALLET_FLAG_MAP
const std::map< uint64_t, std::string > WALLET_FLAG_CAVEATS
bool RemoveWallet(WalletContext &context, const std::shared_ptr< CWallet > &wallet, std::optional< bool > load_on_start, std::vector< bilingual_str > &warnings)
void UnloadWallet(std::shared_ptr< CWallet > &&wallet)
Explicitly unload and delete the wallet.
std::vector< std::shared_ptr< CWallet > > GetWallets(WalletContext &context)
std::shared_ptr< CWallet > GetWallet(WalletContext &context, const std::string &name)
std::shared_ptr< CWallet > CreateWallet(WalletContext &context, const std::string &name, std::optional< bool > load_on_start, DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error, std::vector< bilingual_str > &warnings)
std::shared_ptr< CWallet > LoadWallet(WalletContext &context, const std::string &name, std::optional< bool > load_on_start, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error, std::vector< bilingual_str > &warnings)
std::vector< fs::path > ListWalletDir()
Get wallets in wallet directory.
@ WALLET_FLAG_DISABLE_PRIVATE_KEYS
@ WALLET_FLAG_AVOID_REUSE
@ WALLET_FLAG_DESCRIPTORS
Indicate that this wallet supports DescriptorScriptPubKeyMan.
@ WALLET_FLAG_BLANK_WALLET
Flag set when a wallet contains no HD seed and no private keys, scripts, addresses,...