43 #include <event2/http.h>
64 int confirms =
wallet.GetTxDepthInMainChain(wtx);
65 entry.pushKV(
"confirmations", confirms);
66 if (wtx.IsCoinBase()) {
67 entry.pushKV(
"generated",
true);
70 entry.pushKV(
"blockhash", wtx.m_confirm.hashBlock.GetHex());
71 entry.pushKV(
"blockheight", wtx.m_confirm.block_height);
72 entry.pushKV(
"blockindex", wtx.m_confirm.nIndex);
76 entry.pushKV(
"blocktime", block_time);
81 entry.pushKV(
"txid", hash.
GetHex());
86 entry.pushKV(
"walletconflicts", conflicts);
87 entry.pushKV(
"time", wtx.GetTxTime());
88 entry.pushKV(
"timereceived", int64_t{wtx.nTimeReceived});
90 for (
const std::pair<const std::string, std::string> &item : wtx.mapValue) {
91 entry.pushKV(item.first, item.second);
98 "Returns a new Bitcoin address for receiving payments.\n"
99 "If 'label' is specified, it is added to the address book \n"
100 "so payments received with the address will be associated with "
104 "The label name for the address to be linked to. If not provided, "
105 "the default label \"\" is used. It can also be set to the empty "
106 "string \"\" to represent the default label. The label does not "
107 "need to exist, it will be created if there is no label by the "
111 "The address type to use. Options are \"legacy\"."},
118 std::shared_ptr<CWallet>
const wallet =
128 "Error: This wallet has no available keys");
134 if (!request.params[0].isNull()) {
139 if (!request.params[1].isNull()) {
144 request.params[1].get_str()));
161 "getrawchangeaddress",
162 "Returns a new Bitcoin address, for receiving change.\n"
163 "This is for use with raw transactions, NOT normal use.\n",
170 std::shared_ptr<CWallet>
const wallet =
181 "Error: This wallet has no available keys");
186 if (!request.params[0].isNull()) {
191 request.params[0].get_str()));
208 "Sets the label associated with the given address.\n",
211 "The bitcoin address to be associated with a label."},
213 "The label to assign to the address."},
218 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"tabby\"") +
221 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"tabby\"")},
224 std::shared_ptr<CWallet>
const wallet =
234 wallet->GetChainParams());
237 "Invalid Bitcoin address");
242 if (pwallet->
IsMine(dest)) {
254 const UniValue &subtract_fee_outputs,
255 std::vector<CRecipient> &recipients,
257 std::set<CTxDestination> destinations;
259 for (
const std::string &address : address_amounts.
getKeys()) {
263 std::string(
"Invalid Bitcoin address: ") +
267 if (destinations.count(dest)) {
270 std::string(
"Invalid parameter, duplicated address: ") +
273 destinations.insert(dest);
278 bool subtract_fee =
false;
279 for (
unsigned int idx = 0; idx < subtract_fee_outputs.
size(); idx++) {
280 const UniValue &addr = subtract_fee_outputs[idx];
281 if (addr.
get_str() == address) {
286 CRecipient recipient = {script_pub_key, amount, subtract_fee};
287 recipients.push_back(recipient);
292 std::vector<CRecipient> &recipients,
mapValue_t map_value,
293 bool broadcast =
true) {
301 int nChangePosRet = -1;
305 *pwallet, recipients, tx, nFeeRequired, nChangePosRet,
error,
313 return tx->GetId().GetHex();
322 "The bitcoin address to send to."},
326 "A comment used to store what the transaction is for.\n"
327 " This is not part of the "
328 "transaction, just kept in your wallet."},
331 "A comment to store the name of the person or organization\n"
332 " to which you're sending the "
333 "transaction. This is not part of the \n"
334 " transaction, just kept in "
338 "The fee will be deducted from the amount being sent.\n"
339 " The recipient will receive "
340 "less bitcoins than you enter in the amount field."},
342 "(only available if avoid_reuse wallet flag is set) Avoid "
343 "spending from dirty addresses; addresses are considered\n"
344 " dirty if they have previously "
345 "been used in a transaction."},
350 "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 100000") +
351 HelpExampleCli(
"sendtoaddress",
"\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvay"
352 "dd\" 100000 \"donation\" \"seans "
355 "Jvaydd\" 100000 \"\" \"\" true") +
357 "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvay"
358 "dd\", 100000, \"donation\", \"seans "
362 std::shared_ptr<CWallet>
const wallet =
372 pwallet->BlockUntilSyncedToCurrentChain();
378 if (!request.params[2].isNull() &&
379 !request.params[2].get_str().empty()) {
380 mapValue[
"comment"] = request.params[2].get_str();
382 if (!request.params[3].isNull() &&
383 !request.params[3].get_str().empty()) {
384 mapValue[
"to"] = request.params[3].get_str();
387 bool fSubtractFeeFromAmount =
false;
388 if (!request.params[4].isNull()) {
389 fSubtractFeeFromAmount = request.params[4].get_bool();
402 const std::string address = request.params[0].get_str();
403 address_amounts.
pushKV(address, request.params[1]);
405 if (fSubtractFeeFromAmount) {
406 subtractFeeFromAmount.
push_back(address);
409 std::vector<CRecipient> recipients;
411 wallet->GetChainParams());
413 return SendMoney(pwallet, coin_control, recipients, mapValue);
420 "listaddressgroupings",
421 "Lists groups of addresses which have had their common ownership\n"
422 "made public by common use as inputs or as the resulting change\n"
423 "in past transactions\n",
438 "The bitcoin address"},
450 std::shared_ptr<CWallet>
const wallet =
460 pwallet->BlockUntilSyncedToCurrentChain();
465 std::map<CTxDestination, Amount> balances =
467 for (
const std::set<CTxDestination> &grouping :
473 addressInfo.
push_back(balances[address]);
475 const auto *address_book_entry =
477 if (address_book_entry) {
478 addressInfo.
push_back(address_book_entry->GetLabel());
485 return jsonGroupings;
493 std::set<CTxDestination> address_set;
498 address_set =
wallet.GetLabelAddresses(label);
505 "Invalid Bitcoin address");
508 if (!
wallet.IsMine(script_pub_key)) {
511 address_set.insert(dest);
516 if (!params[1].
isNull()) {
517 min_depth = params[1].get_int();
522 for (
const std::pair<const TxId, CWalletTx> &wtx_pair :
wallet.mapWallet) {
528 for (
const CTxOut &txout : wtx.
tx->vout) {
531 wallet.IsMine(address) && address_set.count(address)) {
542 "getreceivedbyaddress",
543 "Returns the total amount received by the given address in "
544 "transactions with at least minconf confirmations.\n",
547 "The bitcoin address for transactions."},
549 "Only include transactions confirmed at least this many times."},
553 " received at this address."},
555 "\nThe amount from transactions with at least 1 confirmation\n" +
557 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\"") +
558 "\nThe amount including unconfirmed transactions, zero "
561 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" 0") +
562 "\nThe amount with at least 6 confirmations\n" +
564 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" 6") +
565 "\nAs a JSON-RPC call\n" +
567 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", 6")},
570 std::shared_ptr<CWallet>
const wallet =
580 pwallet->BlockUntilSyncedToCurrentChain();
592 "getreceivedbylabel",
593 "Returns the total amount received by addresses with <label> in "
594 "transactions with at least [minconf] confirmations.\n",
597 "The selected label, may be the default label using \"\"."},
599 "Only include transactions confirmed at least this many times."},
603 " received for this label."},
604 RPCExamples{
"\nAmount received by the default label with at least 1 "
607 "\nAmount received at the tabby label including "
608 "unconfirmed amounts with zero confirmations\n" +
610 "\nThe amount with at least 6 confirmations\n" +
612 "\nAs a JSON-RPC call\n" +
616 std::shared_ptr<CWallet>
const wallet =
626 pwallet->BlockUntilSyncedToCurrentChain();
639 "Returns the total available balance.\n"
640 "The available balance is what the wallet considers currently "
641 "spendable, and is\n"
642 "thus affected by options which limit spendability such as "
643 "-spendzeroconfchange.\n",
646 "Remains for backward compatibility. Must be excluded or set to "
649 "Only include transactions confirmed at least this many times."},
652 "true for watch-only wallets, otherwise false"},
653 "Also include balance in watch-only addresses (see "
656 "(only available if avoid_reuse wallet flag is set) Do not "
657 "include balance in dirty outputs; addresses are considered dirty "
658 "if they have previously been used in a transaction."},
662 " received for this wallet."},
664 "\nThe total amount in the wallet with 0 or more confirmations\n" +
666 "\nThe total amount in the wallet with at least 6 confirmations\n" +
667 HelpExampleCli(
"getbalance",
"\"*\" 6") +
"\nAs a JSON-RPC call\n" +
671 std::shared_ptr<CWallet>
const wallet =
681 pwallet->BlockUntilSyncedToCurrentChain();
685 const UniValue &dummy_value = request.params[0];
689 "dummy first argument must be excluded or set to \"*\".");
693 if (!request.params[1].isNull()) {
694 min_depth = request.params[1].get_int();
697 bool include_watchonly =
702 const auto bal =
GetBalance(*pwallet, min_depth, avoid_reuse);
704 return bal.m_mine_trusted + (include_watchonly
705 ? bal.m_watchonly_trusted
713 "getunconfirmedbalance",
714 "DEPRECATED\nIdentical to getbalances().mine.untrusted_pending\n",
720 std::shared_ptr<CWallet>
const wallet =
730 pwallet->BlockUntilSyncedToCurrentChain();
742 "Send multiple times. Amounts are double-precision "
743 "floating point numbers." +
747 "Must be set to \"\" for backwards compatibility.",
"\"\""},
752 "The addresses and amounts",
755 "The bitcoin address is the key, the numeric amount (can "
761 "Only use the balance confirmed at least this many times."},
769 " The fee will be equally deducted "
770 "from the amount of each selected address.\n"
771 " Those recipients will receive less "
772 "bitcoins than you enter in their corresponding amount field.\n"
773 " If no addresses are specified "
774 "here, the sender pays the fee.",
777 "Subtract fee from this address"},
782 "The transaction id for the send. Only 1 transaction is "
783 "created regardless of the number of addresses."},
785 "\nSend two amounts to two different addresses:\n" +
789 "\"{\\\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\\\":"
791 "\\\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\\\":0."
793 "\nSend two amounts to two different addresses setting the "
794 "confirmation and comment:\n" +
798 "\"{\\\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\\\":"
800 "\\\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\\\":0."
803 "\nSend two amounts to two different addresses, subtract fee "
808 "\"{\\\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\\\":"
810 "\\\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\\\":0."
812 "\"[\\\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\\\","
813 "\\\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\\\"]"
815 "\nAs a JSON-RPC call\n" +
819 "{\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\":0.01,"
820 "\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\":0.02}, "
825 std::shared_ptr<CWallet>
const wallet =
835 pwallet->BlockUntilSyncedToCurrentChain();
839 if (!request.params[0].isNull() &&
840 !request.params[0].get_str().empty()) {
842 "Dummy value must be set to \"\"");
847 if (!request.params[3].isNull() &&
848 !request.params[3].get_str().empty()) {
849 mapValue[
"comment"] = request.params[3].
get_str();
853 if (!request.params[4].isNull()) {
854 subtractFeeFromAmount = request.params[4].
get_array();
857 std::vector<CRecipient> recipients;
859 wallet->GetChainParams());
862 return SendMoney(pwallet, coin_control, recipients,
863 std::move(mapValue));
870 "addmultisigaddress",
871 "Add an nrequired-to-sign multisignature address to the wallet. "
872 "Requires a new wallet backup.\n"
873 "Each key is a Bitcoin address or hex-encoded public key.\n"
874 "This functionality is only intended for use with non-watchonly "
876 "See `importaddress` for watchonly p2sh address support.\n"
877 "If 'label' is specified (DEPRECATED), assign address to that label.\n",
880 "The number of required signatures out of the n keys or "
886 "The bitcoin addresses or hex-encoded public keys",
889 "bitcoin address or hex-encoded public key"},
893 "A label to assign the addresses to."},
900 "The value of the new multisig address"},
902 "The string value of the hex-encoded redemption script"},
904 "The descriptor for this multisig"},
907 "\nAdd a multisig address from 2 addresses\n" +
910 "\"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\","
911 "\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") +
912 "\nAs a JSON-RPC call\n" +
915 "\"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\","
916 "\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"")},
919 std::shared_ptr<CWallet>
const wallet =
932 if (!request.params[2].isNull()) {
936 int required = request.params[0].get_int();
940 std::vector<CPubKey> pubkeys;
941 for (
size_t i = 0; i < keys_or_addrs.
size(); ++i) {
942 if (
IsHex(keys_or_addrs[i].get_str()) &&
943 (keys_or_addrs[i].get_str().length() == 66 ||
944 keys_or_addrs[i].get_str().length() == 130)) {
958 required, pubkeys, output_type, spk_man, inner);
962 std::unique_ptr<Descriptor> descriptor =
968 result.
pushKV(
"descriptor", descriptor->ToString());
976 int nConf{std::numeric_limits<int>::max()};
983 const UniValue ¶ms,
bool by_label)
987 if (!params[0].
isNull()) {
988 nMinDepth = params[0].get_int();
992 bool fIncludeEmpty =
false;
993 if (!params[1].
isNull()) {
994 fIncludeEmpty = params[1].get_bool();
1002 bool has_filtered_address =
false;
1004 if (!by_label && params.size() > 3) {
1006 pwallet->GetChainParams())) {
1008 "address_filter parameter was invalid");
1012 has_filtered_address =
true;
1016 std::map<CTxDestination, tallyitem> mapTally;
1017 for (
const std::pair<const TxId, CWalletTx> &pairWtx : pwallet->mapWallet) {
1024 int nDepth = pwallet->GetTxDepthInMainChain(wtx);
1025 if (nDepth < nMinDepth) {
1029 for (
const CTxOut &txout : wtx.
tx->vout) {
1035 if (has_filtered_address && !(filtered_address == address)) {
1040 if (!(mine & filter)) {
1056 std::map<std::string, tallyitem> label_tally;
1060 auto start = pwallet->m_address_book.begin();
1061 auto end = pwallet->m_address_book.end();
1063 if (has_filtered_address) {
1064 start = pwallet->m_address_book.find(filtered_address);
1066 end = std::next(start);
1070 for (
auto item_it = start; item_it != end; ++item_it) {
1071 if (item_it->second.IsChange()) {
1075 const std::string &label = item_it->second.GetLabel();
1076 std::map<CTxDestination, tallyitem>::iterator it =
1077 mapTally.find(address);
1078 if (it == mapTally.end() && !fIncludeEmpty) {
1083 int nConf = std::numeric_limits<int>::max();
1084 bool fIsWatchonly =
false;
1085 if (it != mapTally.end()) {
1086 nAmount = (*it).second.nAmount;
1087 nConf = (*it).second.nConf;
1088 fIsWatchonly = (*it).second.fIsWatchonly;
1099 obj.
pushKV(
"involvesWatchonly",
true);
1102 obj.
pushKV(
"amount", nAmount);
1103 obj.
pushKV(
"confirmations",
1104 (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
1105 obj.
pushKV(
"label", label);
1107 if (it != mapTally.end()) {
1108 for (
const uint256 &_item : (*it).second.txids) {
1112 obj.
pushKV(
"txids", transactions);
1118 for (
const auto &entry : label_tally) {
1119 Amount nAmount = entry.second.nAmount;
1120 int nConf = entry.second.nConf;
1122 if (entry.second.fIsWatchonly) {
1123 obj.
pushKV(
"involvesWatchonly",
true);
1125 obj.
pushKV(
"amount", nAmount);
1126 obj.
pushKV(
"confirmations",
1127 (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
1128 obj.
pushKV(
"label", entry.first);
1138 "listreceivedbyaddress",
1139 "List balances by receiving address.\n",
1142 "The minimum number of confirmations before payments are "
1145 "Whether to include addresses that haven't received any "
1149 "true for watch-only wallets, otherwise false"},
1150 "Whether to include watch-only addresses (see 'importaddress')."},
1153 "If present, only return information on this address."},
1165 "Only returns true if imported addresses were involved "
1170 " received by the address"},
1172 "The number of confirmations of the most recent "
1173 "transaction included"},
1175 "The label of the receiving address. The default label "
1182 "The ids of transactions received with the address"},
1191 "listreceivedbyaddress",
1192 "6, true, true, \"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\"")},
1195 std::shared_ptr<CWallet>
const wallet =
1205 pwallet->BlockUntilSyncedToCurrentChain();
1209 return ListReceived(config, pwallet, request.params,
false);
1216 "listreceivedbylabel",
1217 "List received transactions by label.\n",
1220 "The minimum number of confirmations before payments are "
1223 "Whether to include labels that haven't received any payments."},
1226 "true for watch-only wallets, otherwise false"},
1227 "Whether to include watch-only addresses (see 'importaddress')."},
1239 "Only returns true if imported addresses were involved "
1242 "The total amount received by addresses with this label"},
1244 "The number of confirmations of the most recent "
1245 "transaction included"},
1247 "The label of the receiving address. The default label "
1256 std::shared_ptr<CWallet>
const wallet =
1266 pwallet->BlockUntilSyncedToCurrentChain();
1270 return ListReceived(config, pwallet, request.params,
true);
1294 int nMinDepth,
bool fLong,
UniValue &ret,
1296 const std::string *filter_label)
1299 std::list<COutputEntry> listReceived;
1300 std::list<COutputEntry> listSent;
1308 if (!filter_label) {
1311 if (involvesWatchonly ||
1313 entry.
pushKV(
"involvesWatchonly",
true);
1316 entry.
pushKV(
"category",
"send");
1317 entry.
pushKV(
"amount", -s.amount);
1318 const auto *address_book_entry =
1319 pwallet->FindAddressBookEntry(s.destination);
1320 if (address_book_entry) {
1321 entry.
pushKV(
"label", address_book_entry->GetLabel());
1323 entry.
pushKV(
"vout", s.vout);
1324 entry.
pushKV(
"fee", -1 * nFee);
1328 entry.
pushKV(
"abandoned", wtx.isAbandoned());
1329 ret.push_back(entry);
1334 if (listReceived.size() > 0 &&
1335 pwallet->GetTxDepthInMainChain(wtx) >= nMinDepth) {
1338 const auto *address_book_entry =
1339 pwallet->FindAddressBookEntry(r.destination);
1340 if (address_book_entry) {
1341 label = address_book_entry->GetLabel();
1343 if (filter_label && label != *filter_label) {
1347 if (involvesWatchonly ||
1349 entry.
pushKV(
"involvesWatchonly",
true);
1352 if (wtx.IsCoinBase()) {
1353 if (pwallet->GetTxDepthInMainChain(wtx) < 1) {
1354 entry.
pushKV(
"category",
"orphan");
1355 }
else if (pwallet->IsTxImmatureCoinBase(wtx)) {
1356 entry.
pushKV(
"category",
"immature");
1358 entry.
pushKV(
"category",
"generate");
1361 entry.
pushKV(
"category",
"receive");
1363 entry.
pushKV(
"amount", r.amount);
1364 if (address_book_entry) {
1365 entry.
pushKV(
"label", label);
1367 entry.
pushKV(
"vout", r.vout);
1371 ret.push_back(entry);
1379 "The number of confirmations for the transaction. Negative "
1380 "confirmations means the\n"
1381 "transaction conflicted that many blocks ago."},
1383 "Only present if transaction only input is a coinbase one."},
1385 "Only present if we consider transaction to be trusted and so safe to "
1388 "The block hash containing the transaction."},
1390 "The block height containing the transaction."},
1392 "The index of the transaction in the block that includes it."},
1398 "Conflicting transaction ids.",
1407 "If a comment is associated with the transaction, only present if not "
1416 "If a label name is provided, this will return only incoming "
1417 "transactions paying to addresses with the specified label.\n"
1418 "\nReturns up to 'count' most recent transactions skipping the first "
1419 "'from' transactions.\n",
1423 "If set, should be a valid label name to return only incoming "
1424 "transactions with the specified label, or \"*\" to disable "
1425 "filtering and return all transactions."},
1427 "The number of transactions to return"},
1429 "The number of transactions to skip"},
1432 "true for watch-only wallets, otherwise false"},
1433 "Include transactions to watch-only addresses (see "
1434 "'importaddress')"},
1442 Cat(
Cat<std::vector<RPCResult>>(
1445 "Only returns true if imported addresses were "
1446 "involved in transaction."},
1448 "The bitcoin address of the transaction."},
1450 "The transaction category.\n"
1451 "\"send\" Transactions sent.\n"
1452 "\"receive\" Non-coinbase "
1453 "transactions received.\n"
1454 "\"generate\" Coinbase transactions "
1455 "received with more than 100 confirmations.\n"
1456 "\"immature\" Coinbase transactions "
1457 "received with 100 or fewer confirmations.\n"
1458 "\"orphan\" Orphaned coinbase "
1459 "transactions received."},
1461 "The amount in " + ticker +
1462 ". This is negative for the 'send' category, "
1464 "for all other categories"},
1466 "A comment for the address/transaction, if any"},
1469 "The amount of the fee in " + ticker +
1470 ". This is negative and only available for "
1472 "'send' category of transactions."},
1477 "'true' if the transaction has been abandoned "
1478 "(inputs are respendable). Only available for the \n"
1479 "'send' category of transactions."},
1482 RPCExamples{
"\nList the most recent 10 transactions in the systems\n" +
1484 "\nList transactions 100 to 120\n" +
1486 "\nAs a JSON-RPC call\n" +
1490 std::shared_ptr<CWallet>
const wallet =
1500 pwallet->BlockUntilSyncedToCurrentChain();
1502 const std::string *filter_label =
nullptr;
1503 if (!request.params[0].isNull() &&
1504 request.params[0].get_str() !=
"*") {
1505 filter_label = &request.params[0].get_str();
1506 if (filter_label->empty()) {
1509 "Label argument must be a valid label name or \"*\".");
1513 if (!request.params[1].isNull()) {
1514 nCount = request.params[1].get_int();
1518 if (!request.params[2].isNull()) {
1519 nFrom = request.params[2].get_int();
1541 for (CWallet::TxItems::const_reverse_iterator it =
1543 it != txOrdered.rend(); ++it) {
1547 if (
int(ret.
size()) >= (nCount + nFrom)) {
1555 if (nFrom > (
int)ret.
size()) {
1558 if ((nFrom + nCount) > (
int)ret.
size()) {
1559 nCount = ret.
size() - nFrom;
1562 const std::vector<UniValue> &txs = ret.
getValues();
1566 {txs.rend() - nFrom - nCount, txs.rend() - nFrom});
1576 "Get all transactions in blocks since block [blockhash], or all "
1577 "transactions if omitted.\n"
1578 "If \"blockhash\" is no longer a part of the main chain, transactions "
1579 "from the fork point onward are included.\n"
1580 "Additionally, if include_removed is set, transactions affecting the "
1581 "wallet which were removed are returned in the \"removed\" array.\n",
1585 "If set, the block hash to list transactions since, otherwise "
1586 "list all transactions."},
1588 "Return the nth block hash from the main chain. e.g. 1 would mean "
1589 "the best block hash. Note: this is not used as a filter, but "
1590 "only affects [lastblock] in the return value"},
1593 "true for watch-only wallets, otherwise false"},
1594 "Include transactions to watch-only addresses (see "
1595 "'importaddress')"},
1597 "Show transactions that were removed due to a reorg in the "
1598 "\"removed\" array\n"
1600 "guaranteed to work on pruned nodes)"},
1612 Cat(
Cat<std::vector<RPCResult>>(
1615 "Only returns true if imported addresses "
1616 "were involved in transaction."},
1618 "The bitcoin address of the transaction."},
1620 "The transaction category.\n"
1621 "\"send\" Transactions "
1623 "\"receive\" Non-coinbase "
1624 "transactions received.\n"
1625 "\"generate\" Coinbase "
1626 "transactions received with more than 100 "
1628 "\"immature\" Coinbase "
1629 "transactions received with 100 or fewer "
1631 "\"orphan\" Orphaned "
1632 "coinbase transactions received."},
1634 "The amount in " + ticker +
1635 ". This is negative for the 'send' "
1636 "category, and is positive\n"
1637 "for all other categories"},
1641 "The amount of the fee in " + ticker +
1642 ". This is negative and only available "
1644 "'send' category of transactions."},
1649 "'true' if the transaction has been abandoned "
1650 "(inputs are respendable). Only available for "
1652 "'send' category of transactions."},
1654 "If a comment is associated with the "
1657 "A comment for the address/transaction, if any"},
1659 "If a comment to is associated with the "
1665 "<structure is the same as \"transactions\" above, only "
1666 "present if include_removed=true>\n"
1667 "Note: transactions that were re-added in the active chain "
1668 "will appear as-is in this array, and may thus have a "
1669 "positive confirmation count.",
1674 "The hash of the block (target_confirmations-1) from the best "
1675 "block on the main chain, or the genesis hash if the "
1676 "referenced block does not exist yet. This is typically used "
1677 "to feed back into listsinceblock the next time you call it. "
1678 "So you would generally use a target_confirmations of say 6, "
1679 "so you will be continually re-notified of transactions until "
1680 "they've reached 6 confirmations plus any new ones"},
1684 "\"000000000000000bacf66f7497b7dc45ef753ee9a"
1685 "7d38571037cdb1a57f663ad\" 6") +
1687 "\"000000000000000bacf66f7497b7dc45ef753ee9a"
1688 "7d38571037cdb1a57f663ad\", 6")},
1691 std::shared_ptr<CWallet>
const pwallet =
1702 wallet.BlockUntilSyncedToCurrentChain();
1708 std::optional<int> height;
1712 std::optional<int> altheight;
1713 int target_confirms = 1;
1717 if (!request.params[0].isNull() &&
1718 !request.params[0].get_str().empty()) {
1722 if (!
wallet.chain().findCommonAncestor(
1723 blockId,
wallet.GetLastBlockHash(),
1731 if (!request.params[1].isNull()) {
1732 target_confirms = request.params[1].get_int();
1734 if (target_confirms < 1) {
1736 "Invalid parameter");
1744 bool include_removed =
1745 (request.params[3].isNull() || request.params[3].get_bool());
1747 int depth = height ?
wallet.GetLastBlockHeight() + 1 - *height : -1;
1751 for (
const std::pair<const TxId, CWalletTx> &pairWtx :
1755 if (depth == -1 ||
wallet.GetTxDepthInMainChain(tx) < depth) {
1764 while (include_removed && altheight && *altheight > *height) {
1766 if (!
wallet.chain().findBlock(blockId,
1770 "Can't read block from disk");
1773 auto it =
wallet.mapWallet.find(tx->GetId());
1774 if (it !=
wallet.mapWallet.end()) {
1789 std::min(target_confirms,
wallet.GetLastBlockHeight() + 1);
1791 wallet.GetLastBlockHash(),
1792 wallet.GetLastBlockHeight() + 1 - target_confirms,
1796 ret.
pushKV(
"transactions", transactions);
1797 if (include_removed) {
1798 ret.
pushKV(
"removed", removed);
1811 "Get detailed information about in-wallet transaction <txid>\n",
1814 "The transaction id"},
1817 "true for watch-only wallets, otherwise false"},
1818 "Whether to include watch-only addresses in balance calculation "
1821 "Whether to include a `decoded` field containing the decoded "
1822 "transaction (equivalent to RPC decoderawtransaction)"},
1826 Cat(
Cat<std::vector<RPCResult>>(
1829 "The amount in " + ticker},
1831 "The amount of the fee in " + ticker +
1832 ". This is negative and only available for the\n"
1833 "'send' category of transactions."},
1846 "Only returns true if imported addresses were "
1847 "involved in transaction."},
1849 "The bitcoin address involved in the "
1852 "The transaction category.\n"
1853 "\"send\" Transactions sent.\n"
1854 "\"receive\" Non-coinbase "
1855 "transactions received.\n"
1856 "\"generate\" Coinbase "
1857 "transactions received with more than 100 "
1859 "\"immature\" Coinbase "
1860 "transactions received with 100 or fewer "
1862 "\"orphan\" Orphaned coinbase "
1863 "transactions received."},
1865 "The amount in " + ticker},
1867 "A comment for the address/transaction, if any"},
1870 "The amount of the fee in " + ticker +
1871 ". This is negative and only available for "
1873 "'send' category of transactions."},
1875 "'true' if the transaction has been abandoned "
1876 "(inputs are respendable). Only available for "
1878 "'send' category of transactions."},
1882 "Raw data for transaction"},
1885 "Optional, the decoded transaction (only present when "
1886 "`verbose` is passed)",
1889 "Equivalent to the RPC decoderawtransaction method, "
1890 "or the RPC getrawtransaction method when `verbose` "
1895 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1896 "5cf302fc80e9d5fbf5d48d\"") +
1898 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1899 "5cf302fc80e9d5fbf5d48d\" true") +
1901 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1902 "5cf302fc80e9d5fbf5d48d\" false true") +
1904 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1905 "5cf302fc80e9d5fbf5d48d\"")},
1908 std::shared_ptr<CWallet>
const wallet =
1918 pwallet->BlockUntilSyncedToCurrentChain();
1929 bool verbose = request.params[2].isNull()
1931 : request.params[2].get_bool();
1934 auto it = pwallet->mapWallet.find(txid);
1935 if (it == pwallet->mapWallet.end()) {
1937 "Invalid or non-wallet transaction id");
1943 Amount nNet = nCredit - nDebit;
1945 ? wtx.
tx->GetValueOut() - nDebit
1948 entry.
pushKV(
"amount", nNet - nFee);
1950 entry.
pushKV(
"fee", nFee);
1958 entry.
pushKV(
"details", details);
1960 std::string strHex =
1962 entry.
pushKV(
"hex", strHex);
1967 entry.
pushKV(
"decoded", decoded);
1977 "abandontransaction",
1978 "Mark in-wallet transaction <txid> as abandoned\n"
1979 "This will mark this transaction and all its in-wallet descendants as "
1980 "abandoned which will allow\n"
1981 "for their inputs to be respent. It can be used to replace \"stuck\" "
1982 "or evicted transactions.\n"
1983 "It only works on transactions which are not included in a block and "
1984 "are not currently in the mempool.\n"
1985 "It has no effect on transactions which are already abandoned.\n",
1988 "The transaction id"},
1992 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1993 "5cf302fc80e9d5fbf5d48d\"") +
1995 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1996 "5cf302fc80e9d5fbf5d48d\"")},
1999 std::shared_ptr<CWallet>
const wallet =
2009 pwallet->BlockUntilSyncedToCurrentChain();
2015 if (!pwallet->mapWallet.count(txid)) {
2017 "Invalid or non-wallet transaction id");
2022 "Transaction not eligible for abandonment");
2036 "The new keypool size"},
2043 std::shared_ptr<CWallet>
const wallet =
2054 "Error: Private keys are disabled for this wallet");
2061 unsigned int kpSize = 0;
2062 if (!request.params[0].isNull()) {
2063 if (request.params[0].get_int() < 0) {
2066 "Invalid parameter, expected valid size.");
2068 kpSize = (
unsigned int)request.params[0].get_int();
2076 "Error refreshing keypool.");
2087 "Updates list of temporarily unspendable outputs.\n"
2088 "Temporarily lock (unlock=false) or unlock (unlock=true) specified "
2089 "transaction outputs.\n"
2090 "If no transaction outputs are specified when unlocking then all "
2091 "current locked transaction outputs are unlocked.\n"
2092 "A locked transaction output will not be chosen by automatic coin "
2093 "selection, when spending bitcoins.\n"
2094 "Manually selected coins are automatically unlocked.\n"
2095 "Locks are stored in memory only. Nodes start with zero locked "
2096 "outputs, and the locked output list\n"
2097 "is always cleared (by virtue of process exit) when a node stops or "
2099 "Also see the listunspent call\n",
2102 "Whether to unlock (true) or lock (false) the specified "
2108 "The transaction outputs and within each, txid (string) vout "
2120 "The output number"},
2127 "Whether the command was successful or not"},
2129 "\nList the unspent transactions\n" +
2131 "\nLock an unspent transaction\n" +
2134 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2135 "b764ed838b5655e72f463568df1aadf0\\\""
2136 ",\\\"vout\\\":1}]\"") +
2137 "\nList the locked transactions\n" +
2139 "\nUnlock the transaction again\n" +
2142 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2143 "b764ed838b5655e72f463568df1aadf0\\\""
2144 ",\\\"vout\\\":1}]\"") +
2145 "\nAs a JSON-RPC call\n" +
2148 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2149 "b764ed838b5655e72f463568df1aadf0\\\""
2150 ",\\\"vout\\\":1}]\"")},
2153 std::shared_ptr<CWallet>
const wallet =
2163 pwallet->BlockUntilSyncedToCurrentChain();
2169 bool fUnlock = request.params[0].get_bool();
2171 if (request.params[1].isNull()) {
2180 const UniValue &output_params = request.params[1];
2184 std::vector<COutPoint> outputs;
2187 for (
size_t idx = 0; idx < output_params.
size(); idx++) {
2199 "Invalid parameter, vout cannot be negative");
2203 const auto it = pwallet->mapWallet.find(txid);
2204 if (it == pwallet->mapWallet.end()) {
2207 "Invalid parameter, unknown transaction");
2212 if (output.
GetN() >= trans.
tx->vout.size()) {
2215 "Invalid parameter, vout index out of bounds");
2218 if (pwallet->
IsSpent(output)) {
2221 "Invalid parameter, expected unspent output");
2225 if (fUnlock && !is_locked) {
2228 "Invalid parameter, expected locked output");
2231 if (!fUnlock && is_locked) {
2234 "Invalid parameter, output already locked");
2237 outputs.push_back(output);
2241 for (
const COutPoint &output : outputs) {
2257 "Returns list of temporarily unspendable outputs.\n"
2258 "See the lockunspent call to lock and unlock transactions for "
2270 "The transaction id locked"},
2275 "\nList the unspent transactions\n" +
2277 "\nLock an unspent transaction\n" +
2280 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2281 "b764ed838b5655e72f463568df1aadf0\\\""
2282 ",\\\"vout\\\":1}]\"") +
2283 "\nList the locked transactions\n" +
2285 "\nUnlock the transaction again\n" +
2288 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2289 "b764ed838b5655e72f463568df1aadf0\\\""
2290 ",\\\"vout\\\":1}]\"") +
2291 "\nAs a JSON-RPC call\n" +
HelpExampleRpc(
"listlockunspent",
"")},
2294 std::shared_ptr<CWallet>
const wallet =
2303 std::vector<COutPoint> vOutpts;
2308 for (
const COutPoint &output : vOutpts) {
2311 o.
pushKV(
"txid", output.GetTxId().GetHex());
2312 o.
pushKV(
"vout",
int(output.GetN()));
2324 "Set the transaction fee per kB for this wallet. Overrides the "
2325 "global -paytxfee command line parameter.\n"
2326 "Can be deactivated by passing 0 as the fee. In that case automatic "
2327 "fee selection will be used by default.\n",
2337 std::shared_ptr<CWallet>
const wallet =
2347 CFeeRate tx_fee_rate(nAmount, 1000);
2351 }
else if (tx_fee_rate < pwallet->chain().relayMinFee()) {
2354 strprintf(
"txfee cannot be less than min relay tx fee (%s)",
2356 }
else if (tx_fee_rate < pwallet->m_min_fee) {
2359 strprintf(
"txfee cannot be less than wallet min fee (%s)",
2361 }
else if (tx_fee_rate > max_tx_fee_rate) {
2365 "txfee cannot be more than wallet max tx fee (%s)",
2387 "balances from outputs that the wallet can sign",
2390 "trusted balance (outputs created by the wallet or "
2391 "confirmed outputs)"},
2393 "untrusted pending balance (outputs created by "
2394 "others that are in the mempool)"},
2396 "balance from immature coinbase outputs"},
2398 "(only present if avoid_reuse is set) balance from "
2399 "coins sent to addresses that were previously "
2400 "spent from (potentially privacy violating)"},
2404 "watchonly balances (not present if wallet does not "
2408 "trusted balance (outputs created by the wallet or "
2409 "confirmed outputs)"},
2411 "untrusted pending balance (outputs created by "
2412 "others that are in the mempool)"},
2414 "balance from immature coinbase outputs"},
2421 std::shared_ptr<CWallet>
const rpc_wallet =
2431 wallet.BlockUntilSyncedToCurrentChain();
2439 balances_mine.pushKV(
"trusted", bal.m_mine_trusted);
2440 balances_mine.pushKV(
"untrusted_pending",
2441 bal.m_mine_untrusted_pending);
2442 balances_mine.pushKV(
"immature", bal.m_mine_immature);
2448 balances_mine.pushKV(
"used",
2449 full_bal.m_mine_trusted +
2450 full_bal.m_mine_untrusted_pending -
2451 bal.m_mine_trusted -
2452 bal.m_mine_untrusted_pending);
2454 balances.pushKV(
"mine", balances_mine);
2456 auto spk_man =
wallet.GetLegacyScriptPubKeyMan();
2457 if (spk_man && spk_man->HaveWatchOnly()) {
2459 balances_watchonly.pushKV(
"trusted", bal.m_watchonly_trusted);
2460 balances_watchonly.pushKV(
"untrusted_pending",
2461 bal.m_watchonly_untrusted_pending);
2462 balances_watchonly.pushKV(
"immature", bal.m_watchonly_immature);
2463 balances.pushKV(
"watchonly", balances_watchonly);
2473 "Returns an object containing various wallet state info.\n",
2483 "DEPRECATED. Identical to getbalances().mine.trusted"},
2485 "DEPRECATED. Identical to "
2486 "getbalances().mine.untrusted_pending"},
2488 "DEPRECATED. Identical to getbalances().mine.immature"},
2490 "the total number of transactions in the wallet"},
2493 " of the oldest pre-generated key in the key pool. Legacy "
2496 "how many new keys are pre-generated (only counts external "
2499 "how many new keys are pre-generated for internal use (used "
2500 "for change outputs, only appears if the wallet is using this "
2501 "feature, otherwise external keys are used)"},
2505 " until which the wallet is unlocked for transfers, or 0 "
2506 "if the wallet is locked (only present for "
2507 "passphrase-encrypted wallets)"},
2509 "the transaction fee configuration, set in " +
2512 "the Hash160 of the HD seed (only present when HD is "
2515 "false if privatekeys are disabled for this wallet (enforced "
2516 "watch-only wallet)"},
2519 "current scanning details, or false if no scan is in progress",
2522 "elapsed seconds since scan start"},
2524 "scanning progress percentage [0.0, 1.0]"},
2527 "whether this wallet tracks clean/dirty coins in terms of "
2530 "whether this wallet uses descriptors for scriptPubKey "
2538 std::shared_ptr<CWallet>
const wallet =
2548 pwallet->BlockUntilSyncedToCurrentChain();
2559 obj.
pushKV(
"balance", bal.m_mine_trusted);
2560 obj.
pushKV(
"unconfirmed_balance", bal.m_mine_untrusted_pending);
2561 obj.
pushKV(
"immature_balance", bal.m_mine_immature);
2562 obj.
pushKV(
"txcount", (
int)pwallet->mapWallet.size());
2563 if (kp_oldest > 0) {
2564 obj.
pushKV(
"keypoololdest", kp_oldest);
2566 obj.
pushKV(
"keypoolsize", (int64_t)kpExternalSize);
2578 obj.
pushKV(
"keypoolsize_hd_internal",
2582 obj.
pushKV(
"unlocked_until", pwallet->nRelockTime);
2586 "private_keys_enabled",
2592 obj.
pushKV(
"scanning", scanning);
2594 obj.
pushKV(
"scanning",
false);
2596 obj.
pushKV(
"avoid_reuse",
2598 obj.
pushKV(
"descriptors",
2608 "Returns a list of wallets in the wallet directory.\n",
2634 wallet.pushKV(
"name", path.u8string());
2639 result.
pushKV(
"wallets", wallets);
2648 "Returns a list of currently loaded wallets.\n"
2649 "For full information on the wallet, use \"getwalletinfo\"\n",
2676 "Loads a wallet from a wallet file or directory."
2677 "\nNote that all wallet command-line options used when starting "
2679 "\napplied to the new wallet (eg -rescan, etc).\n",
2682 "The wallet directory or .dat file."},
2685 "Save wallet name to persistent settings and load on startup. "
2686 "True to add wallet to startup list, false to remove, null to "
2687 "leave unchanged."},
2694 "The wallet name if loaded successfully."},
2696 "Warning message if wallet was not loaded cleanly."},
2703 const std::string
name(request.params[0].get_str());
2705 auto [
wallet, warnings] =
2718 std::string
flags =
"";
2721 flags += (
flags ==
"" ?
"" :
", ") + it.first;
2726 "Change the state of the given wallet flag for a wallet.\n",
2729 "The name of the flag to change. Current available flags: " +
2739 "The name of the flag that was modified"},
2741 "The new state of the flag"},
2743 "Any warnings associated with the change"},
2749 std::shared_ptr<CWallet>
const wallet =
2756 std::string flag_str = request.params[0].get_str();
2758 request.params[1].isNull() || request.params[1].get_bool();
2763 strprintf(
"Unknown wallet flag: %s", flag_str));
2771 strprintf(
"Wallet flag is immutable: %s", flag_str));
2779 strprintf(
"Wallet flag is already set to %s: %s",
2780 value ?
"true" :
"false", flag_str));
2783 res.
pushKV(
"flag_name", flag_str);
2784 res.
pushKV(
"flag_state", value);
2787 pwallet->SetWalletFlag(flag);
2804 "Creates and loads a new wallet.\n",
2807 "The name for the new wallet. If this is a path, the wallet will "
2808 "be created at the path location."},
2810 "Disable the possibility of private keys (only watchonlys are "
2811 "possible in this mode)."},
2813 "Create a blank wallet. A blank wallet has no keys or HD seed. "
2814 "One can be set using sethdseed."},
2816 "Encrypt the wallet with this passphrase."},
2818 "Keep track of coin reuse, and treat dirty and clean coins "
2819 "differently with privacy considerations in mind."},
2821 "Create a native descriptor wallet. The wallet will use "
2822 "descriptors internally to handle address creation"},
2825 "Save wallet name to persistent settings and load on startup. "
2826 "True to add wallet to startup list, false to remove, null to "
2827 "leave unchanged."},
2834 "The wallet name if created successfully. If the wallet "
2835 "was created using a full path, the wallet_name will be "
2838 "Warning message if wallet was not loaded cleanly."},
2844 {
"avoid_reuse",
true},
2845 {
"descriptors",
true},
2846 {
"load_on_startup",
true}}) +
2848 {
"avoid_reuse",
true},
2849 {
"descriptors",
true},
2850 {
"load_on_startup",
true}})},
2855 if (!request.params[1].isNull() && request.params[1].get_bool()) {
2859 if (!request.params[2].isNull() && request.params[2].get_bool()) {
2864 passphrase.reserve(100);
2865 std::vector<bilingual_str> warnings;
2866 if (!request.params[3].isNull()) {
2867 passphrase = request.params[3].get_str().c_str();
2868 if (passphrase.empty()) {
2871 "Empty string given as passphrase, wallet will "
2872 "not be encrypted."));
2876 if (!request.params[4].isNull() && request.params[4].get_bool()) {
2879 if (!request.params[5].isNull() && request.params[5].get_bool()) {
2882 "Wallet is an experimental descriptor wallet"));
2891 std::optional<bool> load_on_start =
2892 request.params[6].isNull()
2894 : std::make_optional<bool>(request.params[6].get_bool());
2895 std::shared_ptr<CWallet>
wallet =
2897 load_on_start, options, status,
error, warnings);
2917 "Unloads the wallet referenced by the request endpoint otherwise "
2918 "unloads the wallet specified in the argument.\n"
2919 "Specifying the wallet name on a wallet endpoint is invalid.",
2923 "The name of the wallet to unload."},
2926 "Save wallet name to persistent settings and load on startup. "
2927 "True to add wallet to startup list, false to remove, null to "
2928 "leave unchanged."},
2935 "Warning message if wallet was not unloaded cleanly."},
2941 std::string wallet_name;
2943 if (!request.params[0].isNull()) {
2945 "Cannot unload the requested wallet");
2948 wallet_name = request.params[0].get_str();
2955 "Requested wallet does not exist or is not loaded");
2961 std::vector<bilingual_str> warnings;
2962 std::optional<bool> load_on_start =
2963 request.params[1].isNull()
2965 : std::make_optional<bool>(request.params[1].get_bool());
2968 "Requested wallet already unloaded");
2985 "Returns array of unspent transaction outputs\n"
2986 "with between minconf and maxconf (inclusive) confirmations.\n"
2987 "Optionally filter to only include txouts paid to specified "
2991 "The minimum confirmations to filter"},
2993 "The maximum confirmations to filter"},
2998 "The bitcoin addresses to filter",
3005 "Include outputs that are not safe to spend\n"
3006 " See description of \"safe\" attribute below."},
3010 "JSON with query options",
3014 "Minimum value of each UTXO in " + ticker +
""},
3017 "Maximum value of each UTXO in " + ticker +
""},
3022 "Minimum sum value of all UTXOs in " + ticker +
""},
3039 "The associated label, or \"\" for the default label"},
3042 "the transaction output amount in " + ticker},
3044 "The number of confirmations"},
3047 "DEPRECATED: The number of in-mempool ancestor "
3048 "transactions, including this one (if transaction is in "
3049 "the mempool). Only displayed if the "
3050 "-deprecatedrpc=mempool_ancestors_descendants option is "
3053 "DEPRECATED: The virtual transaction size of in-mempool "
3054 " ancestors, including this one (if transaction is in "
3055 "the mempool). Only displayed if the "
3056 "-deprecatedrpc=mempool_ancestors_descendants option is "
3060 "DEPRECATED: The total fees of in-mempool ancestors "
3061 "(including this one) with fee deltas used for mining "
3064 " (if transaction is in the mempool). Only "
3066 "-deprecatedrpc=mempool_ancestors_descendants option "
3070 "The redeemScript if scriptPubKey is P2SH"},
3072 "Whether we have the private keys to spend this output"},
3074 "Whether we know how to spend this output, ignoring the "
3077 "(only present if avoid_reuse is set) Whether this "
3078 "output is reused/dirty (sent to an address that was "
3079 "previously spent from)"},
3081 "(only when solvable) A descriptor for spending this "
3084 "Whether this output is considered safe to spend. "
3085 "Unconfirmed transactions\n"
3086 "from outside keys are considered unsafe\n"
3087 "and are not eligible for spending by fundrawtransaction "
3088 "and sendtoaddress."},
3095 "\"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\","
3096 "\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"") +
3099 "\"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\","
3100 "\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"") +
3103 "6 9999999 '[]' true '{ \"minimumAmount\": 0.005 }'") +
3106 "6, 9999999, [] , true, { \"minimumAmount\": 0.005 } ")},
3109 std::shared_ptr<CWallet>
const wallet =
3117 if (!request.params[0].isNull()) {
3119 nMinDepth = request.params[0].get_int();
3122 int nMaxDepth = 9999999;
3123 if (!request.params[1].isNull()) {
3125 nMaxDepth = request.params[1].get_int();
3128 std::set<CTxDestination> destinations;
3129 if (!request.params[2].isNull()) {
3132 for (
size_t idx = 0; idx < inputs.
size(); idx++) {
3133 const UniValue &input = inputs[idx];
3139 std::string(
"Invalid Bitcoin address: ") +
3142 if (!destinations.insert(dest).second) {
3146 "Invalid parameter, duplicated address: ") +
3152 bool include_unsafe =
true;
3153 if (!request.params[3].isNull()) {
3155 include_unsafe = request.params[3].get_bool();
3161 uint64_t nMaximumCount = 0;
3163 if (!request.params[4].isNull()) {
3176 if (options.
exists(
"minimumAmount")) {
3180 if (options.
exists(
"maximumAmount")) {
3184 if (options.
exists(
"minimumSumAmount")) {
3189 if (options.
exists(
"maximumCount")) {
3190 nMaximumCount = options[
"maximumCount"].
get_int64();
3197 pwallet->BlockUntilSyncedToCurrentChain();
3200 std::vector<COutput> vecOutputs;
3209 nMaximumAmount, nMinimumSumAmount,
3215 const bool avoid_reuse =
3218 for (
const COutput &out : vecOutputs) {
3221 out.tx->tx->vout[out.i].scriptPubKey;
3224 avoid_reuse && pwallet->
IsSpentKey(out.tx->GetId(), out.i);
3226 if (destinations.size() &&
3227 (!fValidAddress || !destinations.count(address))) {
3232 entry.
pushKV(
"txid", out.tx->GetId().GetHex());
3233 entry.
pushKV(
"vout", out.i);
3235 if (fValidAddress) {
3238 const auto *address_book_entry =
3240 if (address_book_entry) {
3241 entry.
pushKV(
"label", address_book_entry->GetLabel());
3244 std::unique_ptr<SigningProvider> provider =
3249 CScriptID(std::get<ScriptHash>(address));
3251 if (provider->GetCScript(hash, redeemScript)) {
3252 entry.
pushKV(
"redeemScript",
3260 entry.
pushKV(
"amount", out.tx->tx->vout[out.i].nValue);
3261 entry.
pushKV(
"confirmations", out.nDepth);
3262 entry.
pushKV(
"spendable", out.fSpendable);
3263 entry.
pushKV(
"solvable", out.fSolvable);
3264 if (out.fSolvable) {
3265 std::unique_ptr<SigningProvider> provider =
3270 entry.
pushKV(
"desc", descriptor->ToString());
3274 entry.
pushKV(
"reused", reused);
3276 entry.
pushKV(
"safe", out.fSafe);
3286 Amount &fee_out,
int &change_position,
3290 pwallet->BlockUntilSyncedToCurrentChain();
3292 change_position = -1;
3293 bool lockUnspents =
false;
3295 std::set<int> setSubtractFeeFromOutputs;
3328 if (options.
exists(
"add_inputs")) {
3332 if (options.
exists(
"changeAddress") ||
3333 options.
exists(
"change_address")) {
3334 const std::string change_address_str =
3335 (options.
exists(
"change_address")
3336 ? options[
"change_address"]
3337 : options[
"changeAddress"])
3345 "Change address must be a valid bitcoin address");
3351 if (options.
exists(
"changePosition") ||
3352 options.
exists(
"change_position")) {
3353 change_position = (options.
exists(
"change_position")
3354 ? options[
"change_position"]
3355 : options[
"changePosition"])
3359 const UniValue include_watching_option =
3360 options.
exists(
"include_watching") ? options[
"include_watching"]
3361 : options[
"includeWatching"];
3365 if (options.
exists(
"lockUnspents") ||
3366 options.
exists(
"lock_unspents")) {
3368 (options.
exists(
"lock_unspents") ? options[
"lock_unspents"]
3369 : options[
"lockUnspents"])
3373 if (options.
exists(
"include_unsafe")) {
3375 options[
"include_unsafe"].
get_bool();
3378 if (options.
exists(
"feeRate") || options.
exists(
"fee_rate")) {
3380 options.
exists(
"fee_rate") ? options[
"fee_rate"]
3381 : options[
"feeRate"]));
3385 if (options.
exists(
"subtractFeeFromOutputs") ||
3386 options.
exists(
"subtract_fee_from_outputs")) {
3387 subtractFeeFromOutputs =
3388 (options.
exists(
"subtract_fee_from_outputs")
3389 ? options[
"subtract_fee_from_outputs"]
3390 : options[
"subtractFeeFromOutputs"])
3400 if (tx.
vout.size() == 0) {
3402 "TX must have at least one output");
3405 if (change_position != -1 &&
3406 (change_position < 0 ||
3407 (
unsigned int)change_position > tx.
vout.size())) {
3409 "changePosition out of bounds");
3412 for (
size_t idx = 0; idx < subtractFeeFromOutputs.
size(); idx++) {
3413 int pos = subtractFeeFromOutputs[idx].
get_int();
3414 if (setSubtractFeeFromOutputs.count(pos)) {
3417 strprintf(
"Invalid parameter, duplicated position: %d", pos));
3422 strprintf(
"Invalid parameter, negative position: %d", pos));
3424 if (pos >=
int(tx.
vout.size())) {
3427 strprintf(
"Invalid parameter, position too large: %d", pos));
3429 setSubtractFeeFromOutputs.insert(pos);
3435 lockUnspents, setSubtractFeeFromOutputs,
3444 "fundrawtransaction",
3445 "If the transaction has no inputs, they will be automatically selected "
3446 "to meet its out value.\n"
3447 "It will add at most one change output to the outputs.\n"
3448 "No existing outputs will be modified unless "
3449 "\"subtractFeeFromOutputs\" is specified.\n"
3450 "Note that inputs which were signed may need to be resigned after "
3451 "completion since in/outputs have been added.\n"
3452 "The inputs added will not be signed, use signrawtransactionwithkey or "
3453 "signrawtransactionwithwallet for that.\n"
3454 "Note that all existing inputs must have their previous output "
3455 "transaction be in the wallet.\n"
3456 "Note that all inputs selected must be of standard form and P2SH "
3458 "in the wallet using importaddress or addmultisigaddress (to calculate "
3460 "You can see whether this is the case by checking the \"solvable\" "
3461 "field in the listunspent output.\n"
3462 "Only pay-to-pubkey, multisig, and P2SH versions thereof are currently "
3463 "supported for watch-only\n",
3466 "The hex string of the raw transaction"},
3470 "for backward compatibility: passing in a true instead of an "
3471 "object will result in {\"includeWatching\":true}",
3474 "For a transaction with existing inputs, automatically "
3475 "include more if they are not enough."},
3477 "Include inputs that are not safe to spend (unconfirmed "
3478 "transactions from outside keys).\n"
3479 "Warning: the resulting transaction may become invalid if "
3480 "one of the unsafe inputs disappears.\n"
3481 "If that happens, you will need to fund the transaction with "
3482 "different inputs and republish it."},
3485 "The bitcoin address to receive the change"},
3488 "The index of the change output"},
3491 "true for watch-only wallets, otherwise false"},
3492 "Also select inputs which are watch only.\n"
3493 "Only solvable inputs can be used. Watch-only destinations "
3494 "are solvable if the public key and/or output script was "
3496 "e.g. with 'importpubkey' or 'importmulti' with the "
3497 "'pubkeys' or 'desc' field."},
3499 "Lock selected unspent outputs"},
3502 "not set: makes wallet determine the fee"},
3503 "Set a specific fee rate in " + ticker +
"/kB"},
3505 "subtractFeeFromOutputs",
3509 " The fee will be equally "
3510 "deducted from the amount of each specified output.\n"
3511 " Those recipients will "
3512 "receive less bitcoins than you enter in their "
3513 "corresponding amount field.\n"
3514 " If no outputs are "
3515 "specified here, the sender pays the fee.",
3519 "The zero-based output index, before a change output "
3531 "The resulting raw transaction (hex-encoded string)"},
3533 "Fee in " + ticker +
" the resulting transaction pays"},
3535 "The position of the added change output, or -1"},
3538 "\nCreate a transaction with no inputs\n" +
3540 "\"[]\" \"{\\\"myaddress\\\":10000}\"") +
3541 "\nAdd sufficient unsigned inputs to meet the output value\n" +
3543 "\nSign the transaction\n" +
3545 "\"fundedtransactionhex\"") +
3546 "\nSend the transaction\n" +
3547 HelpExampleCli(
"sendrawtransaction",
"\"signedtransactionhex\"")},
3550 std::shared_ptr<CWallet>
const wallet =
3557 RPCTypeCheck(request.params, {UniValue::VSTR, UniValueType()});
3561 if (!
DecodeHexTx(tx, request.params[0].get_str())) {
3563 "TX decode failed");
3567 int change_position;
3573 request.params[1], coin_control);
3577 result.
pushKV(
"fee", fee);
3578 result.
pushKV(
"changepos", change_position);
3587 "signrawtransactionwithwallet",
3588 "Sign inputs for raw transaction (serialized, hex-encoded).\n"
3589 "The second optional argument (may be null) is an array of previous "
3590 "transaction outputs that\n"
3591 "this transaction depends on but may not yet be in the block chain.\n" +
3595 "The transaction hex string"},
3600 "The previous dependent transaction outputs",
3611 "The output number"},
3623 "The signature hash type. Must be one of\n"
3625 " \"NONE|FORKID\"\n"
3626 " \"SINGLE|FORKID\"\n"
3627 " \"ALL|FORKID|ANYONECANPAY\"\n"
3628 " \"NONE|FORKID|ANYONECANPAY\"\n"
3629 " \"SINGLE|FORKID|ANYONECANPAY\""},
3637 "The hex-encoded raw transaction with signature(s)"},
3639 "If the transaction has a complete set of signatures"},
3643 "Script verification errors (if there are any)",
3650 "The hash of the referenced, previous transaction"},
3652 "The index of the output to spent and used as "
3655 "The hex-encoded signature script"},
3657 "Script sequence number"},
3659 "Verification or signing error related to the "
3669 std::shared_ptr<CWallet>
const wallet =
3677 {UniValue::VSTR, UniValue::VARR, UniValue::VSTR},
3681 if (!
DecodeHexTx(mtx, request.params[0].get_str())) {
3683 "TX decode failed");
3691 std::map<COutPoint, Coin> coins;
3692 for (
const CTxIn &txin : mtx.
vin) {
3704 "Signature must use SIGHASH_FORKID");
3708 std::map<int, std::string> input_errors;
3723 "Rescan the local blockchain for wallet related transactions.\n"
3724 "Note: Use \"getwalletinfo\" to query the scanning progress.\n",
3727 "block height where the rescan should start"},
3730 "the last block height that should be scanned"},
3738 "The block height where the rescan started (the requested "
3741 "The height of the last rescanned block. May be null in rare "
3742 "cases if there was a reorg and the call didn't scan any "
3743 "blocks because they were already scanned in the background."},
3749 std::shared_ptr<CWallet>
const wallet =
3759 "Wallet is currently rescanning. Abort "
3760 "existing rescan or wait.");
3763 int start_height = 0;
3764 std::optional<int> stop_height;
3770 if (!request.params[0].isNull()) {
3771 start_height = request.params[0].get_int();
3772 if (start_height < 0 || start_height > tip_height) {
3774 "Invalid start_height");
3778 if (!request.params[1].isNull()) {
3779 stop_height = request.params[1].get_int();
3780 if (*stop_height < 0 || *stop_height > tip_height) {
3782 "Invalid stop_height");
3783 }
else if (*stop_height < start_height) {
3786 "stop_height must be greater than start_height");
3793 start_height, stop_height)) {
3796 "Can't rescan beyond pruned data. Use RPC call "
3797 "getblockchaininfo to determine your pruned height.");
3806 start_block, start_height, stop_height, reserver,
3814 "Rescan failed. Potentially corrupted data files.");
3821 response.pushKV(
"start_height", start_height);
3836 std::vector<std::vector<uint8_t>> solutions_data;
3847 UniValue wallet_detail = std::visit(*
this, embedded);
3848 subobj.
pushKVs(wallet_detail);
3853 if (subobj.
exists(
"pubkey")) {
3854 obj.
pushKV(
"pubkey", subobj[
"pubkey"]);
3856 obj.
pushKV(
"embedded", std::move(subobj));
3862 obj.
pushKV(
"sigsrequired", solutions_data[0][0]);
3864 for (
size_t i = 1; i < solutions_data.size() - 1; ++i) {
3865 CPubKey key(solutions_data[i].begin(), solutions_data[i].end());
3868 obj.
pushKV(
"pubkeys", std::move(pubkeys));
3906 std::unique_ptr<SigningProvider> provider =
nullptr;
3917 const bool verbose) {
3929 "Return information about the given bitcoin address.\n"
3930 "Some of the information will only be present if the address is in the "
3934 "The bitcoin address for which to get information."},
3942 "The bitcoin address validated."},
3944 "The hex-encoded scriptPubKey generated by the address."},
3947 "If the address is watchonly."},
3949 "If we know how to spend coins sent to this address, ignoring "
3950 "the possible lack of private keys."},
3952 "A descriptor for spending coins sent to this address (only "
3956 "If the address was used for change output."},
3958 "The output script type. Only if isscript is true and the "
3959 "redeemscript is known. Possible\n"
3961 "types: nonstandard, pubkey, pubkeyhash, scripthash, "
3962 "multisig, nulldata."},
3964 "The redeemscript for the p2sh address."},
3968 "Array of pubkeys associated with the known redeemscript "
3969 "(only if script is multisig).",
3974 "The number of signatures required to spend multisig output "
3975 "(only if script is multisig)."},
3977 "The hex value of the raw public key for single-key addresses "
3978 "(possibly embedded in P2SH)."},
3982 "Information about the address embedded in P2SH, if "
3983 "relevant and known.",
3986 "Includes all getaddressinfo output fields for the "
3987 "embedded address excluding metadata (timestamp, "
3988 "hdkeypath, hdseedid)\n"
3989 "and relation to the wallet (ismine, iswatchonly)."},
3992 "If the pubkey is compressed."},
3994 "The creation time of the key, if available, expressed in " +
3997 "The HD keypath, if the key is HD and available."},
3999 "The Hash160 of the HD seed."},
4001 true,
"The fingerprint of the master key."},
4004 "Array of labels associated with the address. Currently "
4005 "limited to one label but returned\n"
4006 "as an array to keep the API stable if multiple labels are "
4007 "enabled in the future.",
4010 "Label name (defaults to \"\")."},
4017 std::shared_ptr<CWallet>
const wallet =
4028 wallet->GetChainParams());
4036 ret.
pushKV(
"address", currentAddress);
4041 std::unique_ptr<SigningProvider> provider =
4047 bool solvable = provider &&
IsSolvable(*provider, scriptPubKey);
4048 ret.
pushKV(
"solvable", solvable);
4066 if (
const std::unique_ptr<CKeyMetadata> meta =
4068 ret.
pushKV(
"timestamp", meta->nCreateTime);
4069 if (meta->has_key_origin) {
4072 ret.
pushKV(
"hdseedid", meta->hd_seed_id.GetHex());
4073 ret.
pushKV(
"hdmasterfingerprint",
4074 HexStr(meta->key_origin.fingerprint));
4085 const auto *address_book_entry =
4087 if (address_book_entry) {
4088 labels.
push_back(address_book_entry->GetLabel());
4090 ret.
pushKV(
"labels", std::move(labels));
4099 "getaddressesbylabel",
4100 "Returns the list of addresses assigned the specified label.\n",
4106 "json object with addresses as keys",
4110 "Information about address",
4113 "Purpose of address (\"send\" for sending address, "
4114 "\"receive\" for receiving address)"},
4121 std::shared_ptr<CWallet>
const wallet =
4134 std::set<std::string> addresses;
4135 for (
const std::pair<const CTxDestination, CAddressBookData> &item :
4136 pwallet->m_address_book) {
4137 if (item.second.IsChange()) {
4140 if (item.second.GetLabel() == label) {
4158 std::string(
"No addresses with label " + label));
4169 "Returns the list of all labels, or labels that are assigned to "
4170 "addresses with a specific purpose.\n",
4173 "Address purpose to list labels for ('send','receive'). An empty "
4174 "string is the same as not providing this argument."},
4183 "\nList labels that have receiving addresses\n" +
4185 "\nList labels that have sending addresses\n" +
4187 "\nAs a JSON-RPC call\n" +
4191 std::shared_ptr<CWallet>
const wallet =
4200 std::string purpose;
4201 if (!request.params[0].isNull()) {
4202 purpose = request.params[0].get_str();
4207 std::set<std::string> label_set;
4208 for (
const std::pair<const CTxDestination, CAddressBookData>
4209 &entry : pwallet->m_address_book) {
4210 if (entry.second.IsChange()) {
4213 if (purpose.empty() || entry.second.purpose == purpose) {
4214 label_set.insert(entry.second.GetLabel());
4219 for (
const std::string &
name : label_set) {
4231 "EXPERIMENTAL warning: this call may be changed in future releases.\n"
4232 "\nSend a transaction.\n",
4238 "A JSON array with outputs (key-value pairs), where none of "
4239 "the keys are duplicated.\n"
4240 "That is, each address can only appear once and there can only "
4241 "be one 'data' object.\n"
4242 "For convenience, a dictionary, which holds the key-value "
4243 "pairs directly, is also accepted.",
4253 "A key-value pair. The key (string) is the "
4254 "bitcoin address, the value (float or string) is "
4267 "A key-value pair. The key must be \"data\", the "
4268 "value is hex-encoded data"},
4279 "If inputs are specified, automatically include more if they "
4282 "Include inputs that are not safe to spend (unconfirmed "
4283 "transactions from outside keys).\n"
4284 "Warning: the resulting transaction may become invalid if "
4285 "one of the unsafe inputs disappears.\n"
4286 "If that happens, you will need to fund the transaction with "
4287 "different inputs and republish it."},
4289 "When false, returns a serialized transaction which will not "
4290 "be added to the wallet or broadcast"},
4293 "The bitcoin address to receive the change"},
4296 "The index of the change output"},
4299 "not set: makes wallet determine the fee"},
4304 "true for watch-only wallets, otherwise false"},
4305 "Also select inputs which are watch only.\n"
4306 "Only solvable inputs can be used. Watch-only destinations "
4307 "are solvable if the public key and/or output script was "
4309 "e.g. with 'importpubkey' or 'importmulti' with the "
4310 "'pubkeys' or 'desc' field."},
4315 "Specify inputs instead of adding them automatically. A "
4316 "JSON array of JSON objects",
4319 "The transaction id"},
4321 "The output number"},
4323 "The sequence number"},
4327 "Raw locktime. Non-0 value also locktime-activates inputs"},
4329 "Lock selected unspent outputs"},
4331 "Always return a PSBT, implies add_to_wallet=false."},
4333 "subtract_fee_from_outputs",
4336 "Outputs to subtract the fee from, specified as integer "
4338 "The fee will be equally deducted from the amount of each "
4339 "specified output.\n"
4340 "Those recipients will receive less bitcoins than you "
4341 "enter in their corresponding amount field.\n"
4342 "If no outputs are specified here, the sender pays the "
4347 "The zero-based output index, before a change output "
4359 "If the transaction has a complete set of signatures"},
4361 "The transaction id for the send. Only 1 transaction is created "
4362 "regardless of the number of addresses."},
4364 "If add_to_wallet is false, the hex-encoded raw transaction with "
4367 "If more signatures are needed, or if add_to_wallet is false, "
4368 "the base64-encoded (partially) signed transaction"}}},
4371 "\nSend with a fee rate of 10 XEC/kB\n" +
4373 "\": 100000}' '{\"fee_rate\": 10}'\n") +
4374 "\nCreate a transaction with a specific input, and return "
4375 "result without adding to wallet or broadcasting to the "
4379 "\": 100000}' '{\"add_to_wallet\": "
4380 "false, \"inputs\": "
4382 "\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b565"
4383 "5e72f463568df1aadf0\", \"vout\":1}]}'")},
4388 UniValueType(), UniValue::VOBJ},
4391 std::shared_ptr<CWallet>
const wallet =
4398 UniValue options = request.params[1];
4399 if (options.
exists(
"changeAddress")) {
4402 if (options.
exists(
"changePosition")) {
4404 "Use change_position");
4406 if (options.
exists(
"includeWatching")) {
4408 "Use include_watching");
4410 if (options.
exists(
"lockUnspents")) {
4413 if (options.
exists(
"subtractFeeFromOutputs")) {
4415 "Use subtract_fee_from_outputs");
4417 if (options.
exists(
"feeRate")) {
4421 const bool psbt_opt_in =
4425 int change_position;
4427 wallet->GetChainParams(), options[
"inputs"], request.params[0],
4428 options[
"locktime"]);
4436 bool add_to_wallet =
true;
4437 if (options.
exists(
"add_to_wallet")) {
4438 add_to_wallet = options[
"add_to_wallet"].
get_bool();
4445 bool complete =
true;
4447 psbtx, complete,
SigHashType().withForkId(),
true,
false);
4457 if (psbt_opt_in || !complete || !add_to_wallet) {
4465 std::string err_string;
4468 result.
pushKV(
"txid", tx->GetHash().GetHex());
4469 if (add_to_wallet && !psbt_opt_in) {
4472 result.
pushKV(
"hex", hex);
4475 result.
pushKV(
"complete", complete);
4484 "Set or generate a new HD wallet seed. Non-HD wallets will not be "
4485 "upgraded to being a HD wallet. Wallets that are already\n"
4486 "HD will have a new HD seed set so that new keys added to the keypool "
4487 "will be derived from this new seed.\n"
4488 "\nNote that you will need to MAKE A NEW BACKUP of your wallet after "
4489 "setting the HD wallet seed.\n" +
4493 "Whether to flush old unused addresses, including change "
4494 "addresses, from the keypool and regenerate it.\n"
4495 " If true, the next address from "
4496 "getnewaddress and change address from getrawchangeaddress will "
4497 "be from this new seed.\n"
4498 " If false, addresses (including "
4499 "change addresses if the wallet already had HD Chain Split "
4500 "enabled) from the existing\n"
4501 " keypool will be used until it has "
4504 "The WIF private key to use as the new HD seed.\n"
4505 " The seed value can be retrieved "
4506 "using the dumpwallet command. It is the private key marked "
4516 std::shared_ptr<CWallet>
const wallet =
4528 "Cannot set a HD seed to a wallet with "
4529 "private keys disabled");
4538 "Cannot set a HD seed on a non-HD wallet. Use the "
4539 "upgradewallet RPC in order to upgrade a non-HD wallet "
4545 bool flush_key_pool =
true;
4546 if (!request.params[0].isNull()) {
4547 flush_key_pool = request.params[0].get_bool();
4551 if (request.params[1].isNull()) {
4557 "Invalid private key");
4563 "Already have this key (either as an HD seed or "
4564 "as a loose private key)");
4571 if (flush_key_pool) {
4582 "walletprocesspsbt",
4583 "Update a PSBT with input information from our wallet and then sign "
4584 "inputs that we can sign for." +
4588 "The transaction base64 string"},
4590 "Also sign the transaction when updating"},
4592 "The signature hash type to sign with if not specified by "
4593 "the PSBT. Must be one of\n"
4595 " \"NONE|FORKID\"\n"
4596 " \"SINGLE|FORKID\"\n"
4597 " \"ALL|FORKID|ANYONECANPAY\"\n"
4598 " \"NONE|FORKID|ANYONECANPAY\"\n"
4599 " \"SINGLE|FORKID|ANYONECANPAY\""},
4601 "Includes the BIP 32 derivation paths for public keys if we know "
4609 "The base64-encoded partially signed transaction"},
4611 "If the transaction has a complete set of signatures"},
4616 std::shared_ptr<CWallet>
const wallet =
4624 {UniValue::VSTR, UniValue::VBOOL, UniValue::VSTR});
4638 "Signature must use SIGHASH_FORKID");
4642 bool sign = request.params[1].isNull()
4644 : request.params[1].get_bool();
4645 bool bip32derivs = request.params[3].isNull()
4647 : request.params[3].get_bool();
4648 bool complete =
true;
4650 psbtx, complete, nHashType, sign, bip32derivs);
4659 result.
pushKV(
"complete", complete);
4669 "walletcreatefundedpsbt",
4670 "Creates and funds a transaction in the Partially Signed Transaction "
4672 "Implements the Creator and Updater roles.\n",
4678 "Leave empty to add inputs automatically. See add_inputs "
4690 "The output number"},
4693 "depends on the value of the 'locktime' and "
4694 "'options.replaceable' arguments"},
4695 "The sequence number"},
4704 "The outputs (key-value pairs), where none of "
4705 "the keys are duplicated.\n"
4706 "That is, each address can only appear once and there can only "
4707 "be one 'data' object.\n"
4708 "For compatibility reasons, a dictionary, which holds the "
4709 "key-value pairs directly, is also\n"
4710 " accepted as second parameter.",
4720 "A key-value pair. The key (string) is the "
4721 "bitcoin address, the value (float or string) is "
4734 "A key-value pair. The key must be \"data\", the "
4735 "value is hex-encoded data"},
4741 "Raw locktime. Non-0 value also locktime-activates inputs\n"
4742 " Allows this transaction to be "
4743 "replaced by a transaction with higher fees. If provided, it is "
4744 "an error if explicit sequence numbers are incompatible."},
4751 "If inputs are specified, automatically include more if they "
4754 "Include inputs that are not safe to spend (unconfirmed "
4755 "transactions from outside keys).\n"
4756 "Warning: the resulting transaction may become invalid if "
4757 "one of the unsafe inputs disappears.\n"
4758 "If that happens, you will need to fund the transaction with "
4759 "different inputs and republish it."},
4762 "The bitcoin address to receive the change"},
4765 "The index of the change output"},
4768 "true for watch-only wallets, otherwise false"},
4769 "Also select inputs which are watch only"},
4771 "Lock selected unspent outputs"},
4774 "not set: makes wallet determine the fee"},
4775 "Set a specific fee rate in " + ticker +
"/kB"},
4777 "subtractFeeFromOutputs",
4780 "The outputs to subtract the fee from.\n"
4781 " The fee will be equally "
4782 "deducted from the amount of each specified output.\n"
4783 " Those recipients will "
4784 "receive less bitcoins than you enter in their "
4785 "corresponding amount field.\n"
4786 " If no outputs are "
4787 "specified here, the sender pays the fee.",
4791 "The zero-based output index, before a change output "
4798 "Includes the BIP 32 derivation paths for public keys if we know "
4806 "The resulting raw transaction (base64-encoded string)"},
4808 "Fee in " + ticker +
" the resulting transaction pays"},
4810 "The position of the added change output, or -1"},
4813 "\nCreate a transaction with no inputs\n" +
4815 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" "
4816 "\"[{\\\"data\\\":\\\"00010203\\\"}]\"")},
4819 std::shared_ptr<CWallet>
const wallet =
4829 UniValue::VNUM, UniValue::VOBJ},
4833 int change_position;
4835 wallet->GetChainParams(), request.params[0], request.params[1],
4842 request.params[3], coin_control);
4848 bool bip32derivs = request.params[4].isNull()
4850 : request.params[4].get_bool();
4851 bool complete =
true;
4854 false, bip32derivs);
4865 result.
pushKV(
"fee", fee);
4866 result.
pushKV(
"changepos", change_position);
4875 "Upgrade the wallet. Upgrades to the latest version if no "
4876 "version number is specified\n"
4877 "New keys may be generated and a new wallet backup will need to "
4880 "The version number to upgrade to. Default is the latest "
4887 std::shared_ptr<CWallet>
const wallet =
4899 if (!request.params[0].isNull()) {
4900 version = request.params[0].get_int();
4906 return error.original;
4915 "createwallettransaction",
4916 "Create a transaction sending an amount to a given address.\n" +
4920 "The bitcoin address to send to."},
4927 "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 100000") +
4929 "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\", 100000")},
4932 std::shared_ptr<CWallet>
const wallet =
4942 pwallet->BlockUntilSyncedToCurrentChain();
4949 const std::string address = request.params[0].get_str();
4950 address_amounts.
pushKV(address, request.params[1]);
4953 std::vector<CRecipient> recipients;
4955 wallet->GetChainParams());
4958 return SendMoney(pwallet, coin_control, recipients, {},
false);
4997 {
"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.
#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.
Double ended buffer combining vector and stream-like interfaces.
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.
const uint8_t * begin() const
bool IsValid() const
Check whether this private key is valid.
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 outpoint - a combination of a transaction hash and an index n into its 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)
Serialized script, used inside transaction inputs and outputs.
bool IsPayToScriptHash() const
A reference to a CScript: the Hash160 of its serialization (see script.h)
The basic transaction that is broadcasted on the network and contained in blocks.
An input of a transaction.
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
const std::string & GetName() const
Get a name for this wallet for logging/debugging purposes.
bool IsLegacy() const
Determine if we are a legacy wallet.
interfaces::Chain & chain() const
Interface for accessing chain state.
int GetLastBlockHeight() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Get last block processed height.
OutputType m_default_address_type
int64_t ScanningDuration() const
LegacyScriptPubKeyMan * GetLegacyScriptPubKeyMan() const
Get the LegacyScriptPubKeyMan which is used for all types, internal, and external.
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)
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.
const std::string & get_str() const
const UniValue & find_value(std::string_view key) const
int64_t get_int64() const
const UniValue & get_obj() const
void __pushKV(const std::string &key, const UniValue &val)
const std::vector< UniValue > & getValues() const
const std::vector< std::string > & getKeys() const
bool pushKVs(const UniValue &obj)
bool push_back(const UniValue &val)
const UniValue & get_array() const
bool exists(const std::string &key) const
bool pushKV(const std::string &key, const 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 int rpcSerializationFlags()=0
Current RPC serialization flags.
virtual bool findBlock(const BlockHash &hash, const FoundBlock &block={})=0
Return whether node has the block and optionally return block metadata or contents.
virtual void findCoins(std::map< COutPoint, Coin > &coins)=0
Look up unspent output information.
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 const CChainParams & params() const =0
This Chain's parameters.
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, int serialize_flags=0, const CTxUndo *txundo=nullptr)
bool DecodeHexTx(CMutableTransaction &tx, const std::string &strHexTx)
std::string EncodeHexTx(const CTransaction &tx, const int serializeFlags=0)
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)
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 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)
bool GetNewChangeDestination(const OutputType type, CTxDestination &dest, std::string &error)
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
bool GetNewDestination(const OutputType type, const std::string label, CTxDestination &dest, std::string &error)
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)
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.
std::set< std::set< CTxDestination > > GetAddressGroupings(const CWallet &wallet)
bool CachedTxIsFromMe(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
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)
std::map< CTxDestination, Amount > GetAddressBalances(const CWallet &wallet)
void CachedTxGetAmounts(const CWallet &wallet, const CWalletTx &wtx, std::list< COutputEntry > &listReceived, std::list< COutputEntry > &listSent, Amount &nFee, const isminefilter &filter)
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.
void RPCTypeCheck(const UniValue ¶ms, const std::list< UniValueType > &typesExpected, bool fAllowNull)
Type-check arguments; throws JSONRPCError if wrong type given.
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)
void RPCTypeCheckArgument(const UniValue &value, const UniValueType &typeExpected)
Type-check one argument; throws JSONRPCError if wrong type given.
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()
static RPCHelpMan listunspent()
static void ListTransactions(const CWallet *const pwallet, const CWalletTx &wtx, int nMinDepth, bool fLong, UniValue &ret, const isminefilter &filter_ismine, const std::string *filter_label) EXCLUSIVE_LOCKS_REQUIRED(pwallet -> cs_wallet)
List transactions based on the given criteria.
static RPCHelpMan getrawchangeaddress()
static RPCHelpMan walletprocesspsbt()
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 RPCHelpMan getwalletinfo()
static RPCHelpMan lockunspent()
Span< const CRPCCommand > GetWalletRPCCommands()
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 const std::vector< RPCResult > TransactionDescriptionString()
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.
bool CreateTransaction(CWallet &wallet, const std::vector< CRecipient > &vecSend, CTransactionRef &tx, Amount &nFeeRet, int &nChangePosInOut, bilingual_str &error, 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.
std::string GetTxnOutputType(TxoutType t)
Get the name of a TxoutType as a string.
TxoutType Solver(const CScript &scriptPubKey, std::vector< std::vector< uint8_t >> &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
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.
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(const std::string &str)
Returns true if each character in str is a hex character, and has an even number of hex digits.
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.
@ 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)
@ OMITTED_NAMED_ARG
Optional arg that is a named argument and has a default value of null.
@ OMITTED
Optional argument with default value omitted because they are implicitly clear.
@ ELISION
Special type to denote elision (...)
@ NUM_TIME
Special numeric to denote unix epoch time.
@ 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,...
interfaces::Chain * chain
std::vector< uint256 > txids
bool error(const char *fmt, const Args &...args)
#define EXCLUSIVE_LOCKS_REQUIRED(...)
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
const UniValue NullUniValue
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)
WalletContext & EnsureWalletContext(const std::any &context)
bool GetAvoidReuseFlag(const CWallet *const pwallet, const UniValue ¶m)
std::tuple< std::shared_ptr< CWallet >, std::vector< bilingual_str > > LoadWalletHelper(WalletContext &context, UniValue load_on_start_param, const std::string wallet_name)
bool ParseIncludeWatchonly(const UniValue &include_watchonly, const CWallet &pwallet)
Used by RPC commands that have an include_watchonly parameter.
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
bool RemoveWallet(const std::shared_ptr< CWallet > &wallet, std::optional< bool > load_on_start, std::vector< bilingual_str > &warnings)
const std::map< uint64_t, std::string > WALLET_FLAG_CAVEATS
std::shared_ptr< CWallet > GetWallet(const std::string &name)
std::shared_ptr< CWallet > CreateWallet(interfaces::Chain &chain, const std::string &name, std::optional< bool > load_on_start, const DatabaseOptions &options, DatabaseStatus &status, bilingual_str &error, std::vector< bilingual_str > &warnings)
void UnloadWallet(std::shared_ptr< CWallet > &&wallet)
Explicitly unload and delete the wallet.
std::vector< std::shared_ptr< CWallet > > GetWallets()
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,...