6#include <chainparams.h>
43#include <event2/http.h>
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 eCash 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 "DEPRECATED: The Bitcoin address type to use. Only available for "
112 "compatibility with Bitcoin and will be removed in the future. "
113 "The only valid value is \"legacy\". Note that this does not "
114 "change the output of this RPC; in order to get a Bitcoin address "
115 "the -usecashaddr option should be disabled."},
122 std::shared_ptr<CWallet>
const wallet =
132 "Error: This wallet has no available keys");
138 if (!request.params[0].isNull()) {
143 if (!request.params[1].isNull()) {
148 request.params[1].get_str()));
165 "getrawchangeaddress",
166 "Returns a new Bitcoin address, for receiving change.\n"
167 "This is for use with raw transactions, NOT normal use.\n",
174 std::shared_ptr<CWallet>
const wallet =
185 "Error: This wallet has no available keys");
190 if (!request.params[0].isNull()) {
195 request.params[0].get_str()));
212 "Sets the label associated with the given address.\n",
215 "The bitcoin address to be associated with a label."},
217 "The label to assign to the address."},
222 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"tabby\"") +
225 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"tabby\"")},
228 std::shared_ptr<CWallet>
const wallet =
238 wallet->GetChainParams());
241 "Invalid Bitcoin address");
246 if (pwallet->
IsMine(dest)) {
259 std::vector<CRecipient> &recipients,
267 std::string(
"Invalid Bitcoin address: ") +
274 std::string(
"Invalid parameter, duplicated address: ") +
285 if (addr.
get_str() == address) {
291 recipients.push_back(recipient);
317 return tx->GetId().GetHex();
326 "The bitcoin address to send to."},
330 "A comment used to store what the transaction is for.\n"
331 " This is not part of the "
332 "transaction, just kept in your wallet."},
335 "A comment to store the name of the person or organization\n"
336 " to which you're sending the "
337 "transaction. This is not part of the \n"
338 " transaction, just kept in "
342 "The fee will be deducted from the amount being sent.\n"
343 " The recipient will receive "
344 "less bitcoins than you enter in the amount field."},
346 "(only available if avoid_reuse wallet flag is set) Avoid "
347 "spending from dirty addresses; addresses are considered\n"
348 " dirty if they have previously "
349 "been used in a transaction."},
354 "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 100000") +
355 HelpExampleCli(
"sendtoaddress",
"\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvay"
356 "dd\" 100000 \"donation\" \"seans "
359 "Jvaydd\" 100000 \"\" \"\" true") +
361 "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvay"
362 "dd\", 100000, \"donation\", \"seans "
366 std::shared_ptr<CWallet>
const wallet =
376 pwallet->BlockUntilSyncedToCurrentChain();
382 if (!request.params[2].isNull() &&
383 !request.params[2].get_str().empty()) {
384 mapValue[
"comment"] = request.params[2].get_str();
386 if (!request.params[3].isNull() &&
387 !request.params[3].get_str().empty()) {
388 mapValue[
"to"] = request.params[3].get_str();
391 bool fSubtractFeeFromAmount =
false;
392 if (!request.params[4].isNull()) {
393 fSubtractFeeFromAmount = request.params[4].get_bool();
406 const std::string address = request.params[0].get_str();
409 if (fSubtractFeeFromAmount) {
413 std::vector<CRecipient> recipients;
415 wallet->GetChainParams());
424 "listaddressgroupings",
425 "Lists groups of addresses which have had their common ownership\n"
426 "made public by common use as inputs or as the resulting change\n"
427 "in past transactions\n",
442 "The bitcoin address"},
454 std::shared_ptr<CWallet>
const wallet =
464 pwallet->BlockUntilSyncedToCurrentChain();
469 std::map<CTxDestination, Amount>
balances =
471 for (
const std::set<CTxDestination> &
grouping :
509 "Invalid Bitcoin address");
520 if (!params[1].isNull()) {
526 for (
const std::pair<const TxId, CWalletTx> &
wtx_pair :
wallet.mapWallet) {
532 for (
const CTxOut &txout : wtx.
tx->vout) {
536 amount += txout.nValue;
546 "getreceivedbyaddress",
547 "Returns the total amount received by the given address in "
548 "transactions with at least minconf confirmations.\n",
551 "The bitcoin address for transactions."},
553 "Only include transactions confirmed at least this many times."},
557 " received at this address."},
559 "\nThe amount from transactions with at least 1 confirmation\n" +
561 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\"") +
562 "\nThe amount including unconfirmed transactions, zero "
565 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" 0") +
566 "\nThe amount with at least 6 confirmations\n" +
568 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" 6") +
569 "\nAs a JSON-RPC call\n" +
571 "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", 6")},
574 std::shared_ptr<CWallet>
const wallet =
584 pwallet->BlockUntilSyncedToCurrentChain();
596 "getreceivedbylabel",
597 "Returns the total amount received by addresses with <label> in "
598 "transactions with at least [minconf] confirmations.\n",
601 "The selected label, may be the default label using \"\"."},
603 "Only include transactions confirmed at least this many times."},
607 " received for this label."},
608 RPCExamples{
"\nAmount received by the default label with at least 1 "
611 "\nAmount received at the tabby label including "
612 "unconfirmed amounts with zero confirmations\n" +
614 "\nThe amount with at least 6 confirmations\n" +
616 "\nAs a JSON-RPC call\n" +
620 std::shared_ptr<CWallet>
const wallet =
630 pwallet->BlockUntilSyncedToCurrentChain();
643 "Returns the total available balance.\n"
644 "The available balance is what the wallet considers currently "
645 "spendable, and is\n"
646 "thus affected by options which limit spendability such as "
647 "-spendzeroconfchange.\n",
650 "Remains for backward compatibility. Must be excluded or set to "
653 "Only include transactions confirmed at least this many times."},
656 "true for watch-only wallets, otherwise false"},
657 "Also include balance in watch-only addresses (see "
660 "(only available if avoid_reuse wallet flag is set) Do not "
661 "include balance in dirty outputs; addresses are considered dirty "
662 "if they have previously been used in a transaction."},
666 " received for this wallet."},
668 "\nThe total amount in the wallet with 0 or more confirmations\n" +
670 "\nThe total amount in the wallet with at least 6 confirmations\n" +
671 HelpExampleCli(
"getbalance",
"\"*\" 6") +
"\nAs a JSON-RPC call\n" +
675 std::shared_ptr<CWallet>
const wallet =
685 pwallet->BlockUntilSyncedToCurrentChain();
693 "dummy first argument must be excluded or set to \"*\".");
697 if (!request.params[1].isNull()) {
698 min_depth = request.params[1].getInt<
int>();
709 ?
bal.m_watchonly_trusted
717 "getunconfirmedbalance",
718 "DEPRECATED\nIdentical to getbalances().mine.untrusted_pending\n",
724 std::shared_ptr<CWallet>
const wallet =
734 pwallet->BlockUntilSyncedToCurrentChain();
746 "Send multiple times. Amounts are double-precision "
747 "floating point numbers." +
751 "Must be set to \"\" for backwards compatibility.",
753 .oneline_description =
"\"\""}},
758 "The addresses and amounts",
761 "The bitcoin address is the key, the numeric amount (can "
767 "Only use the balance confirmed at least this many times."},
775 " The fee will be equally deducted "
776 "from the amount of each selected address.\n"
777 " Those recipients will receive less "
778 "bitcoins than you enter in their corresponding amount field.\n"
779 " If no addresses are specified "
780 "here, the sender pays the fee.",
783 "Subtract fee from this address"},
788 "The transaction id for the send. Only 1 transaction is "
789 "created regardless of the number of addresses."},
791 "\nSend two amounts to two different addresses:\n" +
795 "\"{\\\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\\\":"
797 "\\\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\\\":0."
799 "\nSend two amounts to two different addresses setting the "
800 "confirmation and comment:\n" +
804 "\"{\\\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\\\":"
806 "\\\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\\\":0."
809 "\nSend two amounts to two different addresses, subtract fee "
814 "\"{\\\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\\\":"
816 "\\\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\\\":0."
818 "\"[\\\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\\\","
819 "\\\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\\\"]"
821 "\nAs a JSON-RPC call\n" +
825 "{\"bchtest:qplljx455cznj2yrtdhj0jcm7syxlzqnaqt0ku5kjl\":0.01,"
826 "\"bchtest:qzmnuh8t24yrxq4mvjakt84r7j3f9tunlvm2p7qef9\":0.02}, "
831 std::shared_ptr<CWallet>
const wallet =
841 pwallet->BlockUntilSyncedToCurrentChain();
845 if (!request.params[0].isNull() &&
846 !request.params[0].get_str().empty()) {
848 "Dummy value must be set to \"\"");
853 if (!request.params[3].isNull() &&
854 !request.params[3].get_str().empty()) {
855 mapValue[
"comment"] = request.params[3].
get_str();
859 if (!request.params[4].isNull()) {
863 std::vector<CRecipient> recipients;
865 wallet->GetChainParams());
869 std::move(mapValue));
876 "addmultisigaddress",
877 "Add an nrequired-to-sign multisignature address to the wallet. "
878 "Requires a new wallet backup.\n"
879 "Each key is a Bitcoin address or hex-encoded public key.\n"
880 "This functionality is only intended for use with non-watchonly "
882 "See `importaddress` for watchonly p2sh address support.\n"
883 "If 'label' is specified (DEPRECATED), assign address to that label.\n"
884 "Note: This command is only compatible with legacy wallets.\n",
887 "The number of required signatures out of the n keys or "
893 "The bitcoin addresses or hex-encoded public keys",
896 "bitcoin address or hex-encoded public key"},
900 "A label to assign the addresses to."},
907 "The value of the new multisig address"},
909 "The string value of the hex-encoded redemption script"},
911 "The descriptor for this multisig"},
914 "\nAdd a multisig address from 2 addresses\n" +
917 "\"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\","
918 "\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") +
919 "\nAs a JSON-RPC call\n" +
922 "\"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\","
923 "\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"")},
926 std::shared_ptr<CWallet>
const wallet =
939 if (!request.params[2].isNull()) {
943 int required = request.params[0].getInt<
int>();
947 std::vector<CPubKey> pubkeys;
969 std::unique_ptr<Descriptor> descriptor =
975 result.
pushKV(
"descriptor", descriptor->ToString());
983 int nConf{std::numeric_limits<int>::max()};
994 if (!params[0].isNull()) {
1000 if (!params[1].isNull()) {
1011 if (!
by_label && params.size() > 3) {
1013 pwallet->GetChainParams())) {
1015 "address_filter parameter was invalid");
1023 std::map<CTxDestination, tallyitem>
mapTally;
1024 for (
const std::pair<const TxId, CWalletTx> &
pairWtx : pwallet->mapWallet) {
1031 int nDepth = pwallet->GetTxDepthInMainChain(wtx);
1036 for (
const CTxOut &txout : wtx.
tx->vout) {
1047 if (!(
mine & filter)) {
1067 auto start = pwallet->m_address_book.begin();
1068 auto end = pwallet->m_address_book.end();
1073 end = std::next(start);
1078 if (
item_it->second.IsChange()) {
1082 const std::string &label =
item_it->second.GetLabel();
1083 std::map<CTxDestination, tallyitem>::iterator it =
1090 int nConf = std::numeric_limits<int>::max();
1091 bool fIsWatchonly =
false;
1093 nAmount = (*it).second.nAmount;
1094 nConf = (*it).second.nConf;
1095 fIsWatchonly = (*it).second.fIsWatchonly;
1102 _item.fIsWatchonly = fIsWatchonly;
1106 obj.pushKV(
"involvesWatchonly",
true);
1109 obj.pushKV(
"amount", nAmount);
1110 obj.pushKV(
"confirmations",
1111 (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
1112 obj.pushKV(
"label", label);
1126 Amount nAmount = entry.second.nAmount;
1127 int nConf = entry.second.nConf;
1129 if (entry.second.fIsWatchonly) {
1130 obj.pushKV(
"involvesWatchonly",
true);
1132 obj.pushKV(
"amount", nAmount);
1133 obj.pushKV(
"confirmations",
1134 (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
1135 obj.pushKV(
"label", entry.first);
1145 "listreceivedbyaddress",
1146 "List balances by receiving address.\n",
1149 "The minimum number of confirmations before payments are "
1152 "Whether to include addresses that haven't received any "
1156 "true for watch-only wallets, otherwise false"},
1157 "Whether to include watch-only addresses (see 'importaddress')."},
1160 "If present, only return information on this address."},
1172 "Only returns true if imported addresses were involved "
1177 " received by the address"},
1179 "The number of confirmations of the most recent "
1180 "transaction included"},
1182 "The label of the receiving address. The default label "
1189 "The ids of transactions received with the address"},
1198 "listreceivedbyaddress",
1199 "6, true, true, \"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\"")},
1202 std::shared_ptr<CWallet>
const wallet =
1212 pwallet->BlockUntilSyncedToCurrentChain();
1216 return ListReceived(config, pwallet, request.params,
false);
1223 "listreceivedbylabel",
1224 "List received transactions by label.\n",
1227 "The minimum number of confirmations before payments are "
1230 "Whether to include labels that haven't received any payments."},
1233 "true for watch-only wallets, otherwise false"},
1234 "Whether to include watch-only addresses (see 'importaddress')."},
1246 "Only returns true if imported addresses were involved "
1249 "The total amount received by addresses with this label"},
1251 "The number of confirmations of the most recent "
1252 "transaction included"},
1254 "The label of the receiving address. The default label "
1263 std::shared_ptr<CWallet>
const wallet =
1273 pwallet->BlockUntilSyncedToCurrentChain();
1277 return ListReceived(config, pwallet, request.params,
true);
1321 entry.
pushKV(
"involvesWatchonly",
true);
1324 entry.
pushKV(
"category",
"send");
1325 entry.
pushKV(
"amount", -s.amount);
1327 pwallet->FindAddressBookEntry(s.destination);
1331 entry.
pushKV(
"vout", s.vout);
1332 entry.
pushKV(
"fee", -1 * nFee);
1336 entry.
pushKV(
"abandoned", wtx.isAbandoned());
1337 ret.push_back(entry);
1343 pwallet->GetTxDepthInMainChain(wtx) >=
nMinDepth) {
1347 pwallet->FindAddressBookEntry(r.destination);
1357 entry.
pushKV(
"involvesWatchonly",
true);
1360 if (wtx.IsCoinBase()) {
1361 if (pwallet->GetTxDepthInMainChain(wtx) < 1) {
1362 entry.
pushKV(
"category",
"orphan");
1363 }
else if (pwallet->IsTxImmatureCoinBase(wtx)) {
1364 entry.
pushKV(
"category",
"immature");
1366 entry.
pushKV(
"category",
"generate");
1369 entry.
pushKV(
"category",
"receive");
1371 entry.
pushKV(
"amount", r.amount);
1373 entry.
pushKV(
"label", label);
1375 entry.
pushKV(
"vout", r.vout);
1379 ret.push_back(entry);
1387 "The number of confirmations for the transaction. Negative "
1388 "confirmations means the\n"
1389 "transaction conflicted that many blocks ago."},
1391 "Only present if transaction only input is a coinbase one."},
1393 "Only present if we consider transaction to be trusted and so safe to "
1396 "The block hash containing the transaction."},
1398 "The block height containing the transaction."},
1400 "The index of the transaction in the block that includes it."},
1406 "Conflicting transaction ids.",
1415 "If a comment is associated with the transaction, only present if not "
1424 "If a label name is provided, this will return only incoming "
1425 "transactions paying to addresses with the specified label.\n"
1426 "\nReturns up to 'count' most recent transactions skipping the first "
1427 "'from' transactions.\n",
1431 "If set, should be a valid label name to return only incoming "
1432 "transactions with the specified label, or \"*\" to disable "
1433 "filtering and return all transactions."},
1435 "The number of transactions to return"},
1437 "The number of transactions to skip"},
1440 "true for watch-only wallets, otherwise false"},
1441 "Include transactions to watch-only addresses (see "
1442 "'importaddress')"},
1450 Cat(
Cat<std::vector<RPCResult>>(
1453 "Only returns true if imported addresses were "
1454 "involved in transaction."},
1456 "The bitcoin address of the transaction."},
1458 "The transaction category.\n"
1459 "\"send\" Transactions sent.\n"
1460 "\"receive\" Non-coinbase "
1461 "transactions received.\n"
1462 "\"generate\" Coinbase transactions "
1463 "received with more than 100 confirmations.\n"
1464 "\"immature\" Coinbase transactions "
1465 "received with 100 or fewer confirmations.\n"
1466 "\"orphan\" Orphaned coinbase "
1467 "transactions received."},
1469 "The amount in " + ticker +
1470 ". This is negative for the 'send' category, "
1472 "for all other categories"},
1474 "A comment for the address/transaction, if any"},
1477 "The amount of the fee in " + ticker +
1478 ". This is negative and only available for "
1480 "'send' category of transactions."},
1485 "'true' if the transaction has been abandoned "
1486 "(inputs are respendable). Only available for the \n"
1487 "'send' category of transactions."},
1490 RPCExamples{
"\nList the most recent 10 transactions in the systems\n" +
1492 "\nList transactions 100 to 120\n" +
1494 "\nAs a JSON-RPC call\n" +
1498 std::shared_ptr<CWallet>
const wallet =
1508 pwallet->BlockUntilSyncedToCurrentChain();
1511 if (!request.params[0].isNull() &&
1512 request.params[0].get_str() !=
"*") {
1517 "Label argument must be a valid label name or \"*\".");
1521 if (!request.params[1].isNull()) {
1522 nCount = request.params[1].getInt<
int>();
1526 if (!request.params[2].isNull()) {
1527 nFrom = request.params[2].getInt<
int>();
1542 std::vector<UniValue>
ret;
1549 for (CWallet::TxItems::const_reverse_iterator it =
1583 "Get all transactions in blocks since block [blockhash], or all "
1584 "transactions if omitted.\n"
1585 "If \"blockhash\" is no longer a part of the main chain, transactions "
1586 "from the fork point onward are included.\n"
1587 "Additionally, if include_removed is set, transactions affecting the "
1588 "wallet which were removed are returned in the \"removed\" array.\n",
1592 "If set, the block hash to list transactions since, otherwise "
1593 "list all transactions."},
1595 "Return the nth block hash from the main chain. e.g. 1 would mean "
1596 "the best block hash. Note: this is not used as a filter, but "
1597 "only affects [lastblock] in the return value"},
1600 "true for watch-only wallets, otherwise false"},
1601 "Include transactions to watch-only addresses (see "
1602 "'importaddress')"},
1604 "Show transactions that were removed due to a reorg in the "
1605 "\"removed\" array\n"
1607 "guaranteed to work on pruned nodes)"},
1619 Cat(
Cat<std::vector<RPCResult>>(
1622 "Only returns true if imported addresses "
1623 "were involved in transaction."},
1625 "The bitcoin address of the transaction."},
1627 "The transaction category.\n"
1628 "\"send\" Transactions "
1630 "\"receive\" Non-coinbase "
1631 "transactions received.\n"
1632 "\"generate\" Coinbase "
1633 "transactions received with more than 100 "
1635 "\"immature\" Coinbase "
1636 "transactions received with 100 or fewer "
1638 "\"orphan\" Orphaned "
1639 "coinbase transactions received."},
1641 "The amount in " + ticker +
1642 ". This is negative for the 'send' "
1643 "category, and is positive\n"
1644 "for all other categories"},
1648 "The amount of the fee in " + ticker +
1649 ". This is negative and only available "
1651 "'send' category of transactions."},
1656 "'true' if the transaction has been abandoned "
1657 "(inputs are respendable). Only available for "
1659 "'send' category of transactions."},
1661 "If a comment is associated with the "
1664 "A comment for the address/transaction, if any"},
1666 "If a comment to is associated with the "
1672 "<structure is the same as \"transactions\" above, only "
1673 "present if include_removed=true>\n"
1674 "Note: transactions that were re-added in the active chain "
1675 "will appear as-is in this array, and may thus have a "
1676 "positive confirmation count.",
1681 "The hash of the block (target_confirmations-1) from the best "
1682 "block on the main chain, or the genesis hash if the "
1683 "referenced block does not exist yet. This is typically used "
1684 "to feed back into listsinceblock the next time you call it. "
1685 "So you would generally use a target_confirmations of say 6, "
1686 "so you will be continually re-notified of transactions until "
1687 "they've reached 6 confirmations plus any new ones"},
1691 "\"000000000000000bacf66f7497b7dc45ef753ee9a"
1692 "7d38571037cdb1a57f663ad\" 6") +
1694 "\"000000000000000bacf66f7497b7dc45ef753ee9a"
1695 "7d38571037cdb1a57f663ad\", 6")},
1698 std::shared_ptr<CWallet>
const pwallet =
1709 wallet.BlockUntilSyncedToCurrentChain();
1715 std::optional<int> height;
1724 if (!request.params[0].isNull() &&
1725 !request.params[0].get_str().empty()) {
1729 if (!
wallet.chain().findCommonAncestor(
1738 if (!request.params[1].isNull()) {
1743 "Invalid parameter");
1752 (request.params[3].isNull() || request.params[3].get_bool());
1754 int depth = height ?
wallet.GetLastBlockHeight() + 1 - *height : -1;
1758 for (
const std::pair<const TxId, CWalletTx> &
pairWtx :
1762 if (depth == -1 ||
wallet.GetTxDepthInMainChain(tx) < depth) {
1777 "Can't read block from disk");
1780 auto it =
wallet.mapWallet.find(tx->GetId());
1781 if (it !=
wallet.mapWallet.end()) {
1798 wallet.GetLastBlockHash(),
1818 "Get detailed information about in-wallet transaction <txid>\n",
1821 "The transaction id"},
1824 "true for watch-only wallets, otherwise false"},
1825 "Whether to include watch-only addresses in balance calculation "
1828 "Whether to include a `decoded` field containing the decoded "
1829 "transaction (equivalent to RPC decoderawtransaction)"},
1833 Cat(
Cat<std::vector<RPCResult>>(
1836 "The amount in " + ticker},
1838 "The amount of the fee in " + ticker +
1839 ". This is negative and only available for the\n"
1840 "'send' category of transactions."},
1853 "Only returns true if imported addresses were "
1854 "involved in transaction."},
1856 "The bitcoin address involved in the "
1859 "The transaction category.\n"
1860 "\"send\" Transactions sent.\n"
1861 "\"receive\" Non-coinbase "
1862 "transactions received.\n"
1863 "\"generate\" Coinbase "
1864 "transactions received with more than 100 "
1866 "\"immature\" Coinbase "
1867 "transactions received with 100 or fewer "
1869 "\"orphan\" Orphaned coinbase "
1870 "transactions received."},
1872 "The amount in " + ticker},
1874 "A comment for the address/transaction, if any"},
1877 "The amount of the fee in " + ticker +
1878 ". This is negative and only available for "
1880 "'send' category of transactions."},
1882 "'true' if the transaction has been abandoned "
1883 "(inputs are respendable). Only available for "
1885 "'send' category of transactions."},
1889 "Raw data for transaction"},
1892 "Optional, the decoded transaction (only present when "
1893 "`verbose` is passed)",
1896 "Equivalent to the RPC decoderawtransaction method, "
1897 "or the RPC getrawtransaction method when `verbose` "
1902 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1903 "5cf302fc80e9d5fbf5d48d\"") +
1905 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1906 "5cf302fc80e9d5fbf5d48d\" true") +
1908 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1909 "5cf302fc80e9d5fbf5d48d\" false true") +
1911 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
1912 "5cf302fc80e9d5fbf5d48d\"")},
1915 std::shared_ptr<CWallet>
const wallet =
1925 pwallet->BlockUntilSyncedToCurrentChain();
1936 bool verbose = request.params[2].isNull()
1938 : request.params[2].get_bool();
1941 auto it = pwallet->mapWallet.find(txid);
1942 if (it == pwallet->mapWallet.end()) {
1944 "Invalid or non-wallet transaction id");
1957 entry.
pushKV(
"fee", nFee);
1965 entry.
pushKV(
"details", details);
1984 "abandontransaction",
1985 "Mark in-wallet transaction <txid> as abandoned\n"
1986 "This will mark this transaction and all its in-wallet descendants as "
1987 "abandoned which will allow\n"
1988 "for their inputs to be respent. It can be used to replace \"stuck\" "
1989 "or evicted transactions.\n"
1990 "It only works on transactions which are not included in a block and "
1991 "are not currently in the mempool.\n"
1992 "It has no effect on transactions which are already abandoned.\n",
1995 "The transaction id"},
1999 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
2000 "5cf302fc80e9d5fbf5d48d\"") +
2002 "\"1075db55d416d3ca199f55b6084e2115b9345e16c"
2003 "5cf302fc80e9d5fbf5d48d\"")},
2006 std::shared_ptr<CWallet>
const wallet =
2016 pwallet->BlockUntilSyncedToCurrentChain();
2022 if (!pwallet->mapWallet.count(txid)) {
2024 "Invalid or non-wallet transaction id");
2029 "Transaction not eligible for abandonment");
2043 "The new keypool size"},
2050 std::shared_ptr<CWallet>
const wallet =
2061 "Error: Private keys are disabled for this wallet");
2069 if (!request.params[0].isNull()) {
2070 if (request.params[0].getInt<
int>() < 0) {
2073 "Invalid parameter, expected valid size.");
2075 kpSize = (
unsigned int)request.params[0].getInt<
int>();
2083 "Error refreshing keypool.");
2094 "Updates list of temporarily unspendable outputs.\n"
2095 "Temporarily lock (unlock=false) or unlock (unlock=true) specified "
2096 "transaction outputs.\n"
2097 "If no transaction outputs are specified when unlocking then all "
2098 "current locked transaction outputs are unlocked.\n"
2099 "A locked transaction output will not be chosen by automatic coin "
2100 "selection, when spending bitcoins.\n"
2101 "Manually selected coins are automatically unlocked.\n"
2102 "Locks are stored in memory only. Nodes start with zero locked "
2103 "outputs, and the locked output list\n"
2104 "is always cleared (by virtue of process exit) when a node stops or "
2106 "Also see the listunspent call\n",
2109 "Whether to unlock (true) or lock (false) the specified "
2115 "The transaction outputs and within each, txid (string) vout "
2127 "The output number"},
2134 "Whether the command was successful or not"},
2136 "\nList the unspent transactions\n" +
2138 "\nLock an unspent transaction\n" +
2141 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2142 "b764ed838b5655e72f463568df1aadf0\\\""
2143 ",\\\"vout\\\":1}]\"") +
2144 "\nList the locked transactions\n" +
2146 "\nUnlock the transaction again\n" +
2149 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2150 "b764ed838b5655e72f463568df1aadf0\\\""
2151 ",\\\"vout\\\":1}]\"") +
2152 "\nAs a JSON-RPC call\n" +
2155 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2156 "b764ed838b5655e72f463568df1aadf0\\\""
2157 ",\\\"vout\\\":1}]\"")},
2160 std::shared_ptr<CWallet>
const wallet =
2170 pwallet->BlockUntilSyncedToCurrentChain();
2174 bool fUnlock = request.params[0].get_bool();
2176 if (request.params[1].isNull()) {
2187 std::vector<COutPoint> outputs;
2202 "Invalid parameter, vout cannot be negative");
2206 const auto it = pwallet->mapWallet.find(txid);
2207 if (it == pwallet->mapWallet.end()) {
2210 "Invalid parameter, unknown transaction");
2215 if (output.
GetN() >=
trans.tx->vout.size()) {
2218 "Invalid parameter, vout index out of bounds");
2221 if (pwallet->
IsSpent(output)) {
2224 "Invalid parameter, expected unspent output");
2231 "Invalid parameter, expected locked output");
2237 "Invalid parameter, output already locked");
2240 outputs.push_back(output);
2244 for (
const COutPoint &output : outputs) {
2260 "Returns list of temporarily unspendable outputs.\n"
2261 "See the lockunspent call to lock and unlock transactions for "
2273 "The transaction id locked"},
2278 "\nList the unspent transactions\n" +
2280 "\nLock an unspent transaction\n" +
2283 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2284 "b764ed838b5655e72f463568df1aadf0\\\""
2285 ",\\\"vout\\\":1}]\"") +
2286 "\nList the locked transactions\n" +
2288 "\nUnlock the transaction again\n" +
2291 "\\\"a08e6907dbbd3d809776dbfc5d82e371"
2292 "b764ed838b5655e72f463568df1aadf0\\\""
2293 ",\\\"vout\\\":1}]\"") +
2294 "\nAs a JSON-RPC call\n" +
HelpExampleRpc(
"listlockunspent",
"")},
2297 std::shared_ptr<CWallet>
const wallet =
2306 std::vector<COutPoint>
vOutpts;
2314 o.pushKV(
"txid", output.GetTxId().GetHex());
2315 o.pushKV(
"vout",
int(output.GetN()));
2327 "Set the transaction fee per kB for this wallet. Overrides the "
2328 "global -paytxfee command line parameter.\n"
2329 "Can be deactivated by passing 0 as the fee. In that case automatic "
2330 "fee selection will be used by default.\n",
2340 std::shared_ptr<CWallet>
const wallet =
2357 strprintf(
"txfee cannot be less than min relay tx fee (%s)",
2362 strprintf(
"txfee cannot be less than wallet min fee (%s)",
2368 "txfee cannot be more than wallet max tx fee (%s)",
2390 "balances from outputs that the wallet can sign",
2393 "trusted balance (outputs created by the wallet or "
2394 "confirmed outputs)"},
2396 "untrusted pending balance (outputs created by "
2397 "others that are in the mempool)"},
2399 "balance from immature coinbase outputs"},
2401 "(only present if avoid_reuse is set) balance from "
2402 "coins sent to addresses that were previously "
2403 "spent from (potentially privacy violating)"},
2407 "watchonly balances (not present if wallet does not "
2411 "trusted balance (outputs created by the wallet or "
2412 "confirmed outputs)"},
2414 "untrusted pending balance (outputs created by "
2415 "others that are in the mempool)"},
2417 "balance from immature coinbase outputs"},
2434 wallet.BlockUntilSyncedToCurrentChain();
2444 bal.m_mine_untrusted_pending);
2453 full_bal.m_mine_untrusted_pending -
2454 bal.m_mine_trusted -
2455 bal.m_mine_untrusted_pending);
2464 bal.m_watchonly_untrusted_pending);
2476 "Returns an object containing various wallet state info.\n",
2486 "DEPRECATED. Identical to getbalances().mine.trusted"},
2488 "DEPRECATED. Identical to "
2489 "getbalances().mine.untrusted_pending"},
2491 "DEPRECATED. Identical to getbalances().mine.immature"},
2493 "the total number of transactions in the wallet"},
2496 " of the oldest pre-generated key in the key pool. "
2497 "Legacy wallets only."},
2499 "how many new keys are pre-generated (only counts external "
2502 "how many new keys are pre-generated for internal use (used "
2503 "for change outputs, only appears if the wallet is using "
2504 "this feature, otherwise external keys are used)"},
2508 " until which the wallet is unlocked for transfers, or 0 "
2509 "if the wallet is locked (only present for "
2510 "passphrase-encrypted wallets)"},
2512 "the transaction fee configuration, set in " +
2515 "the Hash160 of the HD seed (only present when HD is "
2518 "false if privatekeys are disabled for this wallet (enforced "
2519 "watch-only wallet)"},
2522 "current scanning details, or false if no scan is in "
2526 "elapsed seconds since scan start"},
2528 "scanning progress percentage [0.0, 1.0]"},
2532 "whether this wallet tracks clean/dirty coins in terms of "
2535 "whether this wallet uses descriptors for scriptPubKey "
2543 std::shared_ptr<CWallet>
const wallet =
2553 pwallet->BlockUntilSyncedToCurrentChain();
2562 obj.pushKV(
"walletname", pwallet->
GetName());
2564 obj.pushKV(
"balance",
bal.m_mine_trusted);
2565 obj.pushKV(
"unconfirmed_balance",
bal.m_mine_untrusted_pending);
2566 obj.pushKV(
"immature_balance",
bal.m_mine_immature);
2567 obj.pushKV(
"txcount", (
int)pwallet->mapWallet.size());
2578 obj.pushKV(
"hdseedid", seed_id.
GetHex());
2583 obj.pushKV(
"keypoolsize_hd_internal",
2587 obj.pushKV(
"unlocked_until", pwallet->nRelockTime);
2591 "private_keys_enabled",
2599 obj.pushKV(
"scanning",
false);
2601 obj.pushKV(
"avoid_reuse",
2603 obj.pushKV(
"descriptors",
2613 "Returns a list of wallets in the wallet directory.\n",
2639 wallet.pushKV(
"name", path.u8string());
2653 "Returns a list of currently loaded wallets.\n"
2654 "For full information on the wallet, use \"getwalletinfo\"\n",
2681 "Loads a wallet from a wallet file or directory."
2682 "\nNote that all wallet command-line options used when starting "
2684 "\napplied to the new wallet (eg -rescan, etc).\n",
2687 "The wallet directory or .dat file."},
2690 "Save wallet name to persistent settings and load on startup. "
2691 "True to add wallet to startup list, false to remove, null to "
2692 "leave unchanged."},
2699 "The wallet name if loaded successfully."},
2701 "Warning message if wallet was not loaded cleanly."},
2708 const std::string
name(request.params[0].get_str());
2723 std::string
flags =
"";
2726 flags += (
flags ==
"" ?
"" :
", ") + it.first;
2731 "Change the state of the given wallet flag for a wallet.\n",
2734 "The name of the flag to change. Current available flags: " +
2744 "The name of the flag that was modified"},
2746 "The new state of the flag"},
2748 "Any warnings associated with the change"},
2754 std::shared_ptr<CWallet>
const wallet =
2761 std::string
flag_str = request.params[0].get_str();
2763 request.params[1].isNull() || request.params[1].get_bool();
2784 strprintf(
"Wallet flag is already set to %s: %s",
2785 value ?
"true" :
"false",
flag_str));
2789 res.pushKV(
"flag_state", value);
2809 "Creates and loads a new wallet.\n",
2812 "The name for the new wallet. If this is a path, the wallet will "
2813 "be created at the path location."},
2815 "Disable the possibility of private keys (only watchonlys are "
2816 "possible in this mode)."},
2818 "Create a blank wallet. A blank wallet has no keys or HD seed. "
2819 "One can be set using sethdseed."},
2821 "Encrypt the wallet with this passphrase."},
2823 "Keep track of coin reuse, and treat dirty and clean coins "
2824 "differently with privacy considerations in mind."},
2826 "Create a native descriptor wallet. The wallet will use "
2827 "descriptors internally to handle address creation"},
2830 "Save wallet name to persistent settings and load on startup. "
2831 "True to add wallet to startup list, false to remove, null to "
2832 "leave unchanged."},
2839 "The wallet name if created successfully. If the wallet "
2840 "was created using a full path, the wallet_name will be "
2843 "Warning message if wallet was not loaded cleanly."},
2849 {
"avoid_reuse",
true},
2850 {
"descriptors",
true},
2851 {
"load_on_startup",
true}}) +
2853 {
"avoid_reuse",
true},
2854 {
"descriptors",
true},
2855 {
"load_on_startup",
true}})},
2860 if (!request.params[1].isNull() && request.params[1].get_bool()) {
2864 if (!request.params[2].isNull() && request.params[2].get_bool()) {
2870 std::vector<bilingual_str>
warnings;
2871 if (!request.params[3].isNull()) {
2872 passphrase = request.params[3].get_str().c_str();
2876 "Empty string given as passphrase, wallet will "
2877 "not be encrypted."));
2881 if (!request.params[4].isNull() && request.params[4].get_bool()) {
2884 if (!request.params[5].isNull() && request.params[5].get_bool()) {
2887 "Wallet is an experimental descriptor wallet"));
2897 request.params[6].isNull()
2899 : std::make_optional<bool>(request.params[6].get_bool());
2900 std::shared_ptr<CWallet>
wallet =
2922 "Unloads the wallet referenced by the request endpoint otherwise "
2923 "unloads the wallet specified in the argument.\n"
2924 "Specifying the wallet name on a wallet endpoint is invalid.",
2928 "The name of the wallet to unload."},
2931 "Save wallet name to persistent settings and load on startup. "
2932 "True to add wallet to startup list, false to remove, null to "
2933 "leave unchanged."},
2940 "Warning message if wallet was not unloaded cleanly."},
2948 if (!request.params[0].isNull()) {
2950 "Cannot unload the requested wallet");
2960 "Requested wallet does not exist or is not loaded");
2966 std::vector<bilingual_str>
warnings;
2968 request.params[1].isNull()
2970 : std::make_optional<bool>(request.params[1].get_bool());
2973 "Requested wallet already unloaded");
2990 "Returns array of unspent transaction outputs\n"
2991 "with between minconf and maxconf (inclusive) confirmations.\n"
2992 "Optionally filter to only include txouts paid to specified "
2996 "The minimum confirmations to filter"},
2998 "The maximum confirmations to filter"},
3003 "The bitcoin addresses to filter",
3010 "Include outputs that are not safe to spend\n"
3011 " See description of \"safe\" attribute below."},
3015 "JSON with query options",
3019 "Minimum value of each UTXO in " + ticker +
""},
3022 "Maximum value of each UTXO in " + ticker +
""},
3027 "Minimum sum value of all UTXOs in " + ticker +
""},
3044 "The associated label, or \"\" for the default label"},
3047 "the transaction output amount in " + ticker},
3049 "The number of confirmations"},
3052 "DEPRECATED: The number of in-mempool ancestor "
3053 "transactions, including this one (if transaction is in "
3054 "the mempool). Only displayed if the "
3055 "-deprecatedrpc=mempool_ancestors_descendants option is "
3058 "DEPRECATED: The virtual transaction size of in-mempool "
3059 " ancestors, including this one (if transaction is in "
3060 "the mempool). Only displayed if the "
3061 "-deprecatedrpc=mempool_ancestors_descendants option is "
3065 "DEPRECATED: The total fees of in-mempool ancestors "
3066 "(including this one) with fee deltas used for mining "
3069 " (if transaction is in the mempool). Only "
3071 "-deprecatedrpc=mempool_ancestors_descendants option "
3075 "The redeemScript if scriptPubKey is P2SH"},
3077 "Whether we have the private keys to spend this output"},
3079 "Whether we know how to spend this output, ignoring the "
3082 "(only present if avoid_reuse is set) Whether this "
3083 "output is reused/dirty (sent to an address that was "
3084 "previously spent from)"},
3086 "(only when solvable) A descriptor for spending this "
3089 "Whether this output is considered safe to spend. "
3090 "Unconfirmed transactions\n"
3091 "from outside keys are considered unsafe\n"
3092 "and are not eligible for spending by fundrawtransaction "
3093 "and sendtoaddress."},
3100 "\"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\","
3101 "\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"") +
3104 "\"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\","
3105 "\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"") +
3108 "6 9999999 '[]' true '{ \"minimumAmount\": 0.005 }'") +
3111 "6, 9999999, [] , true, { \"minimumAmount\": 0.005 } ")},
3114 std::shared_ptr<CWallet>
const wallet =
3122 if (!request.params[0].isNull()) {
3123 nMinDepth = request.params[0].getInt<
int>();
3127 if (!request.params[1].isNull()) {
3128 nMaxDepth = request.params[1].getInt<
int>();
3132 if (!request.params[2].isNull()) {
3134 for (
size_t idx = 0; idx < inputs.
size(); idx++) {
3135 const UniValue &input = inputs[idx];
3141 std::string(
"Invalid Bitcoin address: ") +
3148 "Invalid parameter, duplicated address: ") +
3155 if (!request.params[3].isNull()) {
3164 if (!request.params[4].isNull()) {
3177 if (options.
exists(
"minimumAmount")) {
3181 if (options.
exists(
"maximumAmount")) {
3185 if (options.
exists(
"minimumSumAmount")) {
3190 if (options.
exists(
"maximumCount")) {
3198 pwallet->BlockUntilSyncedToCurrentChain();
3222 out.tx->tx->vout[out.i].scriptPubKey;
3233 entry.
pushKV(
"txid", out.tx->GetId().GetHex());
3234 entry.
pushKV(
"vout", out.i);
3245 std::unique_ptr<SigningProvider> provider =
3250 CScriptID(std::get<ScriptHash>(address));
3253 entry.
pushKV(
"redeemScript",
3261 entry.
pushKV(
"amount", out.tx->tx->vout[out.i].nValue);
3262 entry.
pushKV(
"confirmations", out.nDepth);
3263 entry.
pushKV(
"spendable", out.fSpendable);
3264 entry.
pushKV(
"solvable", out.fSolvable);
3265 if (out.fSolvable) {
3266 std::unique_ptr<SigningProvider> provider =
3271 entry.
pushKV(
"desc", descriptor->ToString());
3277 entry.
pushKV(
"safe", out.fSafe);
3291 pwallet->BlockUntilSyncedToCurrentChain();
3328 if (options.
exists(
"add_inputs")) {
3332 if (options.
exists(
"changeAddress") ||
3333 options.
exists(
"change_address")) {
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")) {
3354 ? options[
"change_position"]
3355 : options[
"changePosition"])
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")) {
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");
3409 "changePosition out of bounds");
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));
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",
3506 "subtractFeeFromOutputs",
3510 " The fee will be equally "
3511 "deducted from the amount of each specified output.\n"
3512 " Those recipients will "
3513 "receive less bitcoins than you enter in their "
3514 "corresponding amount field.\n"
3515 " If no outputs are "
3516 "specified here, the sender pays the fee.",
3520 "The zero-based output index, before a change output "
3526 .oneline_description =
"options"}},
3533 "The resulting raw transaction (hex-encoded string)"},
3535 "Fee in " + ticker +
" the resulting transaction pays"},
3537 "The position of the added change output, or -1"},
3540 "\nCreate a transaction with no inputs\n" +
3542 "\"[]\" \"{\\\"myaddress\\\":10000}\"") +
3543 "\nAdd sufficient unsigned inputs to meet the output value\n" +
3545 "\nSign the transaction\n" +
3547 "\"fundedtransactionhex\"") +
3548 "\nSend the transaction\n" +
3549 HelpExampleCli(
"sendrawtransaction",
"\"signedtransactionhex\"")},
3552 std::shared_ptr<CWallet>
const wallet =
3561 if (!
DecodeHexTx(tx, request.params[0].get_str())) {
3563 "TX decode failed");
3577 result.
pushKV(
"fee", fee);
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 =
3679 "TX decode failed");
3687 std::map<COutPoint, Coin> coins;
3690 coins[
txin.prevout];
3700 "Signature must use SIGHASH_FORKID");
3719 "Rescan the local blockchain for wallet related transactions.\n"
3720 "Note: Use \"getwalletinfo\" to query the scanning progress.\n",
3723 "block height where the rescan should start"},
3726 "the last block height that should be scanned"},
3734 "The block height where the rescan started (the requested "
3737 "The height of the last rescanned block. May be null in rare "
3738 "cases if there was a reorg and the call didn't scan any "
3739 "blocks because they were already scanned in the background."},
3745 std::shared_ptr<CWallet>
const wallet =
3755 "Wallet is currently rescanning. Abort "
3756 "existing rescan or wait.");
3766 if (!request.params[0].isNull()) {
3770 "Invalid start_height");
3774 if (!request.params[1].isNull()) {
3778 "Invalid stop_height");
3782 "stop_height must be greater than start_height");
3792 "Can't rescan beyond pruned data. Use RPC call "
3793 "getblockchaininfo to determine your pruned height.");
3810 "Rescan failed. Potentially corrupted data files.");
3849 if (
subobj.exists(
"pubkey")) {
3852 obj.pushKV(
"embedded", std::move(
subobj));
3864 obj.pushKV(
"pubkeys", std::move(pubkeys));
3880 obj.pushKV(
"pubkey",
HexStr(vchPubKey));
3902 std::unique_ptr<SigningProvider> provider =
nullptr;
3906 ret.pushKVs(detail);
3925 "Return information about the given bitcoin address.\n"
3926 "Some of the information will only be present if the address is in the "
3930 "The bitcoin address for which to get information."},
3938 "The bitcoin address validated."},
3940 "The hex-encoded scriptPubKey generated by the address."},
3943 "If the address is watchonly."},
3945 "If we know how to spend coins sent to this address, ignoring "
3946 "the possible lack of private keys."},
3948 "A descriptor for spending coins sent to this address (only "
3952 "If the address was used for change output."},
3954 "The output script type. Only if isscript is true and the "
3955 "redeemscript is known. Possible\n"
3957 "types: nonstandard, pubkey, pubkeyhash, scripthash, "
3958 "multisig, nulldata."},
3960 "The redeemscript for the p2sh address."},
3964 "Array of pubkeys associated with the known redeemscript "
3965 "(only if script is multisig).",
3970 "The number of signatures required to spend multisig output "
3971 "(only if script is multisig)."},
3973 "The hex value of the raw public key for single-key addresses "
3974 "(possibly embedded in P2SH)."},
3978 "Information about the address embedded in P2SH, if "
3979 "relevant and known.",
3982 "Includes all getaddressinfo output fields for the "
3983 "embedded address excluding metadata (timestamp, "
3984 "hdkeypath, hdseedid)\n"
3985 "and relation to the wallet (ismine, iswatchonly)."},
3988 "If the pubkey is compressed."},
3990 "The creation time of the key, if available, expressed in " +
3993 "The HD keypath, if the key is HD and available."},
3995 "The Hash160 of the HD seed."},
3997 true,
"The fingerprint of the master key."},
4000 "Array of labels associated with the address. Currently "
4001 "limited to one label but returned\n"
4002 "as an array to keep the API stable if multiple labels are "
4003 "enabled in the future.",
4006 "Label name (defaults to \"\")."},
4013 std::shared_ptr<CWallet>
const wallet =
4024 wallet->GetChainParams());
4035 ret.pushKV(
"scriptPubKey",
HexStr(scriptPubKey));
4037 std::unique_ptr<SigningProvider> provider =
4055 ret.pushKVs(detail);
4062 if (
const std::unique_ptr<CKeyMetadata>
meta =
4064 ret.pushKV(
"timestamp",
meta->nCreateTime);
4065 if (
meta->has_key_origin) {
4066 ret.pushKV(
"hdkeypath",
4068 ret.pushKV(
"hdseedid",
meta->hd_seed_id.GetHex());
4069 ret.pushKV(
"hdmasterfingerprint",
4086 ret.pushKV(
"labels", std::move(
labels));
4095 "getaddressesbylabel",
4096 "Returns the list of addresses assigned the specified label.\n",
4102 "json object with addresses as keys",
4106 "Information about address",
4109 "Purpose of address (\"send\" for sending address, "
4110 "\"receive\" for receiving address)"},
4117 std::shared_ptr<CWallet>
const wallet =
4131 for (
const std::pair<const CTxDestination, CAddressBookData> &item :
4132 pwallet->m_address_book) {
4133 if (item.second.IsChange()) {
4136 if (item.second.GetLabel() == label) {
4146 ret.pushKVEnd(address,
4154 std::string(
"No addresses with label " + label));
4165 "Returns the list of all labels, or labels that are assigned to "
4166 "addresses with a specific purpose.\n",
4169 "Address purpose to list labels for ('send','receive'). An empty "
4170 "string is the same as not providing this argument."},
4179 "\nList labels that have receiving addresses\n" +
4181 "\nList labels that have sending addresses\n" +
4183 "\nAs a JSON-RPC call\n" +
4187 std::shared_ptr<CWallet>
const wallet =
4196 std::string purpose;
4197 if (!request.params[0].isNull()) {
4198 purpose = request.params[0].get_str();
4204 for (
const std::pair<const CTxDestination, CAddressBookData>
4205 &entry : pwallet->m_address_book) {
4206 if (entry.second.IsChange()) {
4209 if (purpose.empty() || entry.second.purpose == purpose) {
4210 label_set.insert(entry.second.GetLabel());
4227 "EXPERIMENTAL warning: this call may be changed in future releases.\n"
4228 "\nSend a transaction.\n",
4233 "A JSON array with outputs (key-value pairs), where none of "
4234 "the keys are duplicated.\n"
4235 "That is, each address can only appear once and there can only "
4236 "be one 'data' object.\n"
4237 "For convenience, a dictionary, which holds the key-value "
4238 "pairs directly, is also accepted.",
4247 "A key-value pair. The key (string) is the "
4248 "bitcoin address, the value (float or string) is "
4260 "A key-value pair. The key must be \"data\", the "
4261 "value is hex-encoded data"},
4272 "If inputs are specified, automatically include more if they "
4275 "Include inputs that are not safe to spend (unconfirmed "
4276 "transactions from outside keys).\n"
4277 "Warning: the resulting transaction may become invalid if "
4278 "one of the unsafe inputs disappears.\n"
4279 "If that happens, you will need to fund the transaction with "
4280 "different inputs and republish it."},
4282 "When false, returns a serialized transaction which will not "
4283 "be added to the wallet or broadcast"},
4286 "The bitcoin address to receive the change"},
4289 "The index of the change output"},
4292 "not set: makes wallet determine the fee"},
4298 "true for watch-only wallets, otherwise false"},
4299 "Also select inputs which are watch only.\n"
4300 "Only solvable inputs can be used. Watch-only destinations "
4301 "are solvable if the public key and/or output script was "
4303 "e.g. with 'importpubkey' or 'importmulti' with the "
4304 "'pubkeys' or 'desc' field."},
4309 "Specify inputs instead of adding them automatically. A "
4310 "JSON array of JSON objects",
4313 "The transaction id"},
4315 "The output number"},
4317 "The sequence number"},
4321 "Raw locktime. Non-0 value also locktime-activates inputs"},
4323 "Lock selected unspent outputs"},
4325 "Always return a PSBT, implies add_to_wallet=false."},
4327 "subtract_fee_from_outputs",
4330 "Outputs to subtract the fee from, specified as integer "
4332 "The fee will be equally deducted from the amount of each "
4333 "specified output.\n"
4334 "Those recipients will receive less bitcoins than you "
4335 "enter in their corresponding amount field.\n"
4336 "If no outputs are specified here, the sender pays the "
4341 "The zero-based output index, before a change output "
4353 "If the transaction has a complete set of signatures"},
4355 "The transaction id for the send. Only 1 transaction is created "
4356 "regardless of the number of addresses."},
4358 "If add_to_wallet is false, the hex-encoded raw transaction with "
4361 "If more signatures are needed, or if add_to_wallet is false, "
4362 "the base64-encoded (partially) signed transaction"}}},
4365 "\nSend with a fee rate of 10 XEC/kB\n" +
4367 "\": 100000}' '{\"fee_rate\": 10}'\n") +
4368 "\nCreate a transaction with a specific input, and return "
4369 "result without adding to wallet or broadcasting to the "
4373 "\": 100000}' '{\"add_to_wallet\": "
4374 "false, \"inputs\": "
4376 "\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b565"
4377 "5e72f463568df1aadf0\", \"vout\":1}]}'")},
4380 std::shared_ptr<CWallet>
const wallet =
4387 UniValue options = request.params[1];
4388 if (options.
exists(
"changeAddress")) {
4391 if (options.
exists(
"changePosition")) {
4393 "Use change_position");
4395 if (options.
exists(
"includeWatching")) {
4397 "Use include_watching");
4399 if (options.
exists(
"lockUnspents")) {
4402 if (options.
exists(
"subtractFeeFromOutputs")) {
4404 "Use subtract_fee_from_outputs");
4406 if (options.
exists(
"feeRate")) {
4416 wallet->GetChainParams(), options[
"inputs"], request.params[0],
4417 options[
"locktime"]);
4426 if (options.
exists(
"add_to_wallet")) {
4434 bool complete =
true;
4457 result.
pushKV(
"txid", tx->GetHash().GetHex());
4461 result.
pushKV(
"hex", hex);
4464 result.
pushKV(
"complete", complete);
4473 "Set or generate a new HD wallet seed. Non-HD wallets will not be "
4474 "upgraded to being a HD wallet. Wallets that are already\n"
4475 "HD will have a new HD seed set so that new keys added to the keypool "
4476 "will be derived from this new seed.\n"
4477 "\nNote that you will need to MAKE A NEW BACKUP of your wallet after "
4478 "setting the HD wallet seed.\n" +
4480 "Note: This command is only compatible with legacy wallets.\n",
4483 "Whether to flush old unused addresses, including change "
4484 "addresses, from the keypool and regenerate it.\n"
4485 " If true, the next address from "
4486 "getnewaddress and change address from getrawchangeaddress will "
4487 "be from this new seed.\n"
4488 " If false, addresses (including "
4489 "change addresses if the wallet already had HD Chain Split "
4490 "enabled) from the existing\n"
4491 " keypool will be used until it has "
4494 "The WIF private key to use as the new HD seed.\n"
4495 " The seed value can be retrieved "
4496 "using the dumpwallet command. It is the private key marked "
4506 std::shared_ptr<CWallet>
const wallet =
4518 "Cannot set a HD seed to a wallet with "
4519 "private keys disabled");
4528 "Cannot set a HD seed on a non-HD wallet. Use the "
4529 "upgradewallet RPC in order to upgrade a non-HD wallet "
4536 if (!request.params[0].isNull()) {
4541 if (request.params[1].isNull()) {
4547 "Invalid private key");
4553 "Already have this key (either as an HD seed or "
4554 "as a loose private key)");
4572 "walletprocesspsbt",
4573 "Update a PSBT with input information from our wallet and then sign "
4574 "inputs that we can sign for." +
4578 "The transaction base64 string"},
4580 "Also sign the transaction when updating"},
4582 "The signature hash type to sign with if not specified by "
4583 "the PSBT. Must be one of\n"
4585 " \"NONE|FORKID\"\n"
4586 " \"SINGLE|FORKID\"\n"
4587 " \"ALL|FORKID|ANYONECANPAY\"\n"
4588 " \"NONE|FORKID|ANYONECANPAY\"\n"
4589 " \"SINGLE|FORKID|ANYONECANPAY\""},
4591 "Includes the BIP 32 derivation paths for public keys if we know "
4599 "The base64-encoded partially signed transaction"},
4601 "If the transaction has a complete set of signatures"},
4606 std::shared_ptr<CWallet>
const wallet =
4625 "Signature must use SIGHASH_FORKID");
4629 bool sign = request.params[1].isNull()
4631 : request.params[1].get_bool();
4634 : request.params[3].get_bool();
4635 bool complete =
true;
4646 result.
pushKV(
"complete", complete);
4656 "walletcreatefundedpsbt",
4657 "Creates and funds a transaction in the Partially Signed Transaction "
4659 "Implements the Creator and Updater roles.\n",
4665 "Leave empty to add inputs automatically. See add_inputs "
4677 "The output number"},
4680 "depends on the value of the 'locktime' and "
4681 "'options.replaceable' arguments"},
4682 "The sequence number"},
4690 "The outputs (key-value pairs), where none of "
4691 "the keys are duplicated.\n"
4692 "That is, each address can only appear once and there can only "
4693 "be one 'data' object.\n"
4694 "For compatibility reasons, a dictionary, which holds the "
4695 "key-value pairs directly, is also\n"
4696 " accepted as second parameter.",
4705 "A key-value pair. The key (string) is the "
4706 "bitcoin address, the value (float or string) is "
4718 "A key-value pair. The key must be \"data\", the "
4719 "value is hex-encoded data"},
4725 "Raw locktime. Non-0 value also locktime-activates inputs\n"
4726 " Allows this transaction to be "
4727 "replaced by a transaction with higher fees. If provided, it is "
4728 "an error if explicit sequence numbers are incompatible."},
4735 "If inputs are specified, automatically include more if they "
4738 "Include inputs that are not safe to spend (unconfirmed "
4739 "transactions from outside keys).\n"
4740 "Warning: the resulting transaction may become invalid if "
4741 "one of the unsafe inputs disappears.\n"
4742 "If that happens, you will need to fund the transaction with "
4743 "different inputs and republish it."},
4746 "The bitcoin address to receive the change"},
4749 "The index of the change output"},
4752 "true for watch-only wallets, otherwise false"},
4753 "Also select inputs which are watch only"},
4755 "Lock selected unspent outputs"},
4758 "not set: makes wallet determine the fee"},
4759 "Set a specific fee rate in " + ticker +
"/kB",
4762 "subtractFeeFromOutputs",
4765 "The outputs to subtract the fee from.\n"
4766 " The fee will be equally "
4767 "deducted from the amount of each specified output.\n"
4768 " Those recipients will "
4769 "receive less bitcoins than you enter in their "
4770 "corresponding amount field.\n"
4771 " If no outputs are "
4772 "specified here, the sender pays the fee.",
4776 "The zero-based output index, before a change output "
4783 "Includes the BIP 32 derivation paths for public keys if we know "
4791 "The resulting raw transaction (base64-encoded string)"},
4793 "Fee in " + ticker +
" the resulting transaction pays"},
4795 "The position of the added change output, or -1"},
4798 "\nCreate a transaction with no inputs\n" +
4800 "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" "
4801 "\"[{\\\"data\\\":\\\"00010203\\\"}]\"")},
4804 std::shared_ptr<CWallet>
const wallet =
4814 wallet->GetChainParams(), request.params[0], request.params[1],
4829 : request.params[4].get_bool();
4830 bool complete =
true;
4844 result.
pushKV(
"fee", fee);
4854 "Upgrade the wallet. Upgrades to the latest version if no "
4855 "version number is specified\n"
4856 "New keys may be generated and a new wallet backup will need to "
4859 "The version number to upgrade to. Default is the latest "
4866 std::shared_ptr<CWallet>
const wallet =
4876 if (!request.params[0].isNull()) {
4877 version = request.params[0].getInt<
int>();
4883 return error.original;
4892 "createwallettransaction",
4893 "Create a transaction sending an amount to a given address.\n" +
4897 "The bitcoin address to send to."},
4904 "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 100000") +
4906 "\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\", 100000")},
4909 std::shared_ptr<CWallet>
const wallet =
4919 pwallet->BlockUntilSyncedToCurrentChain();
4926 const std::string address = request.params[0].get_str();
4930 std::vector<CRecipient> recipients;
4932 wallet->GetChainParams());
4974 {
"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.
bool m_add_inputs
If false, only selected inputs are used.
bool m_avoid_address_reuse
Forbids inclusion of dirty (previously used) addresses.
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.
An encapsulated secp256k1 private key.
bool IsValid() const
Check whether this private key is valid.
const uint8_t * begin() const
bool IsCompressed() const
Check whether the public key corresponding to this private key is (to be) compressed.
CPubKey GetPubKey() const
Compute the public key from a private key.
void Set(const T pbegin, const T pend, bool fCompressedIn)
Initialize using begin and end iterators to byte data.
const uint8_t * end() const
A reference to a CKey: the Hash160 of its serialized public key.
A mutable version of CTransaction.
std::vector< CTxOut > vout
An 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
interfaces::Chain & chain() const
Interface for accessing chain state.
bool IsLegacy() const
Determine if we are a legacy wallet.
int GetLastBlockHeight() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Get last block processed height.
OutputType m_default_address_type
int64_t ScanningDuration() const
LegacyScriptPubKeyMan * GetLegacyScriptPubKeyMan() const
Get the LegacyScriptPubKeyMan which is used for all types, internal, and external.
const std::string & GetName() const
Get a name for this wallet for logging/debugging purposes.
bool CanSupportFeature(enum WalletFeature wf) const override EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
check whether we are allowed to upgrade (or already support) to the named feature
int GetVersion() const
get the current wallet format (the oldest client version guaranteed to understand this wallet)
Amount m_default_max_tx_fee
Absolute maximum transaction fee (in satoshis) used by default for the wallet.
bool UpgradeWallet(int version, bilingual_str &error)
Upgrade the wallet.
ScriptPubKeyMan * GetScriptPubKeyMan(const OutputType &type, bool internal) const
Get the ScriptPubKeyMan for the given OutputType and internal/external chain.
std::multimap< int64_t, CWalletTx * > TxItems
std::optional< OutputType > m_default_change_type
Default output type for change outputs.
const CAddressBookData * FindAddressBookEntry(const CTxDestination &, bool allow_change=false) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
A transaction with a bunch of additional info that only the owner cares about.
const SigningProvider *const provider
UniValue operator()(const PKHash &pkhash) const
UniValue operator()(const ScriptHash &scripthash) const
void ProcessSubScript(const CScript &subscript, UniValue &obj) const
DescribeWalletAddressVisitor(const SigningProvider *_provider)
UniValue operator()(const CNoDestination &dest) const
A class implementing ScriptPubKeyMan manages some (or all) scriptPubKeys used in a wallet.
Signature hash type wrapper class.
An interface to be implemented by keystores that support signing.
virtual bool GetCScript(const CScriptID &scriptid, CScript &script) const
virtual bool GetPubKey(const CKeyID &address, CPubKey &pubkey) const
A Span is an object that can refer to a contiguous sequence of objects.
void push_back(UniValue val)
const std::string & get_str() const
const UniValue & find_value(std::string_view key) const
const UniValue & get_obj() const
const UniValue & get_array() const
bool exists(const std::string &key) const
void pushKV(std::string key, UniValue val)
void push_backV(const std::vector< UniValue > &vec)
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 const CChainParams & params() const =0
This Chain's parameters.
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).
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 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)
void CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::vector< std::pair< std::string, std::string > > orderForm, bool broadcast=true)
Add the transaction to the wallet and maybe attempt to broadcast it.
void BlockUntilSyncedToCurrentChain() const LOCKS_EXCLUDED(void SetWalletFlag(uint64_t flags)
Blocks until the wallet state is up-to-date to /at least/ the current chain at the time this function...
isminetype IsMine(const CTxDestination &dest) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool CanGetAddresses(bool internal=false) const
Returns true if the wallet can give out new addresses.
ScanResult ScanForWalletTransactions(const BlockHash &start_block, int start_height, std::optional< int > max_height, const WalletRescanReserver &reserver, bool fUpdate)
Scan the block chain (starting in start_block) for transactions from or to us.
bool IsSpentKey(const TxId &txid, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
const CChainParams & GetChainParams() const override
bool IsSpent(const COutPoint &outpoint) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Outpoint is spent if any non-conflicted transaction, spends it:
void UnsetWalletFlag(uint64_t flag)
Unsets a single wallet flag.
bool IsWalletFlagSet(uint64_t flag) const override
Check if a certain wallet flag is set.
bool AbandonTransaction(const TxId &txid)
Mark a transaction (and it in-wallet descendants) as abandoned so its inputs may be respent.
isminetype
IsMine() return codes.
std::string EncodeDestination(const CTxDestination &dest, const Config &config)
bool IsValidDestinationString(const std::string &str, const CChainParams ¶ms)
CTxDestination DecodeDestination(const std::string &addr, const CChainParams ¶ms)
CKey DecodeSecret(const std::string &str)
bool error(const char *fmt, const Args &...args)
std::string FormatMoney(const Amount amt)
Do not use these functions to represent or parse monetary amounts to or from JSON but use AmountFromV...
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.
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
void SignTransactionResultToJSON(CMutableTransaction &mtx, bool complete, const std::map< COutPoint, Coin > &coins, const std::map< int, std::string > &input_errors, UniValue &result)
CMutableTransaction ConstructTransaction(const CChainParams ¶ms, const UniValue &inputs_in, const UniValue &outputs_in, const UniValue &locktime)
Create a transaction from univalue parameters.
void ParsePrevouts(const UniValue &prevTxsUnival, FillableSigningProvider *keystore, std::map< COutPoint, Coin > &coins)
Parse a prevtxs UniValue array and get the map of coins from it.
bool CachedTxIsFromMe(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
std::set< std::set< CTxDestination > > GetAddressGroupings(const CWallet &wallet)
Amount CachedTxGetDebit(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
filter decides which addresses will count towards the debit
bool ScriptIsChange(const CWallet &wallet, const CScript &script)
void CachedTxGetAmounts(const CWallet &wallet, const CWalletTx &wtx, std::list< COutputEntry > &listReceived, std::list< COutputEntry > &listSent, Amount &nFee, const isminefilter &filter)
std::map< CTxDestination, Amount > GetAddressBalances(const CWallet &wallet)
Amount CachedTxGetCredit(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
bool CachedTxIsTrusted(const CWallet &wallet, const CWalletTx &wtx, std::set< TxId > &trusted_parents)
Balance GetBalance(const CWallet &wallet, const int min_depth, bool avoid_reuse)
UniValue JSONRPCError(int code, const std::string &message)
RPCErrorCode
Bitcoin RPC error codes.
@ RPC_WALLET_INVALID_LABEL_NAME
Invalid label name.
@ RPC_MISC_ERROR
General application defined errors std::exception thrown in command handling.
@ RPC_WALLET_INSUFFICIENT_FUNDS
Not enough funds in wallet or account.
@ RPC_WALLET_ENCRYPTION_FAILED
Failed to encrypt the wallet.
@ RPC_METHOD_DEPRECATED
RPC method is deprecated.
@ RPC_INVALID_PARAMETER
Invalid, missing or duplicate parameter.
@ RPC_WALLET_ERROR
Wallet errors Unspecified problem with wallet (key not found etc.)
@ RPC_WALLET_NOT_FOUND
Invalid wallet specified.
@ RPC_WALLET_KEYPOOL_RAN_OUT
Keypool ran out, call keypoolrefill first.
@ RPC_DESERIALIZATION_ERROR
Error parsing or validating structure in raw format.
@ RPC_INVALID_ADDRESS_OR_KEY
Invalid address or key.
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
CTxDestination AddAndGetMultisigDestination(const int required, const std::vector< CPubKey > &pubkeys, OutputType type, FillableSigningProvider &keystore, CScript &script_out)
std::string HelpExampleRpcNamed(const std::string &methodname, const RPCArgList &args)
UniValue JSONRPCTransactionError(TransactionError terr, const std::string &err_string)
Amount AmountFromValue(const UniValue &value)
const std::string EXAMPLE_ADDRESS
Example CashAddr address used in multiple RPCExamples.
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
const std::string UNIX_EPOCH_TIME
String used to describe UNIX epoch time in documentation, factored out to a constant for consistency.
CPubKey HexToPubKey(const std::string &hex_in)
CPubKey AddrToPubKey(const CChainParams &chainparams, const FillableSigningProvider &keystore, const std::string &addr_in)
uint256 ParseHashO(const UniValue &o, std::string strKey)
uint256 ParseHashV(const UniValue &v, std::string strName)
Utilities: convert hex-encoded values (throws error if not hex).
void RPCTypeCheckObj(const UniValue &o, const std::map< std::string, UniValueType > &typesExpected, bool fAllowNull, bool fStrict)
Check for expected keys/value types in an Object.
std::string HelpExampleCliNamed(const std::string &methodname, const RPCArgList &args)
UniValue DescribeAddress(const CTxDestination &dest)
static RPCHelpMan createwallet()
static RPCHelpMan getnewaddress()
static RPCHelpMan sethdseed()
static RPCHelpMan listreceivedbylabel()
static RPCHelpMan sendtoaddress()
Span< const CRPCCommand > GetWalletRPCCommands()
static RPCHelpMan listunspent()
static RPCHelpMan getrawchangeaddress()
static const std::vector< RPCResult > TransactionDescriptionString()
static RPCHelpMan walletprocesspsbt()
static void ListTransactions(const CWallet *const pwallet, const CWalletTx &wtx, int nMinDepth, bool fLong, Vec &ret, const isminefilter &filter_ismine, const std::string *filter_label) EXCLUSIVE_LOCKS_REQUIRED(pwallet -> cs_wallet)
List transactions based on the given criteria.
static RPCHelpMan fundrawtransaction()
static RPCHelpMan gettransaction()
static UniValue ListReceived(const Config &config, const CWallet *const pwallet, const UniValue ¶ms, bool by_label) EXCLUSIVE_LOCKS_REQUIRED(pwallet -> cs_wallet)
static UniValue AddressBookDataToJSON(const CAddressBookData &data, const bool verbose)
Convert CAddressBookData to JSON record.
static RPCHelpMan listaddressgroupings()
static void WalletTxToJSON(const CWallet &wallet, const CWalletTx &wtx, UniValue &entry) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
static RPCHelpMan addmultisigaddress()
RPCHelpMan getaddressesbylabel()
static RPCHelpMan listlockunspent()
static Amount GetReceived(const CWallet &wallet, const UniValue ¶ms, bool by_label) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
static RPCHelpMan getunconfirmedbalance()
static RPCHelpMan listwallets()
RPCHelpMan rescanblockchain()
static RPCHelpMan upgradewallet()
static RPCHelpMan unloadwallet()
static RPCHelpMan walletcreatefundedpsbt()
static RPCHelpMan getbalances()
static RPCHelpMan listwalletdir()
static RPCHelpMan keypoolrefill()
bool HaveKey(const SigningProvider &wallet, const CKey &key)
Checks if a CKey is in the given CWallet compressed or otherwise.
RPCHelpMan getaddressinfo()
static RPCHelpMan getwalletinfo()
static RPCHelpMan lockunspent()
UniValue SendMoney(CWallet *const pwallet, const CCoinControl &coin_control, std::vector< CRecipient > &recipients, mapValue_t map_value, bool broadcast=true)
static RPCHelpMan setwalletflag()
RPCHelpMan signrawtransactionwithwallet()
static RPCHelpMan createwallettransaction()
static RPCHelpMan setlabel()
static RPCHelpMan getreceivedbyaddress()
static RPCHelpMan getreceivedbylabel()
static void MaybePushAddress(UniValue &entry, const CTxDestination &dest)
static RPCHelpMan getbalance()
static RPCHelpMan loadwallet()
static RPCHelpMan listsinceblock()
static RPCHelpMan settxfee()
static RPCHelpMan listreceivedbyaddress()
static RPCHelpMan sendmany()
RPCHelpMan listtransactions()
static UniValue DescribeWalletAddress(const CWallet *const pwallet, const CTxDestination &dest)
void ParseRecipients(const UniValue &address_amounts, const UniValue &subtract_fee_outputs, std::vector< CRecipient > &recipients, const CChainParams &chainParams)
void FundTransaction(CWallet *const pwallet, CMutableTransaction &tx, Amount &fee_out, int &change_position, const UniValue &options, CCoinControl &coinControl)
static RPCHelpMan abandontransaction()
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
static std::string ToString(const CService &ip)
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.
TxoutType Solver(const CScript &scriptPubKey, std::vector< std::vector< uint8_t > > &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
std::string GetTxnOutputType(TxoutType t)
Get the name of a TxoutType as a string.
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
CKeyID ToKeyID(const PKHash &key_hash)
std::variant< CNoDestination, PKHash, ScriptHash > CTxDestination
A txout script template with a specific destination.
auto Join(const std::vector< T > &list, const BaseType &separator, UnaryOp unary_op) -> decltype(unary_op(list.at(0)))
Join a list of items.
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)
@ OBJ_NAMED_PARAMS
Special type that behaves almost exactly like OBJ, defining an options object with a list of pre-defi...
std::string DefaultHint
Hint for default value.
@ OMITTED
The arg is optional for one of two reasons:
std::string oneline_description
Should be empty unless it is supposed to override the auto-generated summary line.
bool also_positional
If set allows a named-parameter field in an OBJ_NAMED_PARAM options object to have the same name as a...
@ ELISION
Special type to denote elision (...)
@ NUM_TIME
Special numeric to denote unix epoch time.
@ ARR_FIXED
Special array that has a fixed number of entries.
@ OBJ_DYN
Special dictionary with keys that are not literals.
@ STR_HEX
Special string with only hex chars.
@ STR_AMOUNT
Special string to represent a floating point amount.
A TxId is the identifier of a transaction.
Wrapper for UniValue::VType, which includes typeAny: used to denote don't care type.
WalletContext struct containing references to state shared between CWallet instances,...
interfaces::Chain * chain
std::vector< uint256 > txids
#define EXCLUSIVE_LOCKS_REQUIRED(...)
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
const UniValue NullUniValue
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
std::string EncodeBase64(Span< const uint8_t > input)
bool IsHex(std::string_view str)
Returns true if each character in str is a hex character, and has an even number of hex digits.
V Cat(V v1, V &&v2)
Concatenate two vectors, moving elements.
static const int PROTOCOL_VERSION
network protocol versioning
void EnsureWalletIsUnlocked(const CWallet *pwallet)
std::shared_ptr< CWallet > GetWalletForJSONRPCRequest(const JSONRPCRequest &request)
Figures out what wallet, if any, to use for a JSONRPCRequest.
LegacyScriptPubKeyMan & EnsureLegacyScriptPubKeyMan(CWallet &wallet, bool also_create)
bool GetAvoidReuseFlag(const CWallet *const pwallet, const UniValue ¶m)
bool ParseIncludeWatchonly(const UniValue &include_watchonly, const CWallet &pwallet)
Used by RPC commands that have an include_watchonly parameter.
WalletContext & EnsureWalletContext(const std::any &context)
const std::string HELP_REQUIRING_PASSPHRASE
std::string LabelFromValue(const UniValue &value)
bool GetWalletNameFromJSONRPCRequest(const JSONRPCRequest &request, std::string &wallet_name)
std::tuple< std::shared_ptr< CWallet >, std::vector< bilingual_str > > LoadWalletHelper(WalletContext &context, UniValue load_on_start_param, const 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
void UnloadWallet(std::shared_ptr< CWallet > &&wallet)
Explicitly unload and delete the wallet.
std::shared_ptr< CWallet > GetWallet(const std::string &name)
std::vector< std::shared_ptr< CWallet > > GetWallets()
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)
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,...