41 static const std::string WALLET_ENDPOINT_BASE =
"/wallet/";
45 if (request.
URI.substr(0, WALLET_ENDPOINT_BASE.size()) == WALLET_ENDPOINT_BASE) {
47 wallet_name =
urlDecode(request.
URI.substr(WALLET_ENDPOINT_BASE.size()));
55 std::string wallet_name;
57 std::shared_ptr<CWallet> pwallet =
GetWallet(wallet_name);
62 std::vector<std::shared_ptr<CWallet>> wallets =
GetWallets();
63 return wallets.size() == 1 || (request.
fHelp && wallets.size() > 0) ? wallets[0] :
nullptr;
69 ?
"\nRequires wallet passphrase to be set with walletpassphrase call." 75 if (pwallet)
return true;
76 if (avoidException)
return false;
79 RPC_METHOD_NOT_FOUND,
"Method not found (wallet method is disabled because no wallet is loaded)");
82 "Wallet file not specified (must request wallet RPC through /wallet/<filename> uri-path).");
94 int confirms = wtx.GetDepthInMainChain();
95 entry.pushKV(
"confirmations", confirms);
97 entry.pushKV(
"generated",
true);
100 entry.pushKV(
"blockhash", wtx.hashBlock.GetHex());
101 entry.pushKV(
"blockindex", wtx.nIndex);
104 entry.pushKV(
"trusted", wtx.IsTrusted());
107 entry.pushKV(
"txid", hash.
GetHex());
109 for (
const uint256& conflict : wtx.GetConflicts())
110 conflicts.push_back(conflict.GetHex());
111 entry.pushKV(
"walletconflicts", conflicts);
112 entry.pushKV(
"time", wtx.GetTxTime());
113 entry.pushKV(
"timereceived", (int64_t)wtx.nTimeReceived);
116 std::string rbfStatus =
"no";
121 rbfStatus =
"unknown";
125 entry.pushKV(
"bip125-replaceable", rbfStatus);
127 for (
const std::pair<const std::string, std::string>& item : wtx.mapValue)
128 entry.pushKV(item.first, item.second);
131 static std::string LabelFromValue(
const UniValue& value)
133 std::string label = value.
get_str();
142 CWallet*
const pwallet = wallet.get();
149 throw std::runtime_error(
150 "getnewaddress ( \"label\" \"address_type\" )\n" 151 "\nReturns a new BSHA3 address for receiving payments.\n" 152 "If 'label' is specified, it is added to the address book \n" 153 "so payments received with the address will be associated with 'label'.\n" 155 "1. \"label\" (string, optional) The label name for the address to be linked to. If not provided, the default label \"\" is used. It can also be set to the empty string \"\" to represent the default label. The label does not need to exist, it will be created if there is no label by the given name.\n" 156 "2. \"address_type\" (string, optional) The address type to use. Options are \"legacy\", \"p2sh-segwit\", and \"bech32\". Default is set by -addresstype.\n" 158 "\"address\" (string) The new bitcoin address\n" 173 label = LabelFromValue(request.
params[0]);
202 CWallet*
const pwallet = wallet.get();
209 throw std::runtime_error(
210 "getrawchangeaddress ( \"address_type\" )\n" 211 "\nReturns a new BSHA3 address, for receiving change.\n" 212 "This is for use with raw transactions, NOT normal use.\n" 214 "1. \"address_type\" (string, optional) The address type to use. Options are \"legacy\", \"p2sh-segwit\", and \"bech32\". Default is set by -changetype.\n" 216 "\"address\" (string) The address\n" 241 if (!reservekey.GetReservedKey(vchPubKey,
true))
244 reservekey.KeepKey();
256 CWallet*
const pwallet = wallet.get();
263 throw std::runtime_error(
264 "setlabel \"address\" \"label\"\n" 265 "\nSets the label associated with the given address.\n" 267 "1. \"address\" (string, required) The bitcoin address to be associated with a label.\n" 268 "2. \"label\" (string, required) The label to assign to the address.\n" 270 +
HelpExampleCli(
"setlabel",
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"tabby\"")
271 +
HelpExampleRpc(
"setlabel",
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"tabby\"")
281 std::string label = LabelFromValue(request.
params[1]);
283 if (
IsMine(*pwallet, dest)) {
301 if (nValue > curBalance)
314 std::string strError;
315 std::vector<CRecipient> vecSend;
316 int nChangePosRet = -1;
317 CRecipient recipient = {scriptPubKey, nValue, fSubtractFeeFromAmount};
320 if (!pwallet->
CreateTransaction(vecSend, tx, reservekey, nFeeRequired, nChangePosRet, strError, coin_control)) {
321 if (!fSubtractFeeFromAmount && nValue + nFeeRequired > curBalance)
322 strError =
strprintf(
"Error: This transaction requires a transaction fee of at least %s",
FormatMoney(nFeeRequired));
336 CWallet*
const pwallet = wallet.get();
343 throw std::runtime_error(
344 "sendtoaddress \"address\" amount ( \"comment\" \"comment_to\" subtractfeefromamount replaceable conf_target \"estimate_mode\")\n" 345 "\nSend an amount to a given address.\n" 348 "1. \"address\" (string, required) The bitcoin address to send to.\n" 349 "2. \"amount\" (numeric or string, required) The amount in " +
CURRENCY_UNIT +
" to send. eg 0.1\n" 350 "3. \"comment\" (string, optional) A comment used to store what the transaction is for. \n" 351 " This is not part of the transaction, just kept in your wallet.\n" 352 "4. \"comment_to\" (string, optional) A comment to store the name of the person or organization \n" 353 " to which you're sending the transaction. This is not part of the \n" 354 " transaction, just kept in your wallet.\n" 355 "5. subtractfeefromamount (boolean, optional, default=false) The fee will be deducted from the amount being sent.\n" 356 " The recipient will receive less bitcoins than you enter in the amount field.\n" 357 "6. replaceable (boolean, optional) Allow this transaction to be replaced by a transaction with higher fees via BIP 125\n" 358 "7. conf_target (numeric, optional) Confirmation target (in blocks)\n" 359 "8. \"estimate_mode\" (string, optional, default=UNSET) The fee estimate mode, must be one of:\n" 362 " \"CONSERVATIVE\"\n" 364 "\"txid\" (string) The transaction id.\n" 366 +
HelpExampleCli(
"sendtoaddress",
"\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.1")
367 +
HelpExampleCli(
"sendtoaddress",
"\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.1 \"donation\" \"seans outpost\"")
368 +
HelpExampleCli(
"sendtoaddress",
"\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 0.1 \"\" \"\" true")
369 +
HelpExampleRpc(
"sendtoaddress",
"\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\", 0.1, \"donation\", \"seans outpost\"")
395 bool fSubtractFeeFromAmount =
false;
418 CTransactionRef tx = SendMoney(pwallet, dest, nAmount, fSubtractFeeFromAmount, coin_control, std::move(mapValue));
419 return tx->GetHash().GetHex();
425 CWallet*
const pwallet = wallet.get();
432 throw std::runtime_error(
433 "listaddressgroupings\n" 434 "\nLists groups of addresses which have had their common ownership\n" 435 "made public by common use as inputs or as the resulting change\n" 436 "in past transactions\n" 441 " \"address\", (string) The bitcoin address\n" 443 " \"label\" (string, optional) The label\n" 471 addressInfo.push_back(pwallet->
mapAddressBook.find(address)->second.name);
474 jsonGrouping.push_back(addressInfo);
476 jsonGroupings.push_back(jsonGrouping);
478 return jsonGroupings;
484 CWallet*
const pwallet = wallet.get();
491 throw std::runtime_error(
492 "signmessage \"address\" \"message\"\n" 493 "\nSign a message with the private key of an address" 496 "1. \"address\" (string, required) The bitcoin address to use for the private key.\n" 497 "2. \"message\" (string, required) The message to create a signature of.\n" 499 "\"signature\" (string) The signature of the message encoded in base 64\n" 501 "\nUnlock the wallet for 30 seconds\n" 503 "\nCreate the signature\n" 504 +
HelpExampleCli(
"signmessage",
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"my message\"") +
505 "\nVerify the signature\n" 506 +
HelpExampleCli(
"verifymessage",
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"signature\" \"my message\"") +
507 "\nAs a JSON-RPC call\n" 508 +
HelpExampleRpc(
"signmessage",
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"my message\"")
523 const CKeyID *keyID = boost::get<CKeyID>(&dest);
529 if (!pwallet->
GetKey(*keyID, key)) {
537 std::vector<unsigned char> vchSig;
547 CWallet*
const pwallet = wallet.get();
554 throw std::runtime_error(
555 "getreceivedbyaddress \"address\" ( minconf )\n" 556 "\nReturns the total amount received by the given address in transactions with at least minconf confirmations.\n" 558 "1. \"address\" (string, required) The bitcoin address for transactions.\n" 559 "2. minconf (numeric, optional, default=1) Only include transactions confirmed at least this many times.\n" 561 "amount (numeric) The total amount in " +
CURRENCY_UNIT +
" received at this address.\n" 563 "\nThe amount from transactions with at least 1 confirmation\n" 564 +
HelpExampleCli(
"getreceivedbyaddress",
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\"") +
565 "\nThe amount including unconfirmed transactions, zero confirmations\n" 566 +
HelpExampleCli(
"getreceivedbyaddress",
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" 0") +
567 "\nThe amount with at least 6 confirmations\n" 568 +
HelpExampleCli(
"getreceivedbyaddress",
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" 6") +
569 "\nAs a JSON-RPC call\n" 570 +
HelpExampleRpc(
"getreceivedbyaddress",
"\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", 6")
585 if (!
IsMine(*pwallet, scriptPubKey)) {
596 for (
const std::pair<const uint256, CWalletTx>& pairWtx : pwallet->mapWallet) {
601 for (
const CTxOut& txout : wtx.
tx->vout)
614 CWallet*
const pwallet = wallet.get();
621 throw std::runtime_error(
622 "getreceivedbylabel \"label\" ( minconf )\n" 623 "\nReturns the total amount received by addresses with <label> in transactions with at least [minconf] confirmations.\n" 625 "1. \"label\" (string, required) The selected label, may be the default label using \"\".\n" 626 "2. minconf (numeric, optional, default=1) Only include transactions confirmed at least this many times.\n" 628 "amount (numeric) The total amount in " +
CURRENCY_UNIT +
" received for this label.\n" 630 "\nAmount received by the default label with at least 1 confirmation\n" 632 "\nAmount received at the tabby label including unconfirmed amounts with zero confirmations\n" 634 "\nThe amount with at least 6 confirmations\n" 636 "\nAs a JSON-RPC call\n" 652 std::string label = LabelFromValue(request.
params[0]);
657 for (
const std::pair<const uint256, CWalletTx>& pairWtx : pwallet->mapWallet) {
662 for (
const CTxOut& txout : wtx.
tx->vout)
679 CWallet*
const pwallet = wallet.get();
686 throw std::runtime_error(
687 "getbalance ( \"(dummy)\" minconf include_watchonly )\n" 688 "\nReturns the total available balance.\n" 689 "The available balance is what the wallet considers currently spendable, and is\n" 690 "thus affected by options which limit spendability such as -spendzeroconfchange.\n" 692 "1. (dummy) (string, optional) Remains for backward compatibility. Must be excluded or set to \"*\".\n" 693 "2. minconf (numeric, optional, default=0) Only include transactions confirmed at least this many times.\n" 694 "3. include_watchonly (bool, optional, default=false) Also include balance in watch-only addresses (see 'importaddress')\n" 696 "amount (numeric) The total amount in " +
CURRENCY_UNIT +
" received for this wallet.\n" 698 "\nThe total amount in the wallet with 1 or more confirmations\n" 700 "\nThe total amount in the wallet at least 6 blocks confirmed\n" 702 "\nAs a JSON-RPC call\n" 733 CWallet*
const pwallet = wallet.get();
740 throw std::runtime_error(
741 "getunconfirmedbalance\n" 742 "Returns the server's total unconfirmed balance\n");
757 CWallet*
const pwallet = wallet.get();
764 throw std::runtime_error(
765 "sendmany \"\" {\"address\":amount,...} ( minconf \"comment\" [\"address\",...] replaceable conf_target \"estimate_mode\")\n" 766 "\nSend multiple times. Amounts are double-precision floating point numbers.\n" 769 "1. \"dummy\" (string, required) Must be set to \"\" for backwards compatibility.\n" 770 "2. \"amounts\" (string, required) A json object with addresses and amounts\n" 772 " \"address\":amount (numeric or string) The bitcoin address is the key, the numeric amount (can be string) in " +
CURRENCY_UNIT +
" is the value\n" 775 "3. minconf (numeric, optional, default=1) Only use the balance confirmed at least this many times.\n" 776 "4. \"comment\" (string, optional) A comment\n" 777 "5. subtractfeefrom (array, optional) A json array with addresses.\n" 778 " The fee will be equally deducted from the amount of each selected address.\n" 779 " Those recipients will receive less bitcoins than you enter in their corresponding amount field.\n" 780 " If no addresses are specified here, the sender pays the fee.\n" 782 " \"address\" (string) Subtract fee from this address\n" 785 "6. replaceable (boolean, optional) Allow this transaction to be replaced by a transaction with higher fees via BIP 125\n" 786 "7. conf_target (numeric, optional) Confirmation target (in blocks)\n" 787 "8. \"estimate_mode\" (string, optional, default=UNSET) The fee estimate mode, must be one of:\n" 790 " \"CONSERVATIVE\"\n" 792 "\"txid\" (string) The transaction id for the send. Only 1 transaction is created regardless of \n" 793 " the number of addresses.\n" 795 "\nSend two amounts to two different addresses:\n" 796 +
HelpExampleCli(
"sendmany",
"\"\" \"{\\\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\\\":0.01,\\\"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\":0.02}\"") +
797 "\nSend two amounts to two different addresses setting the confirmation and comment:\n" 798 +
HelpExampleCli(
"sendmany",
"\"\" \"{\\\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\\\":0.01,\\\"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\":0.02}\" 6 \"testing\"") +
799 "\nSend two amounts to two different addresses, subtract fee from amount:\n" 800 +
HelpExampleCli(
"sendmany",
"\"\" \"{\\\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\\\":0.01,\\\"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\":0.02}\" 1 \"\" \"[\\\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\\\",\\\"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\\\"]\"") +
801 "\nAs a JSON-RPC call\n" 802 +
HelpExampleRpc(
"sendmany",
"\"\", {\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\":0.01,\"1353tsE8YMTA4EuV7dgUXGjNFf9KpVvKHz\":0.02}, 6, \"testing\"")
846 std::set<CTxDestination> destinations;
847 std::vector<CRecipient> vecSend;
850 std::vector<std::string> keys = sendTo.
getKeys();
851 for (
const std::string& name_ : keys) {
857 if (destinations.count(dest)) {
860 destinations.insert(dest);
866 totalAmount += nAmount;
868 bool fSubtractFeeFromAmount =
false;
869 for (
unsigned int idx = 0; idx < subtractFeeFromAmount.size(); idx++) {
870 const UniValue& addr = subtractFeeFromAmount[idx];
872 fSubtractFeeFromAmount =
true;
875 CRecipient recipient = {scriptPubKey, nAmount, fSubtractFeeFromAmount};
892 int nChangePosRet = -1;
893 std::string strFailReason;
895 bool fCreated = pwallet->
CreateTransaction(vecSend, tx, keyChange, nFeeRequired, nChangePosRet, strFailReason, coin_control);
904 return tx->GetHash().GetHex();
910 CWallet*
const pwallet = wallet.get();
917 std::string msg =
"addmultisigaddress nrequired [\"key\",...] ( \"label\" \"address_type\" )\n" 918 "\nAdd a nrequired-to-sign multisignature address to the wallet. Requires a new wallet backup.\n" 919 "Each key is a BSHA3 address or hex-encoded public key.\n" 920 "This functionality is only intended for use with non-watchonly addresses.\n" 921 "See `importaddress` for watchonly p2sh address support.\n" 922 "If 'label' is specified, assign address to that label.\n" 925 "1. nrequired (numeric, required) The number of required signatures out of the n keys or addresses.\n" 926 "2. \"keys\" (string, required) A json array of bitcoin addresses or hex-encoded public keys\n" 928 " \"address\" (string) bitcoin address or hex-encoded public key\n" 931 "3. \"label\" (string, optional) A label to assign the addresses to.\n" 932 "4. \"address_type\" (string, optional) The address type to use. Options are \"legacy\", \"p2sh-segwit\", and \"bech32\". Default is set by -addresstype.\n" 936 " \"address\":\"multisigaddress\", (string) The value of the new multisig address.\n" 937 " \"redeemScript\":\"script\" (string) The string value of the hex-encoded redemption script.\n" 940 "\nAdd a multisig address from 2 addresses\n" 941 +
HelpExampleCli(
"addmultisigaddress",
"2 \"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\",\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") +
942 "\nAs a JSON-RPC call\n" 943 +
HelpExampleRpc(
"addmultisigaddress",
"2, \"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\",\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"")
945 throw std::runtime_error(msg);
952 label = LabelFromValue(request.
params[2]);
958 std::vector<CPubKey> pubkeys;
959 for (
unsigned int i = 0; i < keys_or_addrs.
size(); ++i) {
960 if (
IsHex(keys_or_addrs[i].get_str()) && (keys_or_addrs[i].
get_str().length() == 66 || keys_or_addrs[i].
get_str().length() == 130)) {
963 pubkeys.push_back(
AddrToPubKey(pwallet, keys_or_addrs[i].get_str()));
981 result.pushKV(
"redeemScript",
HexStr(inner.
begin(), inner.
end()));
994 nConf = std::numeric_limits<int>::max();
1003 if (!params[0].isNull())
1004 nMinDepth = params[0].get_int();
1008 if (!params[1].isNull())
1012 if(!params[2].isNull())
1013 if(params[2].get_bool())
1018 if (!by_label && params.size() > 3) {
1028 for (
const std::pair<const uint256, CWalletTx>& pairWtx : pwallet->mapWallet) {
1035 if (nDepth < nMinDepth)
1038 for (
const CTxOut& txout : wtx.
tx->vout)
1080 const std::string& label = item_it->second.name;
1086 int nConf = std::numeric_limits<int>::max();
1087 bool fIsWatchonly =
false;
1090 nAmount = (*it).second.nAmount;
1091 nConf = (*it).second.nConf;
1092 fIsWatchonly = (*it).second.fIsWatchonly;
1106 obj.
pushKV(
"involvesWatchonly",
true);
1109 obj.
pushKV(
"confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
1110 obj.
pushKV(
"label", label);
1114 for (
const uint256& _item : (*it).second.txids)
1119 obj.
pushKV(
"txids", transactions);
1128 CAmount nAmount = entry.second.nAmount;
1129 int nConf = entry.second.nConf;
1131 if (entry.second.fIsWatchonly)
1132 obj.
pushKV(
"involvesWatchonly",
true);
1134 obj.
pushKV(
"confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf));
1135 obj.
pushKV(
"label", entry.first);
1146 CWallet*
const pwallet = wallet.get();
1153 throw std::runtime_error(
1154 "listreceivedbyaddress ( minconf include_empty include_watchonly address_filter )\n" 1155 "\nList balances by receiving address.\n" 1157 "1. minconf (numeric, optional, default=1) The minimum number of confirmations before payments are included.\n" 1158 "2. include_empty (bool, optional, default=false) Whether to include addresses that haven't received any payments.\n" 1159 "3. include_watchonly (bool, optional, default=false) Whether to include watch-only addresses (see 'importaddress').\n" 1160 "4. address_filter (string, optional) If present, only return information on this address.\n" 1164 " \"involvesWatchonly\" : true, (bool) Only returned if imported addresses were involved in transaction\n" 1165 " \"address\" : \"receivingaddress\", (string) The receiving address\n" 1166 " \"amount\" : x.xxx, (numeric) The total amount in " +
CURRENCY_UNIT +
" received by the address\n" 1167 " \"confirmations\" : n, (numeric) The number of confirmations of the most recent transaction included\n" 1168 " \"label\" : \"label\", (string) The label of the receiving address. The default label is \"\".\n" 1170 " \"txid\", (string) The ids of transactions received with the address \n" 1181 +
HelpExampleRpc(
"listreceivedbyaddress",
"6, true, true, \"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\"")
1190 return ListReceived(pwallet, request.
params,
false);
1196 CWallet*
const pwallet = wallet.get();
1203 throw std::runtime_error(
1204 "listreceivedbylabel ( minconf include_empty include_watchonly)\n" 1205 "\nList received transactions by label.\n" 1207 "1. minconf (numeric, optional, default=1) The minimum number of confirmations before payments are included.\n" 1208 "2. include_empty (bool, optional, default=false) Whether to include labels that haven't received any payments.\n" 1209 "3. include_watchonly (bool, optional, default=false) Whether to include watch-only addresses (see 'importaddress').\n" 1214 " \"involvesWatchonly\" : true, (bool) Only returned if imported addresses were involved in transaction\n" 1215 " \"amount\" : x.xxx, (numeric) The total amount received by addresses with this label\n" 1216 " \"confirmations\" : n, (numeric) The number of confirmations of the most recent transaction included\n" 1217 " \"label\" : \"label\" (string) The label of the receiving address. The default label is \"\".\n" 1234 return ListReceived(pwallet, request.
params,
true);
1257 std::list<COutputEntry> listReceived;
1258 std::list<COutputEntry> listSent;
1265 if ((!listSent.empty() || nFee != 0))
1271 entry.
pushKV(
"involvesWatchonly",
true);
1273 MaybePushAddress(entry, s.destination);
1274 entry.
pushKV(
"category",
"send");
1279 entry.
pushKV(
"vout", s.vout);
1282 WalletTxToJSON(wtx, entry);
1299 entry.
pushKV(
"involvesWatchonly",
true);
1301 MaybePushAddress(entry, r.destination);
1305 entry.
pushKV(
"category",
"orphan");
1307 entry.
pushKV(
"category",
"immature");
1309 entry.
pushKV(
"category",
"generate");
1313 entry.
pushKV(
"category",
"receive");
1317 entry.
pushKV(
"label", label);
1319 entry.
pushKV(
"vout", r.vout);
1321 WalletTxToJSON(wtx, entry);
1330 CWallet*
const pwallet = wallet.get();
1337 throw std::runtime_error(
1338 "listtransactions (dummy count skip include_watchonly)\n" 1339 "\nReturns up to 'count' most recent transactions skipping the first 'from' transactions.\n" 1341 "1. \"dummy\" (string, optional) If set, should be \"*\" for backwards compatibility.\n" 1342 "2. count (numeric, optional, default=10) The number of transactions to return\n" 1343 "3. skip (numeric, optional, default=0) The number of transactions to skip\n" 1344 "4. include_watchonly (bool, optional, default=false) Include transactions to watch-only addresses (see 'importaddress')\n" 1348 " \"address\":\"address\", (string) The bitcoin address of the transaction.\n" 1349 " \"category\":\"send|receive\", (string) The transaction category.\n" 1350 " \"amount\": x.xxx, (numeric) The amount in " +
CURRENCY_UNIT +
". This is negative for the 'send' category, and is positive\n" 1351 " for the 'receive' category,\n" 1352 " \"label\": \"label\", (string) A comment for the address/transaction, if any\n" 1353 " \"vout\": n, (numeric) the vout value\n" 1354 " \"fee\": x.xxx, (numeric) The amount of the fee in " +
CURRENCY_UNIT +
". This is negative and only available for the \n" 1355 " 'send' category of transactions.\n" 1356 " \"confirmations\": n, (numeric) The number of confirmations for the transaction. Negative confirmations indicate the\n" 1357 " transaction conflicts with the block chain\n" 1358 " \"trusted\": xxx, (bool) Whether we consider the outputs of this unconfirmed transaction safe to spend.\n" 1359 " \"blockhash\": \"hashvalue\", (string) The block hash containing the transaction.\n" 1360 " \"blockindex\": n, (numeric) The index of the transaction in the block that includes it.\n" 1361 " \"blocktime\": xxx, (numeric) The block time in seconds since epoch (1 Jan 1970 GMT).\n" 1362 " \"txid\": \"transactionid\", (string) The transaction id.\n" 1363 " \"time\": xxx, (numeric) The transaction time in seconds since epoch (midnight Jan 1 1970 GMT).\n" 1364 " \"timereceived\": xxx, (numeric) The time received in seconds since epoch (midnight Jan 1 1970 GMT).\n" 1365 " \"comment\": \"...\", (string) If a comment is associated with the transaction.\n" 1366 " \"bip125-replaceable\": \"yes|no|unknown\", (string) Whether this transaction could be replaced due to BIP125 (replace-by-fee);\n" 1367 " may be unknown for unconfirmed transactions not in the mempool\n" 1368 " \"abandoned\": xxx (bool) 'true' if the transaction has been abandoned (inputs are respendable). Only available for the \n" 1369 " 'send' category of transactions.\n" 1374 "\nList the most recent 10 transactions in the systems\n" 1376 "\nList transactions 100 to 120\n" 1378 "\nAs a JSON-RPC call\n" 1413 for (CWallet::TxItems::const_reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it)
1416 ListTransactions(pwallet, *pwtx, 0,
true,
ret,
filter);
1417 if ((
int)
ret.
size() >= (nCount+nFrom))
break;
1425 if ((nFrom + nCount) > (
int)
ret.
size())
1430 std::vector<UniValue>::iterator first = arrTmp.begin();
1431 std::advance(first, nFrom);
1432 std::vector<UniValue>::iterator last = arrTmp.begin();
1433 std::advance(last, nFrom+nCount);
1435 if (last != arrTmp.end()) arrTmp.erase(last, arrTmp.end());
1436 if (first != arrTmp.begin()) arrTmp.erase(arrTmp.begin(), first);
1438 std::reverse(arrTmp.begin(), arrTmp.end());
1450 CWallet*
const pwallet = wallet.get();
1457 throw std::runtime_error(
1458 "listsinceblock ( \"blockhash\" target_confirmations include_watchonly include_removed )\n" 1459 "\nGet all transactions in blocks since block [blockhash], or all transactions if omitted.\n" 1460 "If \"blockhash\" is no longer a part of the main chain, transactions from the fork point onward are included.\n" 1461 "Additionally, if include_removed is set, transactions affecting the wallet which were removed are returned in the \"removed\" array.\n" 1463 "1. \"blockhash\" (string, optional) The block hash to list transactions since\n" 1464 "2. target_confirmations: (numeric, optional, default=1) Return the nth block hash from the main chain. e.g. 1 would mean the best block hash. Note: this is not used as a filter, but only affects [lastblock] in the return value\n" 1465 "3. include_watchonly: (bool, optional, default=false) Include transactions to watch-only addresses (see 'importaddress')\n" 1466 "4. include_removed: (bool, optional, default=true) Show transactions that were removed due to a reorg in the \"removed\" array\n" 1467 " (not guaranteed to work on pruned nodes)\n" 1470 " \"transactions\": [\n" 1471 " \"address\":\"address\", (string) The bitcoin address of the transaction. Not present for move transactions (category = move).\n" 1472 " \"category\":\"send|receive\", (string) The transaction category. 'send' has negative amounts, 'receive' has positive amounts.\n" 1473 " \"amount\": x.xxx, (numeric) The amount in " +
CURRENCY_UNIT +
". This is negative for the 'send' category, and for the 'move' category for moves \n" 1474 " outbound. It is positive for the 'receive' category, and for the 'move' category for inbound funds.\n" 1475 " \"vout\" : n, (numeric) the vout value\n" 1476 " \"fee\": x.xxx, (numeric) The amount of the fee in " +
CURRENCY_UNIT +
". This is negative and only available for the 'send' category of transactions.\n" 1477 " \"confirmations\": n, (numeric) The number of confirmations for the transaction. Available for 'send' and 'receive' category of transactions.\n" 1478 " When it's < 0, it means the transaction conflicted that many blocks ago.\n" 1479 " \"blockhash\": \"hashvalue\", (string) The block hash containing the transaction. Available for 'send' and 'receive' category of transactions.\n" 1480 " \"blockindex\": n, (numeric) The index of the transaction in the block that includes it. Available for 'send' and 'receive' category of transactions.\n" 1481 " \"blocktime\": xxx, (numeric) The block time in seconds since epoch (1 Jan 1970 GMT).\n" 1482 " \"txid\": \"transactionid\", (string) The transaction id. Available for 'send' and 'receive' category of transactions.\n" 1483 " \"time\": xxx, (numeric) The transaction time in seconds since epoch (Jan 1 1970 GMT).\n" 1484 " \"timereceived\": xxx, (numeric) The time received in seconds since epoch (Jan 1 1970 GMT). Available for 'send' and 'receive' category of transactions.\n" 1485 " \"bip125-replaceable\": \"yes|no|unknown\", (string) Whether this transaction could be replaced due to BIP125 (replace-by-fee);\n" 1486 " may be unknown for unconfirmed transactions not in the mempool\n" 1487 " \"abandoned\": xxx, (bool) 'true' if the transaction has been abandoned (inputs are respendable). Only available for the 'send' category of transactions.\n" 1488 " \"comment\": \"...\", (string) If a comment is associated with the transaction.\n" 1489 " \"label\" : \"label\" (string) A comment for the address/transaction, if any\n" 1490 " \"to\": \"...\", (string) If a comment to is associated with the transaction.\n" 1493 " <structure is the same as \"transactions\" above, only present if include_removed=true>\n" 1494 " Note: transactions that were re-added in the active chain will appear as-is in this array, and may thus have a positive confirmation count.\n" 1496 " \"lastblock\": \"lastblockhash\" (string) The hash of the block (target_confirmations-1) from the best block on the main chain. This is typically used to feed back into listsinceblock the next time you call it. So you would generally use a target_confirmations of say 6, so you will be continually re-notified of transactions until they've reached 6 confirmations plus any new ones\n" 1500 +
HelpExampleCli(
"listsinceblock",
"\"000000000000000bacf66f7497b7dc45ef753ee9a7d38571037cdb1a57f663ad\" 6")
1501 +
HelpExampleRpc(
"listsinceblock",
"\"000000000000000bacf66f7497b7dc45ef753ee9a7d38571037cdb1a57f663ad\", 6")
1512 int target_confirms = 1;
1533 if (target_confirms < 1) {
1548 for (
const std::pair<const uint256, CWalletTx>& pairWtx : pwallet->mapWallet) {
1552 ListTransactions(pwallet, tx, 0,
true, transactions,
filter);
1559 while (include_removed && paltindex && paltindex != pindex) {
1565 auto it = pwallet->mapWallet.find(tx->GetHash());
1566 if (it != pwallet->mapWallet.end()) {
1569 ListTransactions(pwallet, it->second, -100000000,
true, removed,
filter);
1572 paltindex = paltindex->
pprev;
1579 ret.
pushKV(
"transactions", transactions);
1580 if (include_removed)
ret.
pushKV(
"removed", removed);
1589 CWallet*
const pwallet = wallet.get();
1596 throw std::runtime_error(
1597 "gettransaction \"txid\" ( include_watchonly )\n" 1598 "\nGet detailed information about in-wallet transaction <txid>\n" 1600 "1. \"txid\" (string, required) The transaction id\n" 1601 "2. \"include_watchonly\" (bool, optional, default=false) Whether to include watch-only addresses in balance calculation and details[]\n" 1604 " \"amount\" : x.xxx, (numeric) The transaction amount in " +
CURRENCY_UNIT +
"\n" 1605 " \"fee\": x.xxx, (numeric) The amount of the fee in " +
CURRENCY_UNIT +
". This is negative and only available for the \n" 1606 " 'send' category of transactions.\n" 1607 " \"confirmations\" : n, (numeric) The number of confirmations\n" 1608 " \"blockhash\" : \"hash\", (string) The block hash\n" 1609 " \"blockindex\" : xx, (numeric) The index of the transaction in the block that includes it\n" 1610 " \"blocktime\" : ttt, (numeric) The time in seconds since epoch (1 Jan 1970 GMT)\n" 1611 " \"txid\" : \"transactionid\", (string) The transaction id.\n" 1612 " \"time\" : ttt, (numeric) The transaction time in seconds since epoch (1 Jan 1970 GMT)\n" 1613 " \"timereceived\" : ttt, (numeric) The time received in seconds since epoch (1 Jan 1970 GMT)\n" 1614 " \"bip125-replaceable\": \"yes|no|unknown\", (string) Whether this transaction could be replaced due to BIP125 (replace-by-fee);\n" 1615 " may be unknown for unconfirmed transactions not in the mempool\n" 1616 " \"details\" : [\n" 1618 " \"address\" : \"address\", (string) The bitcoin address involved in the transaction\n" 1619 " \"category\" : \"send|receive\", (string) The category, either 'send' or 'receive'\n" 1620 " \"amount\" : x.xxx, (numeric) The amount in " +
CURRENCY_UNIT +
"\n" 1621 " \"label\" : \"label\", (string) A comment for the address/transaction, if any\n" 1622 " \"vout\" : n, (numeric) the vout value\n" 1623 " \"fee\": x.xxx, (numeric) The amount of the fee in " +
CURRENCY_UNIT +
". This is negative and only available for the \n" 1624 " 'send' category of transactions.\n" 1625 " \"abandoned\": xxx (bool) 'true' if the transaction has been abandoned (inputs are respendable). Only available for the \n" 1626 " 'send' category of transactions.\n" 1630 " \"hex\" : \"data\" (string) Raw data for transaction\n" 1634 +
HelpExampleCli(
"gettransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
1635 +
HelpExampleCli(
"gettransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\" true")
1636 +
HelpExampleRpc(
"gettransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
1653 auto it = pwallet->mapWallet.find(hash);
1654 if (it == pwallet->mapWallet.end()) {
1661 CAmount nNet = nCredit - nDebit;
1668 WalletTxToJSON(wtx, entry);
1671 ListTransactions(pwallet, wtx, 0,
false, details,
filter);
1672 entry.
pushKV(
"details", details);
1675 entry.
pushKV(
"hex", strHex);
1683 CWallet*
const pwallet = wallet.get();
1690 throw std::runtime_error(
1691 "abandontransaction \"txid\"\n" 1692 "\nMark in-wallet transaction <txid> as abandoned\n" 1693 "This will mark this transaction and all its in-wallet descendants as abandoned which will allow\n" 1694 "for their inputs to be respent. It can be used to replace \"stuck\" or evicted transactions.\n" 1695 "It only works on transactions which are not included in a block and are not currently in the mempool.\n" 1696 "It has no effect on transactions which are already abandoned.\n" 1698 "1. \"txid\" (string, required) The transaction id\n" 1701 +
HelpExampleCli(
"abandontransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
1702 +
HelpExampleRpc(
"abandontransaction",
"\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"")
1714 if (!pwallet->mapWallet.count(hash)) {
1728 CWallet*
const pwallet = wallet.get();
1735 throw std::runtime_error(
1736 "backupwallet \"destination\"\n" 1737 "\nSafely copies current wallet file to destination, which can be a directory or a path with filename.\n" 1739 "1. \"destination\" (string) The destination directory or file\n" 1763 CWallet*
const pwallet = wallet.get();
1770 throw std::runtime_error(
1771 "keypoolrefill ( newsize )\n" 1772 "\nFills the keypool." 1775 "1. newsize (numeric, optional, default=100) The new keypool size\n" 1788 unsigned int kpSize = 0;
1809 CWallet*
const pwallet = wallet.get();
1816 throw std::runtime_error(
1817 "walletpassphrase \"passphrase\" timeout\n" 1818 "\nStores the wallet decryption key in memory for 'timeout' seconds.\n" 1819 "This is needed prior to performing transactions related to private keys such as sending bitcoins\n" 1821 "1. \"passphrase\" (string, required) The wallet passphrase\n" 1822 "2. timeout (numeric, required) The time to keep the decryption key in seconds; capped at 100000000 (~3 years).\n" 1824 "Issuing the walletpassphrase command while the wallet is already unlocked will set a new unlock\n" 1825 "time that overrides the old one.\n" 1827 "\nUnlock the wallet for 60 seconds\n" 1829 "\nLock the wallet again (before 60 seconds)\n" 1831 "\nAs a JSON-RPC call\n" 1844 strWalletPass.reserve(100);
1852 if (nSleepTime < 0) {
1856 constexpr int64_t MAX_SLEEP_TIME = 100000000;
1857 if (nSleepTime > MAX_SLEEP_TIME) {
1858 nSleepTime = MAX_SLEEP_TIME;
1861 if (strWalletPass.length() > 0)
1863 if (!pwallet->
Unlock(strWalletPass)) {
1868 throw std::runtime_error(
1869 "walletpassphrase <passphrase> <timeout>\n" 1870 "Stores the wallet decryption key in memory for <timeout> seconds.");
1879 std::weak_ptr<CWallet> weak_wallet = wallet;
1881 if (
auto shared_wallet = weak_wallet.lock()) {
1882 LOCK(shared_wallet->cs_wallet);
1883 shared_wallet->Lock();
1884 shared_wallet->nRelockTime = 0;
1895 CWallet*
const pwallet = wallet.get();
1902 throw std::runtime_error(
1903 "walletpassphrasechange \"oldpassphrase\" \"newpassphrase\"\n" 1904 "\nChanges the wallet passphrase from 'oldpassphrase' to 'newpassphrase'.\n" 1906 "1. \"oldpassphrase\" (string) The current passphrase\n" 1907 "2. \"newpassphrase\" (string) The new passphrase\n" 1909 +
HelpExampleCli(
"walletpassphrasechange",
"\"old one\" \"new one\"")
1910 +
HelpExampleRpc(
"walletpassphrasechange",
"\"old one\", \"new one\"")
1923 strOldWalletPass.reserve(100);
1927 strNewWalletPass.reserve(100);
1930 if (strOldWalletPass.length() < 1 || strNewWalletPass.length() < 1)
1931 throw std::runtime_error(
1932 "walletpassphrasechange <oldpassphrase> <newpassphrase>\n" 1933 "Changes the wallet passphrase from <oldpassphrase> to <newpassphrase>.");
1946 CWallet*
const pwallet = wallet.get();
1953 throw std::runtime_error(
1955 "\nRemoves the wallet encryption key from memory, locking the wallet.\n" 1956 "After calling this method, you will need to call walletpassphrase again\n" 1957 "before being able to call any methods which require the wallet to be unlocked.\n" 1959 "\nSet the passphrase for 2 minutes to perform a transaction\n" 1961 "\nPerform a send (requires passphrase set)\n" 1962 +
HelpExampleCli(
"sendtoaddress",
"\"1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd\" 1.0") +
1963 "\nClear the passphrase since we are done before 2 minutes is up\n" 1965 "\nAs a JSON-RPC call\n" 1986 CWallet*
const pwallet = wallet.get();
1993 throw std::runtime_error(
1994 "encryptwallet \"passphrase\"\n" 1995 "\nEncrypts the wallet with 'passphrase'. This is for first time encryption.\n" 1996 "After this, any calls that interact with private keys such as sending or signing \n" 1997 "will require the passphrase to be set prior the making these calls.\n" 1998 "Use the walletpassphrase call for this, and then walletlock call.\n" 1999 "If the wallet is already encrypted, use the walletpassphrasechange call.\n" 2001 "1. \"passphrase\" (string) The pass phrase to encrypt the wallet with. It must be at least 1 character, but should be long.\n" 2003 "\nEncrypt your wallet\n" 2005 "\nNow set the passphrase to use the wallet, such as for signing or sending bitcoin\n" 2007 "\nNow we can do something like sign\n" 2008 +
HelpExampleCli(
"signmessage",
"\"address\" \"test message\"") +
2009 "\nNow lock the wallet again by removing the passphrase\n" 2011 "\nAs a JSON-RPC call\n" 2025 strWalletPass.reserve(100);
2028 if (strWalletPass.length() < 1)
2029 throw std::runtime_error(
2030 "encryptwallet <passphrase>\n" 2031 "Encrypts the wallet with <passphrase>.");
2037 return "wallet encrypted; The keypool has been flushed and a new HD seed was generated (if you are using HD). You need to make a new backup.";
2043 CWallet*
const pwallet = wallet.get();
2050 throw std::runtime_error(
2051 "lockunspent unlock ([{\"txid\":\"txid\",\"vout\":n},...])\n" 2052 "\nUpdates list of temporarily unspendable outputs.\n" 2053 "Temporarily lock (unlock=false) or unlock (unlock=true) specified transaction outputs.\n" 2054 "If no transaction outputs are specified when unlocking then all current locked transaction outputs are unlocked.\n" 2055 "A locked transaction output will not be chosen by automatic coin selection, when spending bitcoins.\n" 2056 "Locks are stored in memory only. Nodes start with zero locked outputs, and the locked output list\n" 2057 "is always cleared (by virtue of process exit) when a node stops or fails.\n" 2058 "Also see the listunspent call\n" 2060 "1. unlock (boolean, required) Whether to unlock (true) or lock (false) the specified transactions\n" 2061 "2. \"transactions\" (string, optional) A json array of objects. Each object the txid (string) vout (numeric)\n" 2062 " [ (json array of json objects)\n" 2064 " \"txid\":\"id\", (string) The transaction id\n" 2065 " \"vout\": n (numeric) The output number\n" 2071 "true|false (boolean) Whether the command was successful or not\n" 2074 "\nList the unspent transactions\n" 2076 "\nLock an unspent transaction\n" 2077 +
HelpExampleCli(
"lockunspent",
"false \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") +
2078 "\nList the locked transactions\n" 2080 "\nUnlock the transaction again\n" 2081 +
HelpExampleCli(
"lockunspent",
"true \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") +
2082 "\nAs a JSON-RPC call\n" 2083 +
HelpExampleRpc(
"lockunspent",
"false, \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"")
2108 std::vector<COutPoint> outputs;
2109 outputs.reserve(output_params.
size());
2111 for (
unsigned int idx = 0; idx < output_params.
size(); idx++) {
2128 const auto it = pwallet->mapWallet.find(outpt.hash);
2129 if (it == pwallet->mapWallet.end()) {
2135 if (outpt.n >= trans.
tx->vout.size()) {
2139 if (pwallet->
IsSpent(outpt.hash, outpt.n)) {
2143 const bool is_locked = pwallet->
IsLockedCoin(outpt.hash, outpt.n);
2145 if (fUnlock && !is_locked) {
2149 if (!fUnlock && is_locked) {
2153 outputs.push_back(outpt);
2157 for (
const COutPoint& outpt : outputs) {
2168 CWallet*
const pwallet = wallet.get();
2175 throw std::runtime_error(
2177 "\nReturns list of temporarily unspendable outputs.\n" 2178 "See the lockunspent call to lock and unlock transactions for spending.\n" 2182 " \"txid\" : \"transactionid\", (string) The transaction id locked\n" 2183 " \"vout\" : n (numeric) The vout value\n" 2188 "\nList the unspent transactions\n" 2190 "\nLock an unspent transaction\n" 2191 +
HelpExampleCli(
"lockunspent",
"false \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") +
2192 "\nList the locked transactions\n" 2194 "\nUnlock the transaction again\n" 2195 +
HelpExampleCli(
"lockunspent",
"true \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") +
2196 "\nAs a JSON-RPC call\n" 2202 std::vector<COutPoint> vOutpts;
2207 for (
const COutPoint& outpt : vOutpts) {
2210 o.
pushKV(
"txid", outpt.hash.GetHex());
2211 o.
pushKV(
"vout", (
int)outpt.n);
2221 CWallet*
const pwallet = wallet.get();
2228 throw std::runtime_error(
2230 "\nSet the transaction fee per kB for this wallet. Overrides the global -paytxfee command line parameter.\n" 2232 "1. amount (numeric or string, required) The transaction fee in " +
CURRENCY_UNIT +
"/kB\n" 2234 "true|false (boolean) Returns true if successful\n" 2244 CFeeRate tx_fee_rate(nAmount, 1000);
2245 if (tx_fee_rate == 0) {
2249 }
else if (tx_fee_rate < pwallet->m_min_fee) {
2260 CWallet*
const pwallet = wallet.get();
2267 throw std::runtime_error(
2269 "Returns an object containing various wallet state info.\n" 2272 " \"walletname\": xxxxx, (string) the wallet name\n" 2273 " \"walletversion\": xxxxx, (numeric) the wallet version\n" 2274 " \"balance\": xxxxxxx, (numeric) the total confirmed balance of the wallet in " +
CURRENCY_UNIT +
"\n" 2275 " \"unconfirmed_balance\": xxx, (numeric) the total unconfirmed balance of the wallet in " +
CURRENCY_UNIT +
"\n" 2276 " \"immature_balance\": xxxxxx, (numeric) the total immature balance of the wallet in " +
CURRENCY_UNIT +
"\n" 2277 " \"txcount\": xxxxxxx, (numeric) the total number of transactions in the wallet\n" 2278 " \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since Unix epoch) of the oldest pre-generated key in the key pool\n" 2279 " \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated (only counts external keys)\n" 2280 " \"keypoolsize_hd_internal\": xxxx, (numeric) how many new keys are pre-generated for internal use (used for change outputs, only appears if the wallet is using this feature, otherwise external keys are used)\n" 2281 " \"unlocked_until\": ttt, (numeric) the timestamp in seconds since epoch (midnight Jan 1 1970 GMT) that the wallet is unlocked for transfers, or 0 if the wallet is locked\n" 2282 " \"paytxfee\": x.xxxx, (numeric) the transaction fee configuration, set in " +
CURRENCY_UNIT +
"/kB\n" 2283 " \"hdseedid\": \"<hash360>\" (string, optional) the Hash360 of the HD seed (only present when HD is enabled)\n" 2284 " \"hdmasterkeyid\": \"<hash360>\" (string, optional) alias for hdseedid retained for backwards-compatibility. Will be removed in V0.18.\n" 2285 " \"private_keys_enabled\": true|false (boolean) false if privatekeys are disabled for this wallet (enforced watch-only wallet)\n" 2301 obj.pushKV(
"walletname", pwallet->
GetName());
2302 obj.pushKV(
"walletversion", pwallet->
GetVersion());
2306 obj.pushKV(
"txcount", (
int)pwallet->mapWallet.size());
2308 obj.pushKV(
"keypoolsize", (int64_t)kpExternalSize);
2311 obj.pushKV(
"keypoolsize_hd_internal", (int64_t)(pwallet->
GetKeyPoolSize() - kpExternalSize));
2314 obj.pushKV(
"unlocked_until", pwallet->
nRelockTime);
2318 obj.pushKV(
"hdseedid", seed_id.
GetHex());
2319 obj.pushKV(
"hdmasterkeyid", seed_id.
GetHex());
2328 throw std::runtime_error(
2330 "Returns a list of wallets in the wallet directory.\n" 2332 " \"wallets\" : [ (json array of objects)\n" 2334 " \"name\" : \"name\" (string) The wallet name\n" 2348 wallet.pushKV(
"name", path.string());
2349 wallets.push_back(wallet);
2353 result.pushKV(
"wallets", wallets);
2360 throw std::runtime_error(
2362 "Returns a list of currently loaded wallets.\n" 2363 "For full information on the wallet, use \"getwalletinfo\"\n" 2365 "[ (json array of strings)\n" 2366 " \"walletname\" (string) the wallet name\n" 2376 for (
const std::shared_ptr<CWallet>& wallet :
GetWallets()) {
2381 LOCK(wallet->cs_wallet);
2383 obj.push_back(wallet->GetName());
2392 throw std::runtime_error(
2393 "loadwallet \"filename\"\n" 2394 "\nLoads a wallet from a wallet file or directory." 2395 "\nNote that all wallet command-line options used when starting bsha3d will be" 2396 "\napplied to the new wallet (eg -zapwallettxes, upgradewallet, rescan, etc).\n" 2398 "1. \"filename\" (string, required) The wallet directory or .dat file.\n" 2401 " \"name\" : <wallet_name>, (string) The wallet name if loaded successfully.\n" 2402 " \"warning\" : <warning>, (string) Warning message if wallet was not loaded cleanly.\n" 2411 fs::path wallet_path = fs::absolute(wallet_file,
GetWalletDir());
2412 if (fs::symlink_status(wallet_path).type() == fs::file_not_found) {
2414 }
else if (fs::is_directory(wallet_path)) {
2416 fs::path wallet_dat_file = wallet_path /
"wallet.dat";
2417 if (fs::symlink_status(wallet_dat_file).type() == fs::file_not_found) {
2422 std::string warning;
2433 wallet->postInitProcess();
2436 obj.pushKV(
"name", wallet->GetName());
2437 obj.pushKV(
"warning", warning);
2445 throw std::runtime_error(
2446 "createwallet \"wallet_name\" ( disable_private_keys )\n" 2447 "\nCreates and loads a new wallet.\n" 2449 "1. \"wallet_name\" (string, required) The name for the new wallet. If this is a path, the wallet will be created at the path location.\n" 2450 "2. disable_private_keys (boolean, optional, default: false) Disable the possibility of private keys (only watchonlys are possible in this mode).\n" 2453 " \"name\" : <wallet_name>, (string) The wallet name if created successfully. If the wallet was created using a full path, the wallet_name will be the full path.\n" 2454 " \"warning\" : <warning>, (string) Warning message if wallet was not loaded cleanly.\n" 2463 std::string warning;
2465 bool disable_privatekeys =
false;
2470 fs::path wallet_path = fs::absolute(wallet_name,
GetWalletDir());
2471 if (fs::symlink_status(wallet_path).type() != fs::file_not_found) {
2486 wallet->postInitProcess();
2489 obj.pushKV(
"name", wallet->GetName());
2490 obj.pushKV(
"warning", warning);
2498 throw std::runtime_error(
2499 "unloadwallet ( \"wallet_name\" )\n" 2500 "Unloads the wallet referenced by the request endpoint otherwise unloads the wallet specified in the argument.\n" 2501 "Specifying the wallet name on a wallet endpoint is invalid." 2503 "1. \"wallet_name\" (string, optional) The name of the wallet to unload.\n" 2510 std::string wallet_name;
2519 std::shared_ptr<CWallet> wallet =
GetWallet(wallet_name);
2535 wallet->NotifyUnload();
2547 CWallet*
const pwallet = wallet.get();
2554 throw std::runtime_error(
2555 "resendwallettransactions\n" 2556 "Immediately re-broadcast unconfirmed wallet transactions to all peers.\n" 2557 "Intended only for testing; the wallet code periodically re-broadcasts\n" 2559 "Returns an RPC error if -walletbroadcast is set to false.\n" 2560 "Returns array of transaction ids that were re-broadcast.\n" 2574 for (
const uint256& txid : txids)
2576 result.push_back(txid.ToString());
2584 CWallet*
const pwallet = wallet.get();
2591 throw std::runtime_error(
2592 "listunspent ( minconf maxconf [\"addresses\",...] [include_unsafe] [query_options])\n" 2593 "\nReturns array of unspent transaction outputs\n" 2594 "with between minconf and maxconf (inclusive) confirmations.\n" 2595 "Optionally filter to only include txouts paid to specified addresses.\n" 2597 "1. minconf (numeric, optional, default=1) The minimum confirmations to filter\n" 2598 "2. maxconf (numeric, optional, default=9999999) The maximum confirmations to filter\n" 2599 "3. \"addresses\" (string) A json array of bitcoin addresses to filter\n" 2601 " \"address\" (string) bitcoin address\n" 2604 "4. include_unsafe (bool, optional, default=true) Include outputs that are not safe to spend\n" 2605 " See description of \"safe\" attribute below.\n" 2606 "5. query_options (json, optional) JSON with query options\n" 2608 " \"minimumAmount\" (numeric or string, default=0) Minimum value of each UTXO in " +
CURRENCY_UNIT +
"\n" 2609 " \"maximumAmount\" (numeric or string, default=unlimited) Maximum value of each UTXO in " +
CURRENCY_UNIT +
"\n" 2610 " \"maximumCount\" (numeric or string, default=unlimited) Maximum number of UTXOs\n" 2611 " \"minimumSumAmount\" (numeric or string, default=unlimited) Minimum sum value of all UTXOs in " +
CURRENCY_UNIT +
"\n" 2614 "[ (array of json object)\n" 2616 " \"txid\" : \"txid\", (string) the transaction id \n" 2617 " \"vout\" : n, (numeric) the vout value\n" 2618 " \"address\" : \"address\", (string) the bitcoin address\n" 2619 " \"label\" : \"label\", (string) The associated label, or \"\" for the default label\n" 2620 " \"scriptPubKey\" : \"key\", (string) the script key\n" 2621 " \"amount\" : x.xxx, (numeric) the transaction output amount in " +
CURRENCY_UNIT +
"\n" 2622 " \"confirmations\" : n, (numeric) The number of confirmations\n" 2623 " \"redeemScript\" : n (string) The redeemScript if scriptPubKey is P2SH\n" 2624 " \"spendable\" : xxx, (bool) Whether we have the private keys to spend this output\n" 2625 " \"solvable\" : xxx, (bool) Whether we know how to spend this output, ignoring the lack of keys\n" 2626 " \"safe\" : xxx (bool) Whether this output is considered safe to spend. Unconfirmed transactions\n" 2627 " from outside keys and unconfirmed replacement transactions are considered unsafe\n" 2628 " and are not eligible for spending by fundrawtransaction and sendtoaddress.\n" 2635 +
HelpExampleCli(
"listunspent",
"6 9999999 \"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\",\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"")
2636 +
HelpExampleRpc(
"listunspent",
"6, 9999999 \"[\\\"1PGFqEzfmQch1gKD3ra4k18PNj3tTUUSqg\\\",\\\"1LtvqCaApEdUGFkpKMM4MstjcaL4dKg8SP\\\"]\"")
2637 +
HelpExampleCli(
"listunspent",
"6 9999999 '[]' true '{ \"minimumAmount\": 0.005 }'")
2638 +
HelpExampleRpc(
"listunspent",
"6, 9999999, [] , true, { \"minimumAmount\": 0.005 } ")
2647 int nMaxDepth = 9999999;
2653 std::set<CTxDestination> destinations;
2657 for (
unsigned int idx = 0; idx < inputs.
size(); idx++) {
2658 const UniValue& input = inputs[idx];
2663 if (!destinations.insert(dest).second) {
2669 bool include_unsafe =
true;
2676 CAmount nMaximumAmount = MAX_MONEY;
2677 CAmount nMinimumSumAmount = MAX_MONEY;
2678 uint64_t nMaximumCount = 0;
2683 if (options.
exists(
"minimumAmount"))
2686 if (options.
exists(
"maximumAmount"))
2689 if (options.
exists(
"minimumSumAmount"))
2692 if (options.
exists(
"maximumCount"))
2693 nMaximumCount = options[
"maximumCount"].get_int64();
2701 std::vector<COutput> vecOutputs;
2704 pwallet->
AvailableCoins(vecOutputs, !include_unsafe,
nullptr, nMinimumAmount, nMaximumAmount, nMinimumSumAmount, nMaximumCount, nMinDepth, nMaxDepth);
2709 for (
const COutput& out : vecOutputs) {
2711 const CScript& scriptPubKey = out.tx->tx->vout[out.i].scriptPubKey;
2714 if (destinations.size() && (!fValidAddress || !destinations.count(address)))
2718 entry.
pushKV(
"txid", out.tx->GetHash().GetHex());
2719 entry.
pushKV(
"vout", out.i);
2721 if (fValidAddress) {
2726 entry.
pushKV(
"label", i->second.name);
2730 const CScriptID& hash = boost::get<CScriptID>(address);
2732 if (pwallet->
GetCScript(hash, redeemScript)) {
2733 entry.
pushKV(
"redeemScript",
HexStr(redeemScript.begin(), redeemScript.end()));
2740 entry.
pushKV(
"confirmations", out.nDepth);
2741 entry.
pushKV(
"spendable", out.fSpendable);
2742 entry.
pushKV(
"solvable", out.fSolvable);
2743 entry.
pushKV(
"safe", out.fSafe);
2744 results.push_back(entry);
2757 change_position = -1;
2758 bool lockUnspents =
false;
2760 std::set<int> setSubtractFeeFromOutputs;
2784 if (options.
exists(
"changeAddress")) {
2794 if (options.
exists(
"changePosition"))
2795 change_position = options[
"changePosition"].get_int();
2797 if (options.
exists(
"change_type")) {
2798 if (options.
exists(
"changeAddress")) {
2807 if (options.
exists(
"includeWatching"))
2810 if (options.
exists(
"lockUnspents"))
2811 lockUnspents = options[
"lockUnspents"].get_bool();
2813 if (options.
exists(
"feeRate"))
2819 if (options.
exists(
"subtractFeeFromOutputs"))
2820 subtractFeeFromOutputs = options[
"subtractFeeFromOutputs"].get_array();
2822 if (options.
exists(
"replaceable")) {
2825 if (options.
exists(
"conf_target")) {
2826 if (options.
exists(
"feeRate")) {
2831 if (options.
exists(
"estimate_mode")) {
2832 if (options.
exists(
"feeRate")) {
2842 if (tx.
vout.size() == 0)
2845 if (change_position != -1 && (change_position < 0 || (
unsigned int)change_position > tx.
vout.size()))
2848 for (
unsigned int idx = 0; idx < subtractFeeFromOutputs.
size(); idx++) {
2849 int pos = subtractFeeFromOutputs[idx].
get_int();
2850 if (setSubtractFeeFromOutputs.count(pos))
2854 if (pos >=
int(tx.
vout.size()))
2856 setSubtractFeeFromOutputs.insert(pos);
2859 std::string strFailReason;
2861 if (!pwallet->
FundTransaction(tx, fee_out, change_position, strFailReason, lockUnspents, setSubtractFeeFromOutputs, coinControl)) {
2869 CWallet*
const pwallet = wallet.get();
2876 throw std::runtime_error(
2877 "fundrawtransaction \"hexstring\" ( options iswitness )\n" 2878 "\nAdd inputs to a transaction until it has enough in value to meet its out value.\n" 2879 "This will not modify existing inputs, and will add at most one change output to the outputs.\n" 2880 "No existing outputs will be modified unless \"subtractFeeFromOutputs\" is specified.\n" 2881 "Note that inputs which were signed may need to be resigned after completion since in/outputs have been added.\n" 2882 "The inputs added will not be signed, use signrawtransaction for that.\n" 2883 "Note that all existing inputs must have their previous output transaction be in the wallet.\n" 2884 "Note that all inputs selected must be of standard form and P2SH scripts must be\n" 2885 "in the wallet using importaddress or addmultisigaddress (to calculate fees).\n" 2886 "You can see whether this is the case by checking the \"solvable\" field in the listunspent output.\n" 2887 "Only pay-to-pubkey, multisig, and P2SH versions thereof are currently supported for watch-only\n" 2889 "1. \"hexstring\" (string, required) The hex string of the raw transaction\n" 2890 "2. options (object, optional)\n" 2892 " \"changeAddress\" (string, optional, default pool address) The bitcoin address to receive the change\n" 2893 " \"changePosition\" (numeric, optional, default random) The index of the change output\n" 2894 " \"change_type\" (string, optional) The output type to use. Only valid if changeAddress is not specified. Options are \"legacy\", \"p2sh-segwit\", and \"bech32\". Default is set by -changetype.\n" 2895 " \"includeWatching\" (boolean, optional, default false) Also select inputs which are watch only\n" 2896 " \"lockUnspents\" (boolean, optional, default false) Lock selected unspent outputs\n" 2897 " \"feeRate\" (numeric, optional, default not set: makes wallet determine the fee) Set a specific fee rate in " +
CURRENCY_UNIT +
"/kB\n" 2898 " \"subtractFeeFromOutputs\" (array, optional) A json array of integers.\n" 2899 " The fee will be equally deducted from the amount of each specified output.\n" 2900 " The outputs are specified by their zero-based index, before any change output is added.\n" 2901 " Those recipients will receive less bitcoins than you enter in their corresponding amount field.\n" 2902 " If no outputs are specified here, the sender pays the fee.\n" 2903 " [vout_index,...]\n" 2904 " \"replaceable\" (boolean, optional) Marks this transaction as BIP125 replaceable.\n" 2905 " Allows this transaction to be replaced by a transaction with higher fees\n" 2906 " \"conf_target\" (numeric, optional) Confirmation target (in blocks)\n" 2907 " \"estimate_mode\" (string, optional, default=UNSET) The fee estimate mode, must be one of:\n" 2910 " \"CONSERVATIVE\"\n" 2912 " for backward compatibility: passing in a true instead of an object will result in {\"includeWatching\":true}\n" 2913 "3. iswitness (boolean, optional) Whether the transaction hex is a serialized witness transaction \n" 2914 " If iswitness is not present, heuristic tests will be used in decoding\n" 2918 " \"hex\": \"value\", (string) The resulting raw transaction (hex-encoded string)\n" 2919 " \"fee\": n, (numeric) Fee in " +
CURRENCY_UNIT +
" the resulting transaction pays\n" 2920 " \"changepos\": n (numeric) The position of the added change output, or -1\n" 2923 "\nCreate a transaction with no inputs\n" 2924 +
HelpExampleCli(
"createrawtransaction",
"\"[]\" \"{\\\"myaddress\\\":0.01}\"") +
2925 "\nAdd sufficient unsigned inputs to meet the output value\n" 2926 +
HelpExampleCli(
"fundrawtransaction",
"\"rawtransactionhex\"") +
2927 "\nSign the transaction\n" 2928 +
HelpExampleCli(
"signrawtransaction",
"\"fundedtransactionhex\"") +
2929 "\nSend the transaction\n" 2930 +
HelpExampleCli(
"sendrawtransaction",
"\"signedtransactionhex\"")
2944 int change_position;
2950 result.pushKV(
"changepos", change_position);
2958 CWallet*
const pwallet = wallet.get();
2965 throw std::runtime_error(
2966 "signrawtransactionwithwallet \"hexstring\" ( [{\"txid\":\"id\",\"vout\":n,\"scriptPubKey\":\"hex\",\"redeemScript\":\"hex\"},...] sighashtype )\n" 2967 "\nSign inputs for raw transaction (serialized, hex-encoded).\n" 2968 "The second optional argument (may be null) is an array of previous transaction outputs that\n" 2969 "this transaction depends on but may not yet be in the block chain.\n" 2973 "1. \"hexstring\" (string, required) The transaction hex string\n" 2974 "2. \"prevtxs\" (string, optional) An json array of previous dependent transaction outputs\n" 2975 " [ (json array of json objects, or 'null' if none provided)\n" 2977 " \"txid\":\"id\", (string, required) The transaction id\n" 2978 " \"vout\":n, (numeric, required) The output number\n" 2979 " \"scriptPubKey\": \"hex\", (string, required) script key\n" 2980 " \"redeemScript\": \"hex\", (string, required for P2SH or P2WSH) redeem script\n" 2981 " \"amount\": value (numeric, required) The amount spent\n" 2985 "3. \"sighashtype\" (string, optional, default=ALL) The signature hash type. Must be one of\n" 2989 " \"ALL|ANYONECANPAY\"\n" 2990 " \"NONE|ANYONECANPAY\"\n" 2991 " \"SINGLE|ANYONECANPAY\"\n" 2995 " \"hex\" : \"value\", (string) The hex-encoded raw transaction with signature(s)\n" 2996 " \"complete\" : true|false, (boolean) If the transaction has a complete set of signatures\n" 2997 " \"errors\" : [ (json array of objects) Script verification errors (if there are any)\n" 2999 " \"txid\" : \"hash\", (string) The hash of the referenced, previous transaction\n" 3000 " \"vout\" : n, (numeric) The index of the output to spent and used as input\n" 3001 " \"scriptSig\" : \"hex\", (string) The hex-encoded signature script\n" 3002 " \"sequence\" : n, (numeric) Script sequence number\n" 3003 " \"error\" : \"text\" (string) Verification or signing error related to the input\n" 3014 RPCTypeCheck(request.
params, {UniValue::VSTR, UniValue::VARR, UniValue::VSTR},
true);
3031 CWallet*
const pwallet = wallet.get();
3038 throw std::runtime_error(
3039 "bumpfee \"txid\" ( options ) \n" 3040 "\nBumps the fee of an opt-in-RBF transaction T, replacing it with a new transaction B.\n" 3041 "An opt-in RBF transaction with the given txid must be in the wallet.\n" 3042 "The command will pay the additional fee by decreasing (or perhaps removing) its change output.\n" 3043 "If the change output is not big enough to cover the increased fee, the command will currently fail\n" 3044 "instead of adding new inputs to compensate. (A future implementation could improve this.)\n" 3045 "The command will fail if the wallet or mempool contains a transaction that spends one of T's outputs.\n" 3046 "By default, the new fee will be calculated automatically using estimatesmartfee.\n" 3047 "The user can specify a confirmation target for estimatesmartfee.\n" 3048 "Alternatively, the user can specify totalFee, or use RPC settxfee to set a higher fee rate.\n" 3049 "At a minimum, the new fee rate must be high enough to pay an additional new relay fee (incrementalfee\n" 3050 "returned by getnetworkinfo) to enter the node's mempool.\n" 3052 "1. txid (string, required) The txid to be bumped\n" 3053 "2. options (object, optional)\n" 3055 " \"confTarget\" (numeric, optional) Confirmation target (in blocks)\n" 3056 " \"totalFee\" (numeric, optional) Total fee (NOT feerate) to pay, in satoshis.\n" 3057 " In rare cases, the actual fee paid might be slightly higher than the specified\n" 3058 " totalFee if the tx change output has to be removed because it is too close to\n" 3059 " the dust threshold.\n" 3060 " \"replaceable\" (boolean, optional, default true) Whether the new transaction should still be\n" 3061 " marked bip-125 replaceable. If true, the sequence numbers in the transaction will\n" 3062 " be left unchanged from the original. If false, any input sequence numbers in the\n" 3063 " original transaction that were less than 0xfffffffe will be increased to 0xfffffffe\n" 3064 " so the new transaction will not be explicitly bip-125 replaceable (though it may\n" 3065 " still be replaceable in practice, for example if it has unconfirmed ancestors which\n" 3066 " are replaceable).\n" 3067 " \"estimate_mode\" (string, optional, default=UNSET) The fee estimate mode, must be one of:\n" 3070 " \"CONSERVATIVE\"\n" 3074 " \"txid\": \"value\", (string) The id of the new transaction\n" 3075 " \"origfee\": n, (numeric) Fee of the replaced transaction\n" 3076 " \"fee\": n, (numeric) Fee of the new transaction\n" 3077 " \"errors\": [ str... ] (json array of strings) Errors encountered during processing (may be empty)\n" 3080 "\nBump the fee, get the new transaction\'s txid\n" +
3102 if (options.
exists(
"confTarget") && options.
exists(
"totalFee")) {
3103 throw JSONRPCError(
RPC_INVALID_PARAMETER,
"confTarget and totalFee options should not both be set. Please provide either a confirmation target for fee estimation or an explicit total fee for the transaction.");
3104 }
else if (options.
exists(
"confTarget")) {
3106 }
else if (options.
exists(
"totalFee")) {
3107 totalFee = options[
"totalFee"].
get_int64();
3108 if (totalFee <= 0) {
3113 if (options.
exists(
"replaceable")) {
3116 if (options.
exists(
"estimate_mode")) {
3131 std::vector<std::string> errors;
3166 result.pushKV(
"txid", txid.
GetHex());
3170 for (
const std::string&
error : errors) {
3171 result_errors.push_back(
error);
3173 result.pushKV(
"errors", result_errors);
3181 CWallet*
const pwallet = wallet.get();
3189 throw std::runtime_error(
3190 "generate nblocks ( maxtries )\n" 3191 "\nMine up to nblocks blocks immediately (before the RPC call returns) to an address in the wallet.\n" 3193 "1. nblocks (numeric, required) How many blocks are generated immediately.\n" 3194 "2. maxtries (numeric, optional) How many iterations to try (default = 1000000).\n" 3196 "[ blockhashes ] (array) hashes of blocks generated\n" 3198 "\nGenerate 11 blocks\n" 3205 "To use generate in v0.18, restart bsha3d with -deprecatedrpc=generate.\n" 3206 "Clients should transition to using the node rpc method generatetoaddress\n");
3210 uint64_t max_tries = 1000000;
3215 std::shared_ptr<CReserveScript> coinbase_script;
3219 if (!coinbase_script) {
3224 if (coinbase_script->reserveScript.empty()) {
3228 return generateBlocks(coinbase_script, num_generate, max_tries,
true);
3234 CWallet*
const pwallet = wallet.get();
3241 throw std::runtime_error(
3242 "rescanblockchain (\"start_height\") (\"stop_height\")\n" 3243 "\nRescan the local blockchain for wallet related transactions.\n" 3245 "1. \"start_height\" (numeric, optional) block height where the rescan should start\n" 3246 "2. \"stop_height\" (numeric, optional) the last block height that should be scanned\n" 3249 " \"start_height\" (numeric) The block height where the rescan has started. If omitted, rescan started from the genesis block.\n" 3250 " \"stop_height\" (numeric) The height of the last rescanned block. If omitted, rescan stopped at the chain tip.\n" 3292 CBlockIndex *block = pindexStop ? pindexStop : pChainTip;
3295 throw JSONRPCError(
RPC_MISC_ERROR,
"Can't rescan beyond pruned data. Use RPC call getblockchaininfo to determine your pruned height.");
3297 block = block->
pprev;
3307 stopBlock = pindexStop ? pindexStop : pChainTip;
3326 std::vector<std::vector<unsigned char>> solutions_data;
3338 UniValue wallet_detail = boost::apply_visitor(*
this, embedded);
3339 subobj.
pushKVs(wallet_detail);
3343 if (subobj.
exists(
"pubkey")) obj.
pushKV(
"pubkey", subobj[
"pubkey"]);
3344 obj.
pushKV(
"embedded", std::move(subobj));
3349 obj.
pushKV(
"sigsrequired", solutions_data[0][0]);
3351 for (
size_t i = 1; i < solutions_data.size() - 1; ++i) {
3352 CPubKey key(solutions_data[i].begin(), solutions_data[i].
end());
3356 obj.
pushKV(
"pubkeys", std::move(pubkeys));
3363 if (include_addresses) obj.
pushKV(
"addresses", std::move(a));
3440 CWallet*
const pwallet = wallet.get();
3447 throw std::runtime_error(
3448 "getaddressinfo \"address\"\n" 3449 "\nReturn information about the given bitcoin address. Some information requires the address\n" 3450 "to be in the wallet.\n" 3452 "1. \"address\" (string, required) The bitcoin address to get the information of.\n" 3455 " \"address\" : \"address\", (string) The bitcoin address validated\n" 3456 " \"scriptPubKey\" : \"hex\", (string) The hex-encoded scriptPubKey generated by the address\n" 3457 " \"ismine\" : true|false, (boolean) If the address is yours or not\n" 3458 " \"solvable\" : true|false, (boolean) If the address is solvable by the wallet\n" 3459 " \"iswatchonly\" : true|false, (boolean) If the address is watchonly\n" 3460 " \"isscript\" : true|false, (boolean) If the key is a script\n" 3461 " \"iswitness\" : true|false, (boolean) If the address is a witness address\n" 3462 " \"witness_version\" : version (numeric, optional) The version number of the witness program\n" 3463 " \"witness_program\" : \"hex\" (string, optional) The hex value of the witness program\n" 3464 " \"script\" : \"type\" (string, optional) The output script type. Only if \"isscript\" is true and the redeemscript is known. Possible types: nonstandard, pubkey, pubkeyhash, scripthash, multisig, nulldata, witness_v0_keyhash, witness_v0_scripthash, witness_unknown\n" 3465 " \"hex\" : \"hex\", (string, optional) The redeemscript for the p2sh address\n" 3466 " \"pubkeys\" (string, optional) Array of pubkeys associated with the known redeemscript (only if \"script\" is \"multisig\")\n" 3471 " \"sigsrequired\" : xxxxx (numeric, optional) Number of signatures required to spend multisig output (only if \"script\" is \"multisig\")\n" 3472 " \"pubkey\" : \"publickeyhex\", (string, optional) The hex value of the raw public key, for single-key addresses (possibly embedded in P2SH or P2WSH)\n" 3473 " \"embedded\" : {...}, (object, optional) Information about the address embedded in P2SH or P2WSH, if relevant and known. It includes all getaddressinfo output fields for the embedded address, excluding metadata (\"timestamp\", \"hdkeypath\", \"hdseedid\") and relation to the wallet (\"ismine\", \"iswatchonly\").\n" 3474 " \"iscompressed\" : true|false, (boolean) If the address is compressed\n" 3475 " \"label\" : \"label\" (string) The label associated with the address, \"\" is the default label\n" 3476 " \"timestamp\" : timestamp, (number, optional) The creation time of the key if available in seconds since epoch (Jan 1 1970 GMT)\n" 3477 " \"hdkeypath\" : \"keypath\" (string, optional) The HD keypath if the key is HD and available\n" 3478 " \"hdseedid\" : \"<hash360>\" (string, optional) The Hash360 of the HD seed\n" 3479 " \"hdmasterkeyid\" : \"<hash360>\" (string, optional) alias for hdseedid maintained for backwards compatibility. Will be removed in V0.18.\n" 3480 " \"labels\" (object) Array of labels associated with the address.\n" 3482 " { (json object of label data)\n" 3483 " \"name\": \"labelname\" (string) The label\n" 3484 " \"purpose\": \"string\" (string) Purpose of address (\"send\" for sending address, \"receive\" for receiving address)\n" 3489 +
HelpExampleCli(
"getaddressinfo",
"\"1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc\"")
3490 +
HelpExampleRpc(
"getaddressinfo",
"\"1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc\"")
3514 UniValue detail = DescribeWalletAddress(pwallet, dest);
3522 auto it = pwallet->mapKeyMetadata.find(key_id);
3523 if (it != pwallet->mapKeyMetadata.end()) {
3528 auto it = pwallet->m_script_metadata.find(
CScriptID(scriptPubKey));
3529 if (it != pwallet->m_script_metadata.end()) {
3546 std::map<CTxDestination, CAddressBookData>::iterator mi = pwallet->
mapAddressBook.find(dest);
3548 labels.
push_back(AddressBookDataToJSON(mi->second,
true));
3550 ret.
pushKV(
"labels", std::move(labels));
3558 CWallet*
const pwallet = wallet.get();
3565 throw std::runtime_error(
3566 "getaddressesbylabel \"label\"\n" 3567 "\nReturns the list of addresses assigned the specified label.\n" 3569 "1. \"label\" (string, required) The label.\n" 3571 "{ (json object with addresses as keys)\n" 3572 " \"address\": { (json object with information about address)\n" 3573 " \"purpose\": \"string\" (string) Purpose of address (\"send\" for sending address, \"receive\" for receiving address)\n" 3583 std::string label = LabelFromValue(request.
params[0]);
3587 for (
const std::pair<const CTxDestination, CAddressBookData>& item : pwallet->
mapAddressBook) {
3588 if (item.second.name == label) {
3603 CWallet*
const pwallet = wallet.get();
3610 throw std::runtime_error(
3611 "listlabels ( \"purpose\" )\n" 3612 "\nReturns the list of all labels, or labels that are assigned to addresses with a specific purpose.\n" 3614 "1. \"purpose\" (string, optional) Address purpose to list labels for ('send','receive'). An empty string is the same as not providing this argument.\n" 3616 "[ (json array of string)\n" 3617 " \"label\", (string) Label name\n" 3621 "\nList all labels\n" 3623 "\nList labels that have receiving addresses\n" 3625 "\nList labels that have sending addresses\n" 3627 "\nAs a JSON-RPC call\n" 3633 std::string purpose;
3639 std::set<std::string> label_set;
3640 for (
const std::pair<const CTxDestination, CAddressBookData>& entry : pwallet->
mapAddressBook) {
3641 if (purpose.empty() || entry.second.purpose == purpose) {
3642 label_set.insert(entry.second.name);
3647 for (
const std::string&
name : label_set) {
3657 CWallet*
const pwallet = wallet.get();
3664 throw std::runtime_error(
3665 "sethdseed ( \"newkeypool\" \"seed\" )\n" 3666 "\nSet or generate a new HD wallet seed. Non-HD wallets will not be upgraded to being a HD wallet. Wallets that are already\n" 3667 "HD will have a new HD seed set so that new keys added to the keypool will be derived from this new seed.\n" 3668 "\nNote that you will need to MAKE A NEW BACKUP of your wallet after setting the HD wallet seed.\n" 3671 "1. \"newkeypool\" (boolean, optional, default=true) Whether to flush old unused addresses, including change addresses, from the keypool and regenerate it.\n" 3672 " If true, the next address from getnewaddress and change address from getrawchangeaddress will be from this new seed.\n" 3673 " If false, addresses (including change addresses if the wallet already had HD Chain Split enabled) from the existing\n" 3674 " keypool will be used until it has been depleted.\n" 3675 "2. \"seed\" (string, optional) The WIF private key to use as the new HD seed; if not provided a random seed will be used.\n" 3676 " The seed value can be retrieved using the dumpwallet command. It is the private key marked hdseed=1\n" 3693 throw JSONRPCError(
RPC_WALLET_ERROR,
"Cannot set a HD seed on a non-HD wallet. Start with -upgradewallet in order to upgrade a non-HD wallet to HD");
3698 bool flush_key_pool =
true;
3728 if (!pwallet->
GetPubKey(keyID, vchPubKey)) {
3735 hd_keypaths.emplace(vchPubKey, std::move(info));
3742 bool complete =
true;
3743 for (
unsigned int i = 0; i < txConst->
vin.size(); ++i) {
3744 const CTxIn& txin = txConst->
vin[i];
3749 const auto it = pwallet->mapWallet.find(txhash);
3750 if (it != pwallet->mapWallet.end()) {
3767 for (
unsigned int i = 0; i < txConst->
vout.size(); ++i) {
3785 CWallet*
const pwallet = wallet.get();
3792 throw std::runtime_error(
3793 "walletprocesspsbt \"psbt\" ( sign \"sighashtype\" bip32derivs )\n" 3794 "\nUpdate a PSBT with input information from our wallet and then sign inputs\n" 3795 "that we can sign for.\n" 3799 "1. \"psbt\" (string, required) The transaction base64 string\n" 3800 "2. sign (boolean, optional, default=true) Also sign the transaction when updating\n" 3801 "3. \"sighashtype\" (string, optional, default=ALL) The signature hash type to sign with if not specified by the PSBT. Must be one of\n" 3805 " \"ALL|ANYONECANPAY\"\n" 3806 " \"NONE|ANYONECANPAY\"\n" 3807 " \"SINGLE|ANYONECANPAY\"\n" 3808 "4. bip32derivs (boolean, optional, default=false) If true, includes the BIP 32 derivation paths for public keys if we know them\n" 3812 " \"psbt\" : \"value\", (string) The base64-encoded partially signed transaction\n" 3813 " \"complete\" : true|false, (boolean) If the transaction has a complete set of signatures\n" 3840 bool complete =
FillPSBT(pwallet, psbtx, &txConst, nHashType, sign, bip32derivs);
3846 result.
pushKV(
"complete", complete);
3854 CWallet*
const pwallet = wallet.get();
3861 throw std::runtime_error(
3862 "walletcreatefundedpsbt [{\"txid\":\"id\",\"vout\":n},...] [{\"address\":amount},{\"data\":\"hex\"},...] ( locktime ) ( replaceable ) ( options bip32derivs )\n" 3863 "\nCreates and funds a transaction in the Partially Signed Transaction format. Inputs will be added if supplied inputs are not enough\n" 3864 "Implements the Creator and Updater roles.\n" 3866 "1. \"inputs\" (array, required) A json array of json objects\n" 3869 " \"txid\":\"id\", (string, required) The transaction id\n" 3870 " \"vout\":n, (numeric, required) The output number\n" 3871 " \"sequence\":n (numeric, optional) The sequence number\n" 3875 "2. \"outputs\" (array, required) a json array with outputs (key-value pairs)\n" 3878 " \"address\": x.xxx, (obj, optional) A key-value pair. The key (string) is the bitcoin address, the value (float or string) is the amount in " +
CURRENCY_UNIT +
"\n" 3881 " \"data\": \"hex\" (obj, optional) A key-value pair. The key must be \"data\", the value is hex-encoded data\n" 3883 " ,... More key-value pairs of the above form. For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also\n" 3884 " accepted as second parameter.\n" 3886 "3. locktime (numeric, optional, default=0) Raw locktime. Non-0 value also locktime-activates inputs\n" 3887 " Allows this transaction to be replaced by a transaction with higher fees. If provided, it is an error if explicit sequence numbers are incompatible.\n" 3888 "4. options (object, optional)\n" 3890 " \"changeAddress\" (string, optional, default pool address) The bitcoin address to receive the change\n" 3891 " \"changePosition\" (numeric, optional, default random) The index of the change output\n" 3892 " \"change_type\" (string, optional) The output type to use. Only valid if changeAddress is not specified. Options are \"legacy\", \"p2sh-segwit\", and \"bech32\". Default is set by -changetype.\n" 3893 " \"includeWatching\" (boolean, optional, default false) Also select inputs which are watch only\n" 3894 " \"lockUnspents\" (boolean, optional, default false) Lock selected unspent outputs\n" 3895 " \"feeRate\" (numeric, optional, default not set: makes wallet determine the fee) Set a specific fee rate in " +
CURRENCY_UNIT +
"/kB\n" 3896 " \"subtractFeeFromOutputs\" (array, optional) A json array of integers.\n" 3897 " The fee will be equally deducted from the amount of each specified output.\n" 3898 " The outputs are specified by their zero-based index, before any change output is added.\n" 3899 " Those recipients will receive less bitcoins than you enter in their corresponding amount field.\n" 3900 " If no outputs are specified here, the sender pays the fee.\n" 3901 " [vout_index,...]\n" 3902 " \"replaceable\" (boolean, optional) Marks this transaction as BIP125 replaceable.\n" 3903 " Allows this transaction to be replaced by a transaction with higher fees\n" 3904 " \"conf_target\" (numeric, optional) Confirmation target (in blocks)\n" 3905 " \"estimate_mode\" (string, optional, default=UNSET) The fee estimate mode, must be one of:\n" 3908 " \"CONSERVATIVE\"\n" 3910 "5. bip32derivs (boolean, optional, default=false) If true, includes the BIP 32 derivation paths for public keys if we know them\n" 3913 " \"psbt\": \"value\", (string) The resulting raw transaction (base64-encoded string)\n" 3914 " \"fee\": n, (numeric) Fee in " +
CURRENCY_UNIT +
" the resulting transaction pays\n" 3915 " \"changepos\": n (numeric) The position of the added change output, or -1\n" 3918 "\nCreate a transaction with no inputs\n" 3919 +
HelpExampleCli(
"walletcreatefundedpsbt",
"\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
3932 int change_position;
3939 for (
unsigned int i = 0; i < rawTx.
vin.size(); ++i) {
3942 for (
unsigned int i = 0; i < rawTx.
vout.size(); ++i) {
3952 FillPSBT(pwallet, psbtx, &txConst, 1,
false, bip32derivs);
3961 result.
pushKV(
"changepos", change_position);
3980 {
"generating",
"generate", &
generate, {
"nblocks",
"maxtries"} },
3981 {
"hidden",
"resendwallettransactions", &resendwallettransactions, {} },
3982 {
"rawtransactions",
"fundrawtransaction", &fundrawtransaction, {
"hexstring",
"options",
"iswitness"} },
3983 {
"wallet",
"abandontransaction", &abandontransaction, {
"txid"} },
3985 {
"wallet",
"addmultisigaddress", &addmultisigaddress, {
"nrequired",
"keys",
"label",
"address_type"} },
3986 {
"wallet",
"backupwallet", &backupwallet, {
"destination"} },
3987 {
"wallet",
"bumpfee", &bumpfee, {
"txid",
"options"} },
3988 {
"wallet",
"createwallet", &createwallet, {
"wallet_name",
"disable_private_keys"} },
3989 {
"wallet",
"dumpprivkey", &
dumpprivkey, {
"address"} },
3990 {
"wallet",
"dumpwallet", &
dumpwallet, {
"filename"} },
3991 {
"wallet",
"encryptwallet", &encryptwallet, {
"passphrase"} },
3992 {
"wallet",
"getaddressesbylabel", &getaddressesbylabel, {
"label"} },
3994 {
"wallet",
"getbalance", &getbalance, {
"dummy",
"minconf",
"include_watchonly"} },
3995 {
"wallet",
"getnewaddress", &getnewaddress, {
"label",
"address_type"} },
3996 {
"wallet",
"getrawchangeaddress", &getrawchangeaddress, {
"address_type"} },
3997 {
"wallet",
"getreceivedbyaddress", &getreceivedbyaddress, {
"address",
"minconf"} },
3998 {
"wallet",
"getreceivedbylabel", &getreceivedbylabel, {
"label",
"minconf"} },
3999 {
"wallet",
"gettransaction", &gettransaction, {
"txid",
"include_watchonly"} },
4000 {
"wallet",
"getunconfirmedbalance", &getunconfirmedbalance, {} },
4001 {
"wallet",
"getwalletinfo", &getwalletinfo, {} },
4002 {
"wallet",
"importaddress", &
importaddress, {
"address",
"label",
"rescan",
"p2sh"} },
4003 {
"wallet",
"importmulti", &
importmulti, {
"requests",
"options"} },
4004 {
"wallet",
"importprivkey", &
importprivkey, {
"privkey",
"label",
"rescan"} },
4005 {
"wallet",
"importprunedfunds", &
importprunedfunds, {
"rawtransaction",
"txoutproof"} },
4006 {
"wallet",
"importpubkey", &
importpubkey, {
"pubkey",
"label",
"rescan"} },
4007 {
"wallet",
"importwallet", &
importwallet, {
"filename"} },
4008 {
"wallet",
"keypoolrefill", &keypoolrefill, {
"newsize"} },
4009 {
"wallet",
"listaddressgroupings", &listaddressgroupings, {} },
4010 {
"wallet",
"listlabels", &listlabels, {
"purpose"} },
4011 {
"wallet",
"listlockunspent", &listlockunspent, {} },
4012 {
"wallet",
"listreceivedbyaddress", &listreceivedbyaddress, {
"minconf",
"include_empty",
"include_watchonly",
"address_filter"} },
4013 {
"wallet",
"listreceivedbylabel", &listreceivedbylabel, {
"minconf",
"include_empty",
"include_watchonly"} },
4014 {
"wallet",
"listsinceblock", &listsinceblock, {
"blockhash",
"target_confirmations",
"include_watchonly",
"include_removed"} },
4015 {
"wallet",
"listtransactions", &
listtransactions, {
"dummy",
"count",
"skip",
"include_watchonly"} },
4016 {
"wallet",
"listunspent", &listunspent, {
"minconf",
"maxconf",
"addresses",
"include_unsafe",
"query_options"} },
4017 {
"wallet",
"listwalletdir", &listwalletdir, {} },
4018 {
"wallet",
"listwallets", &listwallets, {} },
4019 {
"wallet",
"loadwallet", &loadwallet, {
"filename"} },
4020 {
"wallet",
"lockunspent", &lockunspent, {
"unlock",
"transactions"} },
4022 {
"wallet",
"rescanblockchain", &
rescanblockchain, {
"start_height",
"stop_height"} },
4023 {
"wallet",
"sendmany", &sendmany, {
"dummy",
"amounts",
"minconf",
"comment",
"subtractfeefrom",
"replaceable",
"conf_target",
"estimate_mode"} },
4024 {
"wallet",
"sendtoaddress", &sendtoaddress, {
"address",
"amount",
"comment",
"comment_to",
"subtractfeefromamount",
"replaceable",
"conf_target",
"estimate_mode"} },
4025 {
"wallet",
"sethdseed", &
sethdseed, {
"newkeypool",
"seed"} },
4026 {
"wallet",
"setlabel", &setlabel, {
"address",
"label"} },
4027 {
"wallet",
"settxfee", &settxfee, {
"amount"} },
4028 {
"wallet",
"signmessage", &signmessage, {
"address",
"message"} },
4030 {
"wallet",
"unloadwallet", &unloadwallet, {
"wallet_name"} },
4031 {
"wallet",
"walletcreatefundedpsbt", &
walletcreatefundedpsbt, {
"inputs",
"outputs",
"locktime",
"options",
"bip32derivs"} },
4032 {
"wallet",
"walletlock", &walletlock, {} },
4033 {
"wallet",
"walletpassphrase", &walletpassphrase, {
"passphrase",
"timeout"} },
4034 {
"wallet",
"walletpassphrasechange", &walletpassphrasechange, {
"oldpassphrase",
"newpassphrase"} },
4035 {
"wallet",
"walletprocesspsbt", &
walletprocesspsbt, {
"psbt",
"sign",
"sighashtype",
"bip32derivs"} },
4041 for (
unsigned int vcidx = 0; vcidx <
ARRAYLEN(commands); vcidx++)
No wallet specified (error when there are multiple wallets loaded)
void RPCTypeCheckObj(const UniValue &o, const std::map< std::string, UniValueType > &typesExpected, bool fAllowNull, bool fStrict)
uint256 ParseHashO(const UniValue &o, std::string strKey)
CScript CreateMultisigRedeemscript(const int required, const std::vector< CPubKey > &pubkeys)
CPubKey AddrToPubKey(CKeyStore *const keystore, const std::string &addr_in)
Result CreateTransaction(const CWallet *wallet, const uint256 &txid, const CCoinControl &coin_control, CAmount total_fee, std::vector< std::string > &errors, CAmount &old_fee, CAmount &new_fee, CMutableTransaction &mtx)
Create bumpfee transaction.
std::map< CTxDestination, tallyitem > mapTally
OutputType m_default_change_type
std::set< std::set< CTxDestination > > GetAddressGroupings() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool fPruneMode
True if we're running in -prune mode.
UniValue operator()(const CNoDestination &dest) const
CAmount GetImmatureBalance() const
const std::vector< UniValue > & getValues() const
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
bool GetWalletNameFromJSONRPCRequest(const JSONRPCRequest &request, std::string &wallet_name)
Keypool ran out, call keypoolrefill first.
int64_t GetOldestKeyPoolTime()
UniValue importwallet(const JSONRPCRequest &request)
bool fAllowWatchOnly
Includes watch only addresses which are solvable.
static bool Verify(std::string wallet_file, bool salvage_wallet, std::string &error_string, std::string &warning_string)
Verify wallet naming and perform salvage on the wallet if required.
std::map< std::string, std::string > mapValue_t
bool CanSupportFeature(enum WalletFeature wf) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
check whether we are allowed to upgrade (or already support) to the named feature ...
Enter the wallet passphrase with walletpassphrase first.
Bitcoin RPC command dispatcher.
void AvailableCoins(std::vector< COutput > &vCoins, bool fOnlySafe=true, const CCoinControl *coinControl=nullptr, const CAmount &nMinimumAmount=1, const CAmount &nMaximumAmount=MAX_MONEY, const CAmount &nMinimumSumAmount=MAX_MONEY, const uint64_t nMaximumCount=0, const int nMinDepth=0, const int nMaxDepth=9999999) const EXCLUSIVE_LOCKS_REQUIRED(cs_main
populate vCoins with vector of available COutputs.
int64_t GetBlockTime() const
bool FeeModeFromString(const std::string &mode_string, FeeEstimateMode &fee_estimate_mode)
std::vector< std::shared_ptr< CWallet > > GetWallets()
CBlockIndex * pprev
pointer to the index of the predecessor of this block
void UnlockCoin(const COutPoint &output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
uint32_t nStatus
Verification status of this block. See enum BlockStatus.
std::shared_ptr< CWallet > GetWallet(const std::string &name)
UniValue operator()(const WitnessV0ScriptHash &id) const
boost::optional< CMutableTransaction > tx
bool HaveKey(const CKeyStore &store, const CKey &key)
Checks if a CKey is in the given CKeyStore compressed or otherwise.
boost::optional< unsigned int > m_confirm_target
Override the default confirmation target if set.
std::map< CTxDestination, CAddressBookData > mapAddressBook
bool IsValidDestinationString(const std::string &str, const CChainParams ¶ms)
std::map< std::string, tallyitem > label_tally
bool IsPayToScriptHash() const
bool AddWallet(const std::shared_ptr< CWallet > &wallet)
const uint256 & GetHash() const
bool IsFromMe(const isminefilter &filter) const
std::vector< uint256 > txids
bool EnsureWalletIsAvailable(CWallet *const pwallet, bool avoidException)
UniValue ret(UniValue::VARR)
UniValue getaddressinfo(const JSONRPCRequest &request)
CAmount GetDebit(const isminefilter &filter) const
filter decides which addresses will count towards the debit
std::string urlDecode(const std::string &urlEncoded)
bool GetCScript(const CScriptID &hash, CScript &redeemScriptOut) const override
bool FundTransaction(CMutableTransaction &tx, CAmount &nFeeRet, int &nChangePosInOut, std::string &strFailReason, bool lockUnspents, const std::set< int > &setSubtractFeeFromOutputs, CCoinControl)
Insert additional inputs into the transaction by calling CreateTransaction();.
int Height() const
Return the maximal height in the chain.
bool CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::vector< std::pair< std::string, std::string >> orderForm, CReserveKey &reservekey, CConnman *connman, CValidationState &state)
Call after CreateTransaction unless you want to abort.
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
UniValue ValueFromAmount(const CAmount &amount)
size_t KeypoolCountExternalKeys() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
CPubKey HexToPubKey(const std::string &hex_in)
UniValue DescribeAddress(const CTxDestination &dest)
CKeyID GetKeyForDestination(const CKeyStore &store, const CTxDestination &dest)
Return the CKeyID of the key involved in a script (if there is a unique one).
boost::optional< OutputType > m_change_type
Override the default change type if set, ignored if destChange is set.
const std::string & get_str() const
uint8_t isminefilter
used for bitflags of isminetype
CBlockIndex * Genesis() const
Returns the index entry for the genesis block of this chain, or nullptr if none.
bool IsWalletFlagSet(uint64_t flag)
check if a certain wallet flag is set
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
const UniValue & get_array() const
CAmount GetLegacyBalance(const isminefilter &filter, int minDepth) const
const std::string CURRENCY_UNIT
txnouttype Solver(const CScript &scriptPubKey, std::vector< std::vector< unsigned char >> &vSolutionsRet)
Parse a scriptPubKey and identify script type for standard scripts.
A version of CTransaction with the PSBT format.
Double ended buffer combining vector and stream-like interfaces.
int64_t get_int64() const
bool GetKeyOrigin(const CKeyID &keyid, KeyOriginInfo &info) const override
Implement lookup of key origin information through wallet key metadata.
void UnregisterValidationInterface(CValidationInterface *pwalletIn)
Unregister a wallet from core.
A signature creator for transactions.
bool pushKVs(const UniValue &obj)
const std::vector< std::string > & getKeys() const
void RPCRunLater(const std::string &name, std::function< void()> func, int64_t nSeconds)
Run func nSeconds from now.
bool EncryptWallet(const SecureString &strWalletPassphrase)
std::shared_ptr< const CTransaction > CTransactionRef
bool appendCommand(const std::string &name, const CRPCCommand *pcmd)
Appends a CRPCCommand to the dispatch table.
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
const std::string strMessageMagic
bool fOverrideFeeRate
Override automatic min/max checks on fee, m_feerate must be set if true.
const unsigned char * begin() const
std::string HelpRequiringPassphrase(CWallet *const pwallet)
std::vector< fs::path > ListWalletDir()
Get wallets in wallet directory.
CFeeRate m_min_fee
Override with -mintxfee.
const std::vector< CTxIn > vin
Invalid, missing or duplicate parameter.
uint256 ParseHashV(const UniValue &v, std::string strName)
Utilities: convert hex-encoded Values (throws error if not hex).
boost::optional< CFeeRate > m_feerate
Override the wallet's m_pay_tx_fee if set.
static std::shared_ptr< CWallet > CreateWalletFromFile(const std::string &name, const fs::path &path, uint64_t wallet_creation_flags=0)
bool GetPubKey(const CKeyID &address, CPubKey &vchPubKeyOut) const override
const UniValue & find_value(const UniValue &obj, const std::string &name)
bool DecodePSBT(PartiallySignedTransaction &psbt, const std::string &base64_tx, std::string &error)
void FromSignatureData(const SignatureData &sigdata)
UniValue generateBlocks(std::shared_ptr< CReserveScript > coinbaseScript, int nGenerate, uint64_t nMaxTries, bool keepScript)
Generate blocks (mine)
bool SignCompact(const uint256 &hash, std::vector< unsigned char > &vchSig) const
Create a compact signature (65 bytes), which allows reconstructing the used public key...
int64_t CAmount
Amount in satoshis (Can be negative)
uint256 GetBlockHash() const
A structure for PSBTs which contains per output information.
bool SetAddressBook(const CTxDestination &address, const std::string &strName, const std::string &purpose)
The wallet passphrase entered was incorrect.
std::vector< PSBTOutput > outputs
bool IsLockedCoin(uint256 hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
UniValue walletprocesspsbt(const JSONRPCRequest &request)
void push_back(const T &value)
UniValue signrawtransactionwithwallet(const JSONRPCRequest &request)
bool push_back(const UniValue &val)
bool SignTransaction(CWallet *wallet, CMutableTransaction &mtx)
Sign the new transaction,.
UniValue importaddress(const JSONRPCRequest &request)
bool CheckFinalTx(const CTransaction &tx, int flags)
Transaction validation functions.
CAmount GetBalance(const isminefilter &filter=ISMINE_SPENDABLE, const int min_depth=0) const
void GetAmounts(std::list< COutputEntry > &listReceived, std::list< COutputEntry > &listSent, CAmount &nFee, const isminefilter &filter) const
int GetDepthInMainChain() const EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Return depth of transaction in blockchain: <0 : conflicts with a transaction this deep in the blockch...
bool AbandonTransaction(const uint256 &hashTx)
const unsigned char * end() const
CAmount GetCredit(const isminefilter &filter) const EXCLUSIVE_LOCKS_REQUIRED(cs_main)
CFeeRate minRelayTxFee
A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation) ...
UniValue operator()(const CScriptID &scriptID) const
bool NewKeyPool()
Mark old keypool keys as used, and generate all new keys.
int ParseSighashString(const UniValue &sighash)
isminetype
IsMine() return codes.
An input of a transaction.
boost::variant< CNoDestination, CKeyID, CScriptID, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
OutputType m_default_address_type
CTxDestination subtype to encode any future Witness version.
unsigned int GetKeyPoolSize() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
CTxDestination AddAndGetDestinationForScript(CKeyStore &keystore, const CScript &script, OutputType type)
Get a destination of the requested type (if possible) to the specified script.
bool exists(const std::string &key) const
int GetVersion()
get the current wallet format (the oldest client version guaranteed to understand this wallet) ...
UniValue generate(const JSONRPCRequest &request)
CTxDestination destChange
Custom change destination, if not set an address is generated.
An encapsulated public key.
void UnlockAllCoins() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool IsHex(const std::string &str)
const std::vector< CTxOut > vout
Unexpected type was passed as parameter.
CAmount GetUnconfirmedBalance() const
Command given in wrong wallet encryption state (encrypting an encrypted wallet etc.)
bool has_filtered_address
UniValue importprunedfunds(const JSONRPCRequest &request)
bool IsInitialBlockDownload()
Check whether we are doing an initial block download (synchronizing from disk or network) ...
UniValue dumpwallet(const JSONRPCRequest &request)
void ProcessSubScript(const CScript &subscript, UniValue &obj, bool include_addresses=false) const
const char * GetTxnOutputType(txnouttype t)
Get the name of a txnouttype as a C string, or nullptr if unknown.
General application defined errors.
bool pushKV(const std::string &key, const UniValue &val)
bool GetKey(const CKeyID &address, CKey &keyOut) const override
void RPCTypeCheck(const UniValue ¶ms, const std::list< UniValueType > &typesExpected, bool fAllowNull)
Type-check arguments; throws JSONRPCError if wrong type given.
An output of a transaction.
bool IsSpent(const uint256 &hash, unsigned int n) const EXCLUSIVE_LOCKS_REQUIRED(cs_main
Outpoint is spent if any non-conflicted transaction spends it:
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
CAmount AmountFromValue(const UniValue &value)
Invalid wallet specified.
An outpoint - a combination of a transaction hash and an index n into its vout.
CCriticalSection cs_wallet
std::vector< CTxOut > vout
std::string FormatMoney(const CAmount &n)
Money parsing/formatting utilities.
std::shared_ptr< CWallet > GetWalletForJSONRPCRequest(const JSONRPCRequest &request)
Figures out what wallet, if any, to use for a JSONRPCRequest.
bool IsDeprecatedRPCEnabled(const std::string &method)
Special output type for change outputs only.
std::vector< PSBTInput > inputs
boost::optional< bool > m_signal_bip125_rbf
Override the wallet's m_signal_rbf if set.
UniValue rescanblockchain(const JSONRPCRequest &request)
RAII object to check and reserve a wallet rescan.
A transaction with a bunch of additional info that only the owner cares about.
RPC method is deprecated.
void RegisterWalletRPCCommands(CRPCTable &t)
bool IsSolvable(const SigningProvider &provider, const CScript &script)
CRIPEMD160 & Write(const unsigned char *data, size_t len)
void ListLockedCoins(std::vector< COutPoint > &vOutpts) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
bool FillPSBT(const CWallet *pwallet, PartiallySignedTransaction &psbtx, const CTransaction *txConst, int sighash_type, bool sign, bool bip32derivs)
std::map< CTxDestination, CAmount > GetAddressBalances() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
bool GetBroadcastTransactions() const
Inquire whether this wallet broadcasts transactions.
void BlockUntilSyncedToCurrentChain() LOCKS_EXCLUDED(cs_main
Blocks until the wallet state is up-to-date to /at least/ the current chain at the time this function...
CBlockIndex * ScanForWalletTransactions(CBlockIndex *pindexStart, CBlockIndex *pindexStop, const WalletRescanReserver &reserver, bool fUpdate=false)
Scan the block chain (starting in pindexStart) for transactions from or to us.
void LockCoin(const COutPoint &output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
CPubKey DeriveNewSeed(const CKey &key)
Failed to encrypt the wallet.
bool CreateTransaction(const std::vector< CRecipient > &vecSend, CTransactionRef &tx, CReserveKey &reservekey, CAmount &nFeeRet, int &nChangePosInOut, std::string &strFailReason, const CCoinControl &coin_control, bool sign=true)
Create a new transaction paying the recipients with a set of coins selected by SelectCoins(); Also cr...
Capture information about block/transaction validation.
CTxDestination DecodeDestination(const std::string &str)
void GetScriptForMining(std::shared_ptr< CReserveScript > &script)
#define EXCLUSIVE_LOCKS_REQUIRED(...)
std::vector< CTransactionRef > vtx
std::string FormatStateMessage(const CValidationState &state)
Convert CValidationState to a human-readable message for logging.
void FillSignatureData(SignatureData &sigdata) const
RBFTransactionState IsRBFOptIn(const CTransaction &tx, CTxMemPool &pool)
UniValue walletcreatefundedpsbt(const JSONRPCRequest &request)
bool ChangeWalletPassphrase(const SecureString &strOldWalletPassphrase, const SecureString &strNewWalletPassphrase)
const std::string & GetName() const
Get a name for this wallet for logging/debugging purposes.
A key allocated from the key pool.
Result CommitTransaction(CWallet *wallet, const uint256 &txid, CMutableTransaction &&mtx, std::vector< std::string > &errors, uint256 &bumped_txid)
Commit the bumpfee transaction.
The block chain is a tree shaped structure starting with the genesis block at the root...
const CChainParams & Params()
Return the currently selected parameters.
std::set< CTxDestination > GetLabelAddresses(const std::string &label) const
Serialized script, used inside transaction inputs and outputs.
int RPCSerializationFlags()
UniValue operator()(const WitnessUnknown &id) const
bool TopUpKeyPool(unsigned int kpSize=0)
Not enough funds in wallet or account.
const UniValue & get_obj() const
bool push_backV(const std::vector< UniValue > &vec)
void SetHDSeed(const CPubKey &key)
void RPCTypeCheckArgument(const UniValue &value, const UniValueType &typeExpected)
Type-check one argument; throws JSONRPCError if wrong type given.
isminetype IsMine(const CKeyStore &keystore, const CScript &scriptPubKey)
A reference to a CKey: the Hash360 of its serialized public key.
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
bool DecodeHexTx(CMutableTransaction &tx, const std::string &hex_tx, bool try_no_witness=false, bool try_witness=true)
void LearnRelatedScripts(const CPubKey &key, OutputType)
Explicitly make the wallet learn the related scripts for outputs to the given key.
std::string GetHex() const
bool RemoveWallet(const std::shared_ptr< CWallet > &wallet)
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
unsigned int ParseConfirmTarget(const UniValue &value)
Check bounds on a command line confirm target.
std::string EncodeHexTx(const CTransaction &tx, const int serializeFlags=0)
UniValue SignTransaction(CMutableTransaction &mtx, const UniValue &prevTxsUnival, CBasicKeyStore *keystore, bool is_temp_keystore, const UniValue &hashType)
Sign a transaction with the given keystore and previous transactions.
Fee rate in satoshis per kilobyte: CAmount / kB.
std::unique_ptr< CConnman > g_connman
const UniValue NullUniValue
UniValue removeprunedfunds(const JSONRPCRequest &request)
fs::path GetWalletDir()
Get the path of the wallet directory.
bool ProduceSignature(const SigningProvider &provider, const BaseSignatureCreator &creator, const CScript &fromPubKey, SignatureData &sigdata)
Produce a script signature using a generic signature creator.
bool error(const char *fmt, const Args &... args)
CTxDestination GetDestinationForKey(const CPubKey &key, OutputType type)
Get a destination of the requested type (if possible) to the specified key.
void FundTransaction(CWallet *const pwallet, CMutableTransaction &tx, CAmount &fee_out, int &change_position, UniValue options)
DescribeWalletAddressVisitor(CWallet *_pwallet)
UniValue operator()(const WitnessV0KeyHash &id) const
UniValue sethdseed(const JSONRPCRequest &request)
std::vector< uint256 > ResendWalletTransactionsBefore(int64_t nTime, CConnman *connman) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
A reference to a CScript: the Hash360 of its serialization (see script.h)
bool GetKeyFromPool(CPubKey &key, bool internal=false)
std::string EncodeDestination(const CTxDestination &dest)
CMutableTransaction ConstructTransaction(const UniValue &inputs_in, const UniValue &outputs_in, const UniValue &locktime, const UniValue &rbf)
Create a transaction from univalue parameters.
Standard JSON-RPC 2.0 errors.
A mutable version of CTransaction.
A writer stream (for serialization) that computes a 256-bit SHA-3-256 hash.
UniValue dumpprivkey(const JSONRPCRequest &request)
FeeEstimateMode m_fee_mode
Fee estimation mode to control arguments to estimateSmartFee.
void AddKeypathToMap(const CWallet *pwallet, const CKeyID &keyID, std::map< CPubKey, KeyOriginInfo > &hd_keypaths)
UniValue JSONRPCError(int code, const std::string &message)
No valid connection manager instance found.
int64_t GetTime()
GetTimeMicros() and GetTimeMillis() both return the system time, but in different units...
std::string ToString() const
An encapsulated private key.
The basic transaction that is broadcasted on the network and contained in blocks. ...
int nHeight
height of the entry in the chain. The genesis block has height 0
CTxDestination filtered_address
bool ReadBlockFromDisk(CBlock &block, const CDiskBlockPos &pos, const Consensus::Params &consensusParams)
Functions for disk access for blocks.
UniValue abortrescan(const JSONRPCRequest &request)
CKey DecodeSecret(const std::string &str)
Still downloading initial blocks.
full block available in blk*.dat
bool SignPSBTInput(const SigningProvider &provider, const CMutableTransaction &tx, PSBTInput &input, int index, int sighash)
Signs a PSBTInput, verifying that all provided data matches what is being signed. ...
void Finalize(unsigned char hash[OUTPUT_SIZE])
CChain & chainActive
The currently-connected chain of blocks (protected by cs_main).
const CHDChain & GetHDChain() const
CKeyID seed_id
seed hash360
bool BackupWallet(const std::string &strDest)
UniValue importmulti(const JSONRPCRequest &request)
UniValue importprivkey(const JSONRPCRequest &request)
UniValue importpubkey(const JSONRPCRequest &request)
std::multimap< int64_t, CWalletTx * > TxItems
UniValue listtransactions(const JSONRPCRequest &request)
const CBlockIndex * FindFork(const CBlockIndex *pindex) const
Find the last common block between this chain and a block index entry.
UniValue operator()(const CKeyID &keyID) const
bool ParseOutputType(const std::string &type, OutputType &output_type)
bool IsImmatureCoinBase() const EXCLUSIVE_LOCKS_REQUIRED(cs_main)
CAmount GetFeePerK() const
Return the fee in satoshis for a size of 1000 bytes.
Wrapper for UniValue::VType, which includes typeAny: Used to denote don't care type.
int64_t nRelockTime
Holds a timestamp at which point the wallet is scheduled (externally) to be relocked. Caller must arrange for actual relocking to occur via Lock().
Error parsing or validating structure in raw format.
CPubKey GenerateNewSeed()
std::string EncodeBase64(const unsigned char *pch, size_t len)
A hasher class for RIPEMD-160.
bool IsValid() const
Check whether this private key is valid.
bool Unlock(const SecureString &strWalletPassphrase)
void EnsureWalletIsUnlocked(CWallet *const pwallet)
bool IsCompressed() const
Check whether this is a compressed public key.
CBlockIndex * LookupBlockIndex(const uint256 &hash)