8 #include <validation.h> 22 #include <boost/algorithm/string.hpp> 23 #include <boost/date_time/posix_time/posix_time.hpp> 28 int64_t
static DecodeDumpTime(
const std::string &str) {
29 static const boost::posix_time::ptime epoch = boost::posix_time::from_time_t(0);
30 static const std::locale loc(std::locale::classic(),
31 new boost::posix_time::time_input_facet(
"%Y-%m-%dT%H:%M:%SZ"));
32 std::istringstream iss(str);
34 boost::posix_time::ptime ptime(boost::date_time::not_a_date_time);
36 if (ptime.is_not_a_date_time())
38 return (ptime - epoch).total_seconds();
41 std::string
static EncodeDumpString(
const std::string &str) {
42 std::stringstream
ret;
43 for (
const unsigned char c : str) {
44 if (c <= 32 || c >= 128 || c ==
'%') {
53 static std::string DecodeDumpString(
const std::string &str) {
54 std::stringstream
ret;
55 for (
unsigned int pos = 0; pos < str.length(); pos++) {
56 unsigned char c = str[pos];
57 if (c ==
'%' && pos+2 < str.length()) {
58 c = (((str[pos+1]>>6)*9+((str[pos+1]-
'0')&15)) << 4) |
59 ((str[pos+2]>>6)*9+((str[pos+2]-
'0')&15));
67 static bool GetWalletAddressesForKey(
CWallet *
const pwallet,
const CKeyID &keyid, std::string &strAddr, std::string &strLabel)
69 bool fLabelFound =
false;
71 pwallet->
GetKey(keyid, key);
74 if (!strAddr.empty()) {
88 static const int64_t TIMESTAMP_MIN = 0;
90 static void RescanWallet(
CWallet& wallet,
const WalletRescanReserver& reserver, int64_t time_begin = TIMESTAMP_MIN,
bool update =
true)
92 int64_t scanned_time = wallet.
RescanFromTime(time_begin, reserver, update);
95 }
else if (scanned_time > time_begin) {
103 CWallet*
const pwallet = wallet.get();
109 throw std::runtime_error(
110 "importprivkey \"privkey\" ( \"label\" ) ( rescan )\n" 111 "\nAdds a private key (as returned by dumpprivkey) to your wallet. Requires a new wallet backup.\n" 112 "Hint: use importmulti to import more than one private key.\n" 114 "1. \"privkey\" (string, required) The private key (see dumpprivkey)\n" 115 "2. \"label\" (string, optional, default=\"\") An optional label\n" 116 "3. rescan (boolean, optional, default=true) Rescan the wallet for transactions\n" 117 "\nNote: This call can take over an hour to complete if rescan is true, during that time, other rpc calls\n" 118 "may report that the imported key exists but related transactions are still missing, leading to temporarily incorrect/bogus balances and unspent outputs until rescan completes.\n" 120 "\nDump a private key\n" 122 "\nImport the private key with rescan\n" 124 "\nImport using a label and without rescan\n" 125 +
HelpExampleCli(
"importprivkey",
"\"mykey\" \"testing\" false") +
126 "\nImport using default blank label and without rescan\n" 128 "\nAs a JSON-RPC call\n" 129 +
HelpExampleRpc(
"importprivkey",
"\"mykey\", \"testing\", false")
141 std::string strLabel =
"";
152 if (fRescan && !reserver.
reserve()) {
170 if (pwallet->
HaveKey(vchAddress)) {
176 pwallet->mapKeyMetadata[vchAddress].nCreateTime = 1;
185 RescanWallet(*pwallet, reserver);
194 CWallet*
const pwallet = wallet.get();
200 throw std::runtime_error(
202 "\nStops current wallet rescan triggered by an RPC call, e.g. by an importprivkey call.\n" 204 "\nImport a private key\n" 206 "\nAbort the running wallet rescan\n" 208 "\nAs a JSON-RPC call\n" 230 if (isRedeemScript) {
235 ImportAddress(pwallet,
id, strLabel);
247 ImportScript(pwallet, script, strLabel,
false);
256 CWallet*
const pwallet = wallet.get();
262 throw std::runtime_error(
263 "importaddress \"address\" ( \"label\" rescan p2sh )\n" 264 "\nAdds an address or script (in hex) that can be watched as if it were in your wallet but cannot be used to spend. Requires a new wallet backup.\n" 266 "1. \"address\" (string, required) The BSHA3 address (or hex-encoded script)\n" 267 "2. \"label\" (string, optional, default=\"\") An optional label\n" 268 "3. rescan (boolean, optional, default=true) Rescan the wallet for transactions\n" 269 "4. p2sh (boolean, optional, default=false) Add the P2SH version of the script as well\n" 270 "\nNote: This call can take over an hour to complete if rescan is true, during that time, other rpc calls\n" 271 "may report that the imported address exists but related transactions are still missing, leading to temporarily incorrect/bogus balances and unspent outputs until rescan completes.\n" 272 "If you have the full public key, you should call importpubkey instead of this.\n" 273 "\nNote: If you import a non-standard raw script in hex form, outputs sending to it will be treated\n" 274 "as change, and not show up in many RPCs.\n" 276 "\nImport an address with rescan\n" 278 "\nImport using a label without rescan\n" 279 +
HelpExampleCli(
"importaddress",
"\"myaddress\" \"testing\" false") +
280 "\nAs a JSON-RPC call\n" 281 +
HelpExampleRpc(
"importaddress",
"\"myaddress\", \"testing\", false")
285 std::string strLabel;
298 if (fRescan && !reserver.
reserve()) {
315 ImportAddress(pwallet, dest, strLabel);
318 ImportScript(pwallet,
CScript(data.begin(), data.end()), strLabel, fP2SH);
325 RescanWallet(*pwallet, reserver);
335 CWallet*
const pwallet = wallet.get();
341 throw std::runtime_error(
342 "importprunedfunds\n" 343 "\nImports funds without rescan. Corresponding address or script must previously be included in wallet. Aimed towards pruned wallets. The end-user is responsible to import additional transactions that subsequently spend the imported outputs or rescan after the point in the blockchain the transaction is included.\n" 345 "1. \"rawtransaction\" (string, required) A raw transaction in hex funding an already-existing address in wallet\n" 346 "2. \"txoutproof\" (string, required) The hex output from gettxoutproof that contains the transaction\n" 353 CWalletTx wtx(pwallet, MakeTransactionRef(std::move(tx)));
360 std::vector<uint256> vMatch;
361 std::vector<unsigned int> vIndex;
362 unsigned int txnIndex = 0;
363 if (merkleBlock.txn.ExtractMatches(vMatch, vIndex) == merkleBlock.header.hashMerkleRoot) {
371 std::vector<uint256>::const_iterator it;
372 if ((it = std::find(vMatch.begin(), vMatch.end(), hashTx))==vMatch.end()) {
376 txnIndex = vIndex[it - vMatch.begin()];
383 wtx.
hashBlock = merkleBlock.header.GetHash();
398 CWallet*
const pwallet = wallet.get();
404 throw std::runtime_error(
405 "removeprunedfunds \"txid\"\n" 406 "\nDeletes the specified transaction from the wallet. Meant for use with pruned wallets and as a companion to importprunedfunds. This will affect wallet balances.\n" 408 "1. \"txid\" (string, required) The hex-encoded id of the transaction you are deleting\n" 410 +
HelpExampleCli(
"removeprunedfunds",
"\"a8d0c0184dde994a09ec054286f1ce581bebf46446a512166eae7628734ea0a5\"") +
411 "\nAs a JSON-RPC call\n" 412 +
HelpExampleRpc(
"removeprunedfunds",
"\"a8d0c0184dde994a09ec054286f1ce581bebf46446a512166eae7628734ea0a5\"")
418 std::vector<uint256> vHash;
419 vHash.push_back(hash);
420 std::vector<uint256> vHashOut;
426 if(vHashOut.empty()) {
436 CWallet*
const pwallet = wallet.get();
442 throw std::runtime_error(
443 "importpubkey \"pubkey\" ( \"label\" rescan )\n" 444 "\nAdds a public key (in hex) that can be watched as if it were in your wallet but cannot be used to spend. Requires a new wallet backup.\n" 446 "1. \"pubkey\" (string, required) The hex-encoded public key\n" 447 "2. \"label\" (string, optional, default=\"\") An optional label\n" 448 "3. rescan (boolean, optional, default=true) Rescan the wallet for transactions\n" 449 "\nNote: This call can take over an hour to complete if rescan is true, during that time, other rpc calls\n" 450 "may report that the imported pubkey exists but related transactions are still missing, leading to temporarily incorrect/bogus balances and unspent outputs until rescan completes.\n" 452 "\nImport a public key with rescan\n" 454 "\nImport using a label without rescan\n" 455 +
HelpExampleCli(
"importpubkey",
"\"mypubkey\" \"testing\" false") +
456 "\nAs a JSON-RPC call\n" 457 +
HelpExampleRpc(
"importpubkey",
"\"mypubkey\", \"testing\", false")
461 std::string strLabel;
474 if (fRescan && !reserver.
reserve()) {
481 CPubKey pubKey(data.begin(), data.end());
482 if (!pubKey.IsFullyValid())
489 ImportAddress(pwallet, dest, strLabel);
496 RescanWallet(*pwallet, reserver);
507 CWallet*
const pwallet = wallet.get();
513 throw std::runtime_error(
514 "importwallet \"filename\"\n" 515 "\nImports keys from a wallet dump file (see dumpwallet). Requires a new wallet backup to include imported keys.\n" 517 "1. \"filename\" (string, required) The wallet file\n" 519 "\nDump the wallet\n" 521 "\nImport the wallet\n" 523 "\nImport using the json rpc call\n" 535 int64_t nTimeBegin = 0;
543 file.open(request.
params[0].
get_str(), std::ios::in | std::ios::ate);
544 if (!file.is_open()) {
549 int64_t nFilesize = std::max((int64_t)1, (int64_t)file.tellg());
550 file.seekg(0, file.beg);
555 while (file.good()) {
556 uiInterface.ShowProgress(
"", std::max(1, std::min(99, (
int)(((
double)file.tellg() / (double)nFilesize) * 100))),
false);
558 std::getline(file, line);
559 if (line.empty() || line[0] ==
'#')
562 std::vector<std::string> vstr;
563 boost::split(vstr, line, boost::is_any_of(
" "));
575 int64_t nTime = DecodeDumpTime(vstr[1]);
576 std::string strLabel;
578 for (
unsigned int nStr = 2; nStr < vstr.size(); nStr++) {
579 if (vstr[nStr].front() ==
'#')
581 if (vstr[nStr] ==
"change=1")
583 if (vstr[nStr] ==
"reserve=1")
585 if (vstr[nStr].substr(0,6) ==
"label=") {
586 strLabel = DecodeDumpString(vstr[nStr].substr(6));
595 pwallet->mapKeyMetadata[keyid].nCreateTime = nTime;
598 nTimeBegin = std::min(nTimeBegin, nTime);
599 }
else if(
IsHex(vstr[0])) {
600 std::vector<unsigned char> vData(
ParseHex(vstr[0]));
604 pwallet->
WalletLogPrintf(
"Skipping import of %s (script already present)\n", vstr[0]);
612 int64_t birth_time = DecodeDumpTime(vstr[1]);
613 if (birth_time > 0) {
614 pwallet->m_script_metadata[id].nCreateTime = birth_time;
615 nTimeBegin = std::min(nTimeBegin, birth_time);
624 RescanWallet(*pwallet, reserver, nTimeBegin,
false );
636 CWallet*
const pwallet = wallet.get();
642 throw std::runtime_error(
643 "dumpprivkey \"address\"\n" 644 "\nReveals the private key corresponding to 'address'.\n" 645 "Then the importprivkey can be used with this output\n" 647 "1. \"address\" (string, required) The bitcoin address for the private key\n" 649 "\"key\" (string) The private key\n" 670 if (!pwallet->
GetKey(keyid, vchSecret)) {
680 CWallet*
const pwallet = wallet.get();
686 throw std::runtime_error(
687 "dumpwallet \"filename\"\n" 688 "\nDumps all wallet keys in a human-readable format to a server-side file. This does not allow overwriting existing files.\n" 689 "Imported scripts are included in the dumpfile, but corresponding BIP173 addresses, etc. may not be added automatically by importwallet.\n" 690 "Note that if your wallet contains keys which are not derived from your HD seed (e.g. imported keys), these are not covered by\n" 691 "only backing up the seed itself, and must be backed up too (e.g. ensure you back up the whole dumpfile).\n" 693 "1. \"filename\" (string, required) The filename with path (either absolute or relative to bsha3d)\n" 696 " \"filename\" : { (string) The filename with full absolute path\n" 708 filepath = fs::absolute(filepath);
715 if (fs::exists(filepath)) {
724 std::map<CTxDestination, int64_t> mapKeyBirth;
728 std::set<CScriptID> scripts = pwallet->
GetCScripts();
732 std::vector<std::pair<int64_t, CKeyID> > vKeyBirth;
733 for (
const auto& entry : mapKeyBirth) {
734 if (
const CKeyID* keyID = boost::get<CKeyID>(&entry.first)) {
735 vKeyBirth.push_back(std::make_pair(entry.second, *keyID));
739 std::sort(vKeyBirth.begin(), vKeyBirth.end());
753 if (pwallet->
GetKey(seed_id, seed)) {
757 file <<
"# extended private masterkey: " <<
EncodeExtKey(masterKey) <<
"\n\n";
760 for (std::vector<std::pair<int64_t, CKeyID> >::const_iterator it = vKeyBirth.begin(); it != vKeyBirth.end(); it++) {
761 const CKeyID &keyid = it->second;
764 std::string strLabel;
766 if (pwallet->
GetKey(keyid, key)) {
768 if (GetWalletAddressesForKey(pwallet, keyid, strAddr, strLabel)) {
770 }
else if (keyid == seed_id) {
772 }
else if (mapKeyPool.count(keyid)) {
774 }
else if (pwallet->mapKeyMetadata[keyid].hdKeypath ==
"s") {
775 file <<
"inactivehdseed=1";
779 file <<
strprintf(
" # addr=%s%s\n", strAddr, (pwallet->mapKeyMetadata[keyid].hdKeypath.size() > 0 ?
" hdkeypath="+pwallet->mapKeyMetadata[keyid].hdKeypath :
""));
783 for (
const CScriptID &scriptid : scripts) {
785 std::string create_time =
"0";
788 auto it = pwallet->m_script_metadata.find(scriptid);
789 if (it != pwallet->m_script_metadata.end()) {
794 file <<
strprintf(
" # addr=%s\n", address);
798 file <<
"# End of dump\n";
802 reply.
pushKV(
"filename", filepath.string());
812 const UniValue& scriptPubKey = data[
"scriptPubKey"];
817 const std::string& output = isScript ? scriptPubKey.
get_str() : scriptPubKey[
"address"].
get_str();
820 const std::string& strRedeemScript = data.exists(
"redeemscript") ? data[
"redeemscript"].get_str() :
"";
821 const std::string& witness_script_hex = data.exists(
"witnessscript") ? data[
"witnessscript"].get_str() :
"";
824 const bool internal = data.exists(
"internal") ? data[
"internal"].get_bool() :
false;
825 const bool watchOnly = data.exists(
"watchonly") ? data[
"watchonly"].get_bool() :
false;
826 const std::string& label = data.exists(
"label") ? data[
"label"].get_str() :
"";
839 if (!
IsHex(output)) {
843 std::vector<unsigned char> vData(
ParseHex(output));
844 script =
CScript(vData.begin(), vData.end());
851 if (watchOnly && keys.
size()) {
856 if (
internal && data.exists(
"label")) {
865 CScript scriptpubkey_script = script;
867 bool allow_p2wpkh =
true;
872 if (!
IsHex(strRedeemScript)) {
877 std::vector<unsigned char> vData(
ParseHex(strRedeemScript));
897 script = redeemScript;
903 if (!
IsHex(witness_script_hex)) {
908 std::vector<unsigned char> witness_script_parsed(
ParseHex(witness_script_hex));
909 CScript witness_script =
CScript(witness_script_parsed.begin(), witness_script_parsed.end());
927 script = witness_script;
929 allow_p2wpkh =
false;
937 if (keys.
size() > 1 || pubKeys.
size() > 1) {
944 if (pubKeys.
size()) {
945 const std::string& strPubKey = pubKeys[0].
get_str();
946 if (!
IsHex(strPubKey)) {
949 std::vector<unsigned char> vData(
ParseHex(pubKeys[0].get_str()));
950 CPubKey pubkey_temp(vData.begin(), vData.end());
951 if (pubkey.
size() && pubkey_temp != pubkey) {
954 pubkey = pubkey_temp;
956 if (pubkey.
size() > 0) {
963 if (std::find(destinations.begin(), destinations.end(), dest) == destinations.end()) {
976 if (!pwallet->
AddWatchOnly(scriptRawPubKey, timestamp)) {
989 if (!pwallet->
AddWatchOnly(scriptpubkey_script, timestamp)) {
1003 for (
size_t i = 0; i < keys.
size(); i++) {
1004 const std::string& strPrivkey = keys[i].
get_str();
1019 if (pwallet->
HaveKey(vchAddress)) {
1023 pwallet->mapKeyMetadata[vchAddress].nCreateTime = timestamp;
1038 result.
pushKV(
"error", e);
1048 static int64_t GetImportTimestamp(
const UniValue& data, int64_t now)
1050 if (data.
exists(
"timestamp")) {
1051 const UniValue& timestamp = data[
"timestamp"];
1052 if (timestamp.
isNum()) {
1054 }
else if (timestamp.
isStr() && timestamp.
get_str() ==
"now") {
1065 CWallet*
const pwallet = wallet.get();
1072 throw std::runtime_error(
1073 "importmulti \"requests\" ( \"options\" )\n\n" 1074 "Import addresses/scripts (with private or public keys, redeem script (P2SH)), rescanning all addresses in one-shot-only (rescan can be disabled via options). Requires a new wallet backup.\n\n" 1076 "1. requests (array, required) Data to be imported\n" 1077 " [ (array of json objects)\n" 1079 " \"scriptPubKey\": \"<script>\" | { \"address\":\"<address>\" }, (string / json, required) Type of scriptPubKey (string for script, json for address)\n" 1080 " \"timestamp\": timestamp | \"now\" , (integer / string, required) Creation time of the key in seconds since epoch (Jan 1 1970 GMT),\n" 1081 " or the string \"now\" to substitute the current synced blockchain time. The timestamp of the oldest\n" 1082 " key will determine how far back blockchain rescans need to begin for missing wallet transactions.\n" 1083 " \"now\" can be specified to bypass scanning, for keys which are known to never have been used, and\n" 1084 " 0 can be specified to scan the entire blockchain. Blocks up to 2 hours before the earliest key\n" 1085 " creation time of all keys being imported by the importmulti call will be scanned.\n" 1086 " \"redeemscript\": \"<script>\" , (string, optional) Allowed only if the scriptPubKey is a P2SH or P2SH-P2WSH address/scriptPubKey\n" 1087 " \"witnessscript\": \"<script>\" , (string, optional) Allowed only if the scriptPubKey is a P2SH-P2WSH or P2WSH address/scriptPubKey\n" 1088 " \"pubkeys\": [\"<pubKey>\", ... ] , (array, optional) Array of strings giving pubkeys that must occur in the output or redeemscript\n" 1089 " \"keys\": [\"<key>\", ... ] , (array, optional) Array of strings giving private keys whose corresponding public keys must occur in the output or redeemscript\n" 1090 " \"internal\": <true> , (boolean, optional, default: false) Stating whether matching outputs should be treated as not incoming payments\n" 1091 " \"watchonly\": <true> , (boolean, optional, default: false) Stating whether matching outputs should be considered watched even when they're not spendable, only allowed if keys are empty\n" 1092 " \"label\": <label> , (string, optional, default: '') Label to assign to the address, only allowed with internal=false\n" 1096 "2. options (json, optional)\n" 1098 " \"rescan\": <false>, (boolean, optional, default: true) Stating if should rescan the blockchain after all imports\n" 1100 "\nNote: This call can take over an hour to complete if rescan is true, during that time, other rpc calls\n" 1101 "may report that the imported keys, addresses or scripts exists but related transactions are still missing.\n" 1103 HelpExampleCli(
"importmulti",
"'[{ \"scriptPubKey\": { \"address\": \"<my address>\" }, \"timestamp\":1455191478 }, " 1104 "{ \"scriptPubKey\": { \"address\": \"<my 2nd address>\" }, \"label\": \"example 2\", \"timestamp\": 1455191480 }]'") +
1105 HelpExampleCli(
"importmulti",
"'[{ \"scriptPubKey\": { \"address\": \"<my address>\" }, \"timestamp\":1455191478 }]' '{ \"rescan\": false}'") +
1107 "\nResponse is an array with the same size as the input that has the execution result :\n" 1108 " [{ \"success\": true } , { \"success\": false, \"error\": { \"code\": -1, \"message\": \"Internal Server Error\"} }, ... ]\n");
1117 bool fRescan =
true;
1122 if (options.
exists(
"rescan")) {
1123 fRescan = options[
"rescan"].
get_bool();
1128 if (fRescan && !reserver.
reserve()) {
1133 bool fRunScan =
false;
1134 int64_t nLowestTimestamp = 0;
1143 GetImportTimestamp(data, now);
1146 const int64_t minimumTimestamp = 1;
1155 const int64_t timestamp = std::max(GetImportTimestamp(data, now), minimumTimestamp);
1156 const UniValue result = ProcessImport(pwallet, data, timestamp);
1164 if (result[
"success"].get_bool()) {
1169 if (timestamp < nLowestTimestamp) {
1170 nLowestTimestamp = timestamp;
1174 if (fRescan && fRunScan && requests.
size()) {
1175 int64_t scannedTime = pwallet->
RescanFromTime(nLowestTimestamp, reserver,
true );
1181 if (scannedTime > nLowestTimestamp) {
1182 std::vector<UniValue> results = response.
getValues();
1191 if (scannedTime <= GetImportTimestamp(request, now) || results.at(i).exists(
"error")) {
1200 strprintf(
"Rescan failed for key with creation timestamp %d. There was an error reading a " 1201 "block from time %d, which is after or within %d seconds of key creation, and " 1202 "could contain transactions pertaining to the key. As a result, transactions " 1203 "and coins using this key may not appear in the wallet. This error could be " 1204 "caused by pruning or data corruption (see bsha3d log for details) and could " 1205 "be dealt with by downloading and rescanning the relevant blocks (see -reindex " 1206 "and -rescan options).",
1207 GetImportTimestamp(request, now), scannedTime - TIMESTAMP_WINDOW - 1, TIMESTAMP_WINDOW)));
UniValue abortrescan(const JSONRPCRequest &request)
bool fPruneMode
True if we're running in -prune mode.
const std::vector< UniValue > & getValues() const
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
bool HaveKey(const CKeyID &address) const override
Check whether a key corresponding to a given address is present in the store.
int64_t GetBlockTime() const
void GetKeyBirthTimes(std::map< CTxDestination, int64_t > &mapKeyBirth) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
const std::map< CKeyID, int64_t > & GetAllReserveKeys() const
UniValue dumpprivkey(const JSONRPCRequest &request)
std::map< CTxDestination, CAddressBookData > mapAddressBook
bool IsPayToScriptHash() const
bool VerifyPubKey(const CPubKey &vchPubKey) const
Verify thoroughly whether a private key and a public key match.
UniValue importmulti(const JSONRPCRequest &mainRequest)
CPubKey GetPubKey() const
Compute the public key from a private key.
bool EnsureWalletIsAvailable(CWallet *const pwallet, bool avoidException)
bool HaveCScript(const CScriptID &hash) const override
UniValue ret(UniValue::VARR)
std::set< CScriptID > GetCScripts() const override
void ReacceptWalletTransactions()
bool GetCScript(const CScriptID &hash, CScript &redeemScriptOut) const override
int Height() const
Return the maximal height in the chain.
bool IsValidDestination(const CTxDestination &dest)
Check whether a CTxDestination is a CNoDestination.
std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
CScript GetScriptForRawPubKey(const CPubKey &pubKey)
Generate a P2PK script for the given pubkey.
UniValue dumpwallet(const JSONRPCRequest &request)
CKeyID GetKeyForDestination(const CKeyStore &store, const CTxDestination &dest)
Return the CKeyID of the key involved in a script (if there is a unique one).
const std::string & get_str() const
enum VType getType() const
std::string HelpExampleRpc(const std::string &methodname, const std::string &args)
Double ended buffer combining vector and stream-like interfaces.
int64_t get_int64() const
const unsigned char * begin() const
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
Invalid, missing or duplicate parameter.
uint256 ParseHashV(const UniValue &v, std::string strName)
Utilities: convert hex-encoded Values (throws error if not hex).
std::vector< CTxDestination > GetAllDestinationsForKey(const CPubKey &key)
Get all destinations (potentially) supported by the wallet for the given key.
DBErrors ZapSelectTx(std::vector< uint256 > &vHashIn, std::vector< uint256 > &vHashOut) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
uint256 GetBlockHash() const
bool SetAddressBook(const CTxDestination &address, const std::string &strName, const std::string &purpose)
const char * uvTypeName(UniValue::VType t)
Used to relay blocks as header + vector<merkle branch> to filtered nodes.
bool push_back(const UniValue &val)
bool IsFullyValid() const
fully validate whether this is a valid public key (more expensive than IsValid()) ...
void WalletLogPrintf(std::string fmt, Params... parameters) const
Prepends the wallet name in logging output to ease debugging in multi-wallet use cases.
void UpdateTimeFirstKey(int64_t nCreateTime) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Update wallet first key creation time.
boost::variant< CNoDestination, CKeyID, CScriptID, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
bool AddCScript(const CScript &redeemScript) override
Support for BIP 0013 : see https://github.com/bitcoin/bips/blob/master/bip-0013.mediawiki.
OutputType m_default_address_type
bool exists(const std::string &key) const
bool Contains(const CBlockIndex *pindex) const
Efficiently check whether a block is present in this chain.
UniValue removeprunedfunds(const JSONRPCRequest &request)
An encapsulated public key.
bool IsHex(const std::string &str)
Unexpected type was passed as parameter.
bool AddKeyPubKey(const CKey &key, const CPubKey &pubkey) override EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Adds a key to the store, and saves it to disk.
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.
unsigned int size() const
Simple read-only vector-like interface.
unsigned int size() const
Simple read-only vector-like interface to the pubkey data.
std::string ToString() const
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
std::string HelpExampleCli(const std::string &methodname, const std::string &args)
CCriticalSection cs_wallet
std::shared_ptr< CWallet > GetWalletForJSONRPCRequest(const JSONRPCRequest &request)
Figures out what wallet, if any, to use for a JSONRPCRequest.
void SetSeed(const unsigned char *seed, unsigned int nSeedLen)
bool AddToWallet(const CWalletTx &wtxIn, bool fFlushOnClose=true)
int64_t GetMedianTimePast() const
RAII object to check and reserve a wallet rescan.
A transaction with a bunch of additional info that only the owner cares about.
std::vector< unsigned char > ParseHexV(const UniValue &v, std::string strName)
bool AddWatchOnly(const CScript &dest) override EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
Private version of AddWatchOnly method which does not accept a timestamp, and which will reset the wa...
CTxDestination DecodeDestination(const std::string &str)
#define EXCLUSIVE_LOCKS_REQUIRED(...)
uint256 GetHash() const
Compute the hash of this CMutableTransaction.
The block chain is a tree shaped structure starting with the genesis block at the root...
std::string FormatISO8601DateTime(int64_t nTime)
ISO 8601 formatting is preferred.
Serialized script, used inside transaction inputs and outputs.
UniValue importpubkey(const JSONRPCRequest &request)
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)
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
const UniValue NullUniValue
UniValue importprivkey(const JSONRPCRequest &request)
CTxDestination GetDestinationForKey(const CPubKey &key, OutputType type)
Get a destination of the requested type (if possible) to the specified key.
UniValue importwallet(const JSONRPCRequest &request)
A reference to a CScript: the Hash360 of its serialization (see script.h)
std::string EncodeDestination(const CTxDestination &dest)
UniValue importaddress(const JSONRPCRequest &request)
A mutable version of CTransaction.
const std::string GetDisplayName() const
Returns a bracketed wallet name for displaying in logs, will return [default wallet] if the wallet ha...
UniValue JSONRPCError(int code, const std::string &message)
int64_t GetTime()
GetTimeMicros() and GetTimeMillis() both return the system time, but in different units...
An encapsulated private key.
bool HaveWatchOnly(const CScript &dest) const override
CClientUIInterface uiInterface
void LearnAllRelatedScripts(const CPubKey &key)
Same as LearnRelatedScripts, but when the OutputType is not known (and could be anything).
CKey DecodeSecret(const std::string &str)
int64_t RescanFromTime(int64_t startTime, const WalletRescanReserver &reserver, bool update)
Scan active chain for relevant transactions after importing keys.
isminetype IsMine(const CTxIn &txin) const
CChain & chainActive
The currently-connected chain of blocks (protected by cs_main).
const CHDChain & GetHDChain() const
CKeyID seed_id
seed hash360
std::string EncodeSecret(const CKey &key)
const std::string CLIENT_BUILD
std::string EncodeExtKey(const CExtKey &key)
UniValue importprunedfunds(const JSONRPCRequest &request)
std::string _(const char *psz)
Translation function.
Error parsing or validating structure in raw format.
bool IsPayToWitnessScriptHash() const
bool IsValid() const
Check whether this private key is valid.
void EnsureWalletIsUnlocked(CWallet *const pwallet)
std::vector< unsigned char > ParseHex(const char *psz)
CBlockIndex * LookupBlockIndex(const uint256 &hash)