Browse Source

Reformat touched lines with C++11

0.15
Luke Dashjr 8 years ago
parent
commit
bf8a04a165
  1. 12
      src/rpc/misc.cpp
  2. 3
      src/rpc/rawtransaction.cpp
  3. 45
      src/wallet/rpcdump.cpp
  4. 284
      src/wallet/rpcwallet.cpp

12
src/rpc/misc.cpp

@ -101,8 +101,9 @@ UniValue getinfo(const JSONRPCRequest& request)
obj.push_back(Pair("keypoololdest", pwallet->GetOldestKeyPoolTime())); obj.push_back(Pair("keypoololdest", pwallet->GetOldestKeyPoolTime()));
obj.push_back(Pair("keypoolsize", (int)pwallet->GetKeyPoolSize())); obj.push_back(Pair("keypoolsize", (int)pwallet->GetKeyPoolSize()));
} }
if (pwallet && pwallet->IsCrypted()) if (pwallet && pwallet->IsCrypted()) {
obj.push_back(Pair("unlocked_until", pwallet->nRelockTime)); obj.push_back(Pair("unlocked_until", pwallet->nRelockTime));
}
obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK()))); obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK())));
#endif #endif
obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()))); obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK())));
@ -210,8 +211,9 @@ UniValue validateaddress(const JSONRPCRequest& request)
ret.push_back(Pair("iswatchonly", (mine & ISMINE_WATCH_ONLY) ? true: false)); ret.push_back(Pair("iswatchonly", (mine & ISMINE_WATCH_ONLY) ? true: false));
UniValue detail = boost::apply_visitor(DescribeAddressVisitor(pwallet), dest); UniValue detail = boost::apply_visitor(DescribeAddressVisitor(pwallet), dest);
ret.pushKVs(detail); ret.pushKVs(detail);
if (pwallet && pwallet->mapAddressBook.count(dest)) if (pwallet && pwallet->mapAddressBook.count(dest)) {
ret.push_back(Pair("account", pwallet->mapAddressBook[dest].name)); ret.push_back(Pair("account", pwallet->mapAddressBook[dest].name));
}
CKeyID keyID; CKeyID keyID;
if (pwallet) { if (pwallet) {
const auto& meta = pwallet->mapKeyMetadata; const auto& meta = pwallet->mapKeyMetadata;
@ -257,16 +259,16 @@ CScript _createmultisig_redeemScript(CWallet * const pwallet, const UniValue& pa
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
// Case 1: Bitcoin address and we have full public key: // Case 1: Bitcoin address and we have full public key:
CBitcoinAddress address(ks); CBitcoinAddress address(ks);
if (pwallet && address.IsValid()) if (pwallet && address.IsValid()) {
{
CKeyID keyID; CKeyID keyID;
if (!address.GetKeyID(keyID)) if (!address.GetKeyID(keyID))
throw runtime_error( throw runtime_error(
strprintf("%s does not refer to a key",ks)); strprintf("%s does not refer to a key",ks));
CPubKey vchPubKey; CPubKey vchPubKey;
if (!pwallet->GetPubKey(keyID, vchPubKey)) if (!pwallet->GetPubKey(keyID, vchPubKey)) {
throw runtime_error( throw runtime_error(
strprintf("no full public key for address %s",ks)); strprintf("no full public key for address %s",ks));
}
if (!vchPubKey.IsFullyValid()) if (!vchPubKey.IsFullyValid())
throw runtime_error(" Invalid public key: "+ks); throw runtime_error(" Invalid public key: "+ks);
pubkeys[i] = vchPubKey; pubkeys[i] = vchPubKey;

3
src/rpc/rawtransaction.cpp

@ -721,8 +721,9 @@ UniValue signrawtransaction(const JSONRPCRequest& request)
} }
} }
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
else if (pwallet) else if (pwallet) {
EnsureWalletIsUnlocked(pwallet); EnsureWalletIsUnlocked(pwallet);
}
#endif #endif
// Add previous txouts given in the RPC call: // Add previous txouts given in the RPC call:

45
src/wallet/rpcdump.cpp

@ -76,8 +76,9 @@ UniValue importprivkey(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() < 1 || request.params.size() > 3) if (request.fHelp || request.params.size() < 1 || request.params.size() > 3)
throw runtime_error( throw runtime_error(
@ -133,13 +134,15 @@ UniValue importprivkey(const JSONRPCRequest& request)
pwallet->SetAddressBook(vchAddress, strLabel, "receive"); pwallet->SetAddressBook(vchAddress, strLabel, "receive");
// Don't throw error in case a key is already there // Don't throw error in case a key is already there
if (pwallet->HaveKey(vchAddress)) if (pwallet->HaveKey(vchAddress)) {
return NullUniValue; return NullUniValue;
}
pwallet->mapKeyMetadata[vchAddress].nCreateTime = 1; pwallet->mapKeyMetadata[vchAddress].nCreateTime = 1;
if (!pwallet->AddKeyPubKey(key, pubkey)) if (!pwallet->AddKeyPubKey(key, pubkey)) {
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding key to wallet"); throw JSONRPCError(RPC_WALLET_ERROR, "Error adding key to wallet");
}
// whenever a key is imported, we need to scan the whole chain // whenever a key is imported, we need to scan the whole chain
pwallet->UpdateTimeFirstKey(1); pwallet->UpdateTimeFirstKey(1);
@ -155,17 +158,20 @@ UniValue importprivkey(const JSONRPCRequest& request)
void ImportAddress(CWallet*, const CBitcoinAddress& address, const string& strLabel); void ImportAddress(CWallet*, const CBitcoinAddress& address, const string& strLabel);
void ImportScript(CWallet * const pwallet, const CScript& script, const string& strLabel, bool isRedeemScript) void ImportScript(CWallet * const pwallet, const CScript& script, const string& strLabel, bool isRedeemScript)
{ {
if (!isRedeemScript && ::IsMine(*pwallet, script) == ISMINE_SPENDABLE) if (!isRedeemScript && ::IsMine(*pwallet, script) == ISMINE_SPENDABLE) {
throw JSONRPCError(RPC_WALLET_ERROR, "The wallet already contains the private key for this address or script"); throw JSONRPCError(RPC_WALLET_ERROR, "The wallet already contains the private key for this address or script");
}
pwallet->MarkDirty(); pwallet->MarkDirty();
if (!pwallet->HaveWatchOnly(script) && !pwallet->AddWatchOnly(script, 0 /* nCreateTime */)) if (!pwallet->HaveWatchOnly(script) && !pwallet->AddWatchOnly(script, 0 /* nCreateTime */)) {
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding address to wallet"); throw JSONRPCError(RPC_WALLET_ERROR, "Error adding address to wallet");
}
if (isRedeemScript) { if (isRedeemScript) {
if (!pwallet->HaveCScript(script) && !pwallet->AddCScript(script)) if (!pwallet->HaveCScript(script) && !pwallet->AddCScript(script)) {
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding p2sh redeemScript to wallet"); throw JSONRPCError(RPC_WALLET_ERROR, "Error adding p2sh redeemScript to wallet");
}
ImportAddress(pwallet, CBitcoinAddress(CScriptID(script)), strLabel); ImportAddress(pwallet, CBitcoinAddress(CScriptID(script)), strLabel);
} else { } else {
CTxDestination destination; CTxDestination destination;
@ -188,8 +194,9 @@ UniValue importaddress(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() < 1 || request.params.size() > 4) if (request.fHelp || request.params.size() < 1 || request.params.size() > 4)
throw runtime_error( throw runtime_error(
@ -258,8 +265,9 @@ UniValue importprunedfunds(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() != 2) if (request.fHelp || request.params.size() != 2)
throw runtime_error( throw runtime_error(
@ -319,8 +327,9 @@ UniValue removeprunedfunds(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() != 1) if (request.fHelp || request.params.size() != 1)
throw runtime_error( throw runtime_error(
@ -357,8 +366,9 @@ UniValue importpubkey(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() < 1 || request.params.size() > 4) if (request.fHelp || request.params.size() < 1 || request.params.size() > 4)
throw runtime_error( throw runtime_error(
@ -417,8 +427,9 @@ UniValue importwallet(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() != 1) if (request.fHelp || request.params.size() != 1)
throw runtime_error( throw runtime_error(
@ -525,8 +536,9 @@ UniValue dumpprivkey(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() != 1) if (request.fHelp || request.params.size() != 1)
throw runtime_error( throw runtime_error(
@ -555,8 +567,9 @@ UniValue dumpprivkey(const JSONRPCRequest& request)
if (!address.GetKeyID(keyID)) if (!address.GetKeyID(keyID))
throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to a key"); throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to a key");
CKey vchSecret; CKey vchSecret;
if (!pwallet->GetKey(keyID, vchSecret)) if (!pwallet->GetKey(keyID, vchSecret)) {
throw JSONRPCError(RPC_WALLET_ERROR, "Private key for address " + strAddress + " is not known"); throw JSONRPCError(RPC_WALLET_ERROR, "Private key for address " + strAddress + " is not known");
}
return CBitcoinSecret(vchSecret).ToString(); return CBitcoinSecret(vchSecret).ToString();
} }
@ -565,8 +578,9 @@ UniValue dumpwallet(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() != 1) if (request.fHelp || request.params.size() != 1)
throw runtime_error( throw runtime_error(
@ -615,8 +629,7 @@ UniValue dumpwallet(const JSONRPCRequest& request)
if (!masterKeyID.IsNull()) if (!masterKeyID.IsNull())
{ {
CKey key; CKey key;
if (pwallet->GetKey(masterKeyID, key)) if (pwallet->GetKey(masterKeyID, key)) {
{
CExtKey masterKey; CExtKey masterKey;
masterKey.SetMaster(key.begin(), key.size()); masterKey.SetMaster(key.begin(), key.size());

284
src/wallet/rpcwallet.cpp

@ -43,8 +43,7 @@ std::string HelpRequiringPassphrase(CWallet * const pwallet)
bool EnsureWalletIsAvailable(CWallet * const pwallet, bool avoidException) bool EnsureWalletIsAvailable(CWallet * const pwallet, bool avoidException)
{ {
if (!pwallet) if (!pwallet) {
{
if (!avoidException) if (!avoidException)
throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found (disabled)"); throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found (disabled)");
else else
@ -55,9 +54,10 @@ bool EnsureWalletIsAvailable(CWallet * const pwallet, bool avoidException)
void EnsureWalletIsUnlocked(CWallet * const pwallet) void EnsureWalletIsUnlocked(CWallet * const pwallet)
{ {
if (pwallet->IsLocked()) if (pwallet->IsLocked()) {
throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first."); throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first.");
} }
}
void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry) void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry)
{ {
@ -110,8 +110,9 @@ UniValue getnewaddress(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() > 1) if (request.fHelp || request.params.size() > 1)
throw runtime_error( throw runtime_error(
@ -135,13 +136,15 @@ UniValue getnewaddress(const JSONRPCRequest& request)
if (request.params.size() > 0) if (request.params.size() > 0)
strAccount = AccountFromValue(request.params[0]); strAccount = AccountFromValue(request.params[0]);
if (!pwallet->IsLocked()) if (!pwallet->IsLocked()) {
pwallet->TopUpKeyPool(); pwallet->TopUpKeyPool();
}
// Generate a new key that is added to wallet // Generate a new key that is added to wallet
CPubKey newKey; CPubKey newKey;
if (!pwallet->GetKeyFromPool(newKey)) if (!pwallet->GetKeyFromPool(newKey)) {
throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first"); throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first");
}
CKeyID keyID = newKey.GetID(); CKeyID keyID = newKey.GetID();
pwallet->SetAddressBook(keyID, strAccount, "receive"); pwallet->SetAddressBook(keyID, strAccount, "receive");
@ -164,8 +167,9 @@ UniValue getaccountaddress(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() != 1) if (request.fHelp || request.params.size() != 1)
throw runtime_error( throw runtime_error(
@ -198,8 +202,9 @@ UniValue getrawchangeaddress(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() > 1) if (request.fHelp || request.params.size() > 1)
throw runtime_error( throw runtime_error(
@ -215,8 +220,9 @@ UniValue getrawchangeaddress(const JSONRPCRequest& request)
LOCK2(cs_main, pwallet->cs_wallet); LOCK2(cs_main, pwallet->cs_wallet);
if (!pwallet->IsLocked()) if (!pwallet->IsLocked()) {
pwallet->TopUpKeyPool(); pwallet->TopUpKeyPool();
}
CReserveKey reservekey(pwallet); CReserveKey reservekey(pwallet);
CPubKey vchPubKey; CPubKey vchPubKey;
@ -235,8 +241,9 @@ UniValue setaccount(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2) if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
throw runtime_error( throw runtime_error(
@ -261,15 +268,14 @@ UniValue setaccount(const JSONRPCRequest& request)
strAccount = AccountFromValue(request.params[1]); strAccount = AccountFromValue(request.params[1]);
// Only add the account if the address is yours. // Only add the account if the address is yours.
if (IsMine(*pwallet, address.Get())) if (IsMine(*pwallet, address.Get())) {
{
// Detect when changing the account of an address that is the 'unused current key' of another account: // Detect when changing the account of an address that is the 'unused current key' of another account:
if (pwallet->mapAddressBook.count(address.Get())) if (pwallet->mapAddressBook.count(address.Get())) {
{
string strOldAccount = pwallet->mapAddressBook[address.Get()].name; string strOldAccount = pwallet->mapAddressBook[address.Get()].name;
if (address == GetAccountAddress(pwallet, strOldAccount)) if (address == GetAccountAddress(pwallet, strOldAccount)) {
GetAccountAddress(pwallet, strOldAccount, true); GetAccountAddress(pwallet, strOldAccount, true);
} }
}
pwallet->SetAddressBook(address.Get(), strAccount, "receive"); pwallet->SetAddressBook(address.Get(), strAccount, "receive");
} }
else else
@ -283,8 +289,9 @@ UniValue getaccount(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() != 1) if (request.fHelp || request.params.size() != 1)
throw runtime_error( throw runtime_error(
@ -307,8 +314,9 @@ UniValue getaccount(const JSONRPCRequest& request)
string strAccount; string strAccount;
map<CTxDestination, CAddressBookData>::iterator mi = pwallet->mapAddressBook.find(address.Get()); map<CTxDestination, CAddressBookData>::iterator mi = pwallet->mapAddressBook.find(address.Get());
if (mi != pwallet->mapAddressBook.end() && !(*mi).second.name.empty()) if (mi != pwallet->mapAddressBook.end() && !(*mi).second.name.empty()) {
strAccount = (*mi).second.name; strAccount = (*mi).second.name;
}
return strAccount; return strAccount;
} }
@ -317,8 +325,9 @@ UniValue getaddressesbyaccount(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() != 1) if (request.fHelp || request.params.size() != 1)
throw runtime_error( throw runtime_error(
@ -342,8 +351,7 @@ UniValue getaddressesbyaccount(const JSONRPCRequest& request)
// Find all addresses that have the given account // Find all addresses that have the given account
UniValue ret(UniValue::VARR); UniValue ret(UniValue::VARR);
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, CAddressBookData)& item, pwallet->mapAddressBook) for (const std::pair<CBitcoinAddress, CAddressBookData>& item : pwallet->mapAddressBook) {
{
const CBitcoinAddress& address = item.first; const CBitcoinAddress& address = item.first;
const string& strName = item.second.name; const string& strName = item.second.name;
if (strName == strAccount) if (strName == strAccount)
@ -363,8 +371,9 @@ static void SendMoney(CWallet * const pwallet, const CTxDestination &address, CA
if (nValue > curBalance) if (nValue > curBalance)
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds"); throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds");
if (pwallet->GetBroadcastTransactions() && !g_connman) if (pwallet->GetBroadcastTransactions() && !g_connman) {
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled"); throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
}
// Parse Bitcoin address // Parse Bitcoin address
CScript scriptPubKey = GetScriptForDestination(address); CScript scriptPubKey = GetScriptForDestination(address);
@ -393,8 +402,9 @@ UniValue sendtoaddress(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() < 2 || request.params.size() > 5) if (request.fHelp || request.params.size() < 2 || request.params.size() > 5)
throw runtime_error( throw runtime_error(
@ -453,8 +463,9 @@ UniValue listaddressgroupings(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp) if (request.fHelp)
throw runtime_error( throw runtime_error(
@ -483,8 +494,7 @@ UniValue listaddressgroupings(const JSONRPCRequest& request)
UniValue jsonGroupings(UniValue::VARR); UniValue jsonGroupings(UniValue::VARR);
map<CTxDestination, CAmount> balances = pwallet->GetAddressBalances(); map<CTxDestination, CAmount> balances = pwallet->GetAddressBalances();
BOOST_FOREACH(set<CTxDestination> grouping, pwallet->GetAddressGroupings()) for (set<CTxDestination> grouping : pwallet->GetAddressGroupings()) {
{
UniValue jsonGrouping(UniValue::VARR); UniValue jsonGrouping(UniValue::VARR);
BOOST_FOREACH(CTxDestination address, grouping) BOOST_FOREACH(CTxDestination address, grouping)
{ {
@ -492,9 +502,10 @@ UniValue listaddressgroupings(const JSONRPCRequest& request)
addressInfo.push_back(CBitcoinAddress(address).ToString()); addressInfo.push_back(CBitcoinAddress(address).ToString());
addressInfo.push_back(ValueFromAmount(balances[address])); addressInfo.push_back(ValueFromAmount(balances[address]));
{ {
if (pwallet->mapAddressBook.find(CBitcoinAddress(address).Get()) != pwallet->mapAddressBook.end()) if (pwallet->mapAddressBook.find(CBitcoinAddress(address).Get()) != pwallet->mapAddressBook.end()) {
addressInfo.push_back(pwallet->mapAddressBook.find(CBitcoinAddress(address).Get())->second.name); addressInfo.push_back(pwallet->mapAddressBook.find(CBitcoinAddress(address).Get())->second.name);
} }
}
jsonGrouping.push_back(addressInfo); jsonGrouping.push_back(addressInfo);
} }
jsonGroupings.push_back(jsonGrouping); jsonGroupings.push_back(jsonGrouping);
@ -506,8 +517,9 @@ UniValue signmessage(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() != 2) if (request.fHelp || request.params.size() != 2)
throw runtime_error( throw runtime_error(
@ -546,8 +558,9 @@ UniValue signmessage(const JSONRPCRequest& request)
throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key"); throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key");
CKey key; CKey key;
if (!pwallet->GetKey(keyID, key)) if (!pwallet->GetKey(keyID, key)) {
throw JSONRPCError(RPC_WALLET_ERROR, "Private key not available"); throw JSONRPCError(RPC_WALLET_ERROR, "Private key not available");
}
CHashWriter ss(SER_GETHASH, 0); CHashWriter ss(SER_GETHASH, 0);
ss << strMessageMagic; ss << strMessageMagic;
@ -564,8 +577,9 @@ UniValue getreceivedbyaddress(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2) if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
throw runtime_error( throw runtime_error(
@ -594,8 +608,9 @@ UniValue getreceivedbyaddress(const JSONRPCRequest& request)
if (!address.IsValid()) if (!address.IsValid())
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address"); throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address");
CScript scriptPubKey = GetScriptForDestination(address.Get()); CScript scriptPubKey = GetScriptForDestination(address.Get());
if (!IsMine(*pwallet, scriptPubKey)) if (!IsMine(*pwallet, scriptPubKey)) {
return ValueFromAmount(0); return ValueFromAmount(0);
}
// Minimum confirmations // Minimum confirmations
int nMinDepth = 1; int nMinDepth = 1;
@ -604,9 +619,8 @@ UniValue getreceivedbyaddress(const JSONRPCRequest& request)
// Tally // Tally
CAmount nAmount = 0; CAmount nAmount = 0;
for (map<uint256, CWalletTx>::iterator it = pwallet->mapWallet.begin(); it != pwallet->mapWallet.end(); ++it) for (const std::pair<uint256, CWalletTx>& pairWtx : pwallet->mapWallet) {
{ const CWalletTx& wtx = pairWtx.second;
const CWalletTx& wtx = (*it).second;
if (wtx.IsCoinBase() || !CheckFinalTx(*wtx.tx)) if (wtx.IsCoinBase() || !CheckFinalTx(*wtx.tx))
continue; continue;
@ -624,8 +638,9 @@ UniValue getreceivedbyaccount(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2) if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
throw runtime_error( throw runtime_error(
@ -660,20 +675,20 @@ UniValue getreceivedbyaccount(const JSONRPCRequest& request)
// Tally // Tally
CAmount nAmount = 0; CAmount nAmount = 0;
for (map<uint256, CWalletTx>::iterator it = pwallet->mapWallet.begin(); it != pwallet->mapWallet.end(); ++it) for (const std::pair<uint256, CWalletTx>& pairWtx : pwallet->mapWallet) {
{ const CWalletTx& wtx = pairWtx.second;
const CWalletTx& wtx = (*it).second;
if (wtx.IsCoinBase() || !CheckFinalTx(*wtx.tx)) if (wtx.IsCoinBase() || !CheckFinalTx(*wtx.tx))
continue; continue;
BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout) BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout)
{ {
CTxDestination address; CTxDestination address;
if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*pwallet, address) && setAddress.count(address)) if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*pwallet, address) && setAddress.count(address)) {
if (wtx.GetDepthInMainChain() >= nMinDepth) if (wtx.GetDepthInMainChain() >= nMinDepth)
nAmount += txout.nValue; nAmount += txout.nValue;
} }
} }
}
return ValueFromAmount(nAmount); return ValueFromAmount(nAmount);
} }
@ -683,8 +698,9 @@ UniValue getbalance(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() > 3) if (request.fHelp || request.params.size() > 3)
throw runtime_error( throw runtime_error(
@ -740,9 +756,8 @@ UniValue getbalance(const JSONRPCRequest& request)
// TxIns spending from the wallet. This also has fewer restrictions on // TxIns spending from the wallet. This also has fewer restrictions on
// which unconfirmed transactions are considered trusted. // which unconfirmed transactions are considered trusted.
CAmount nBalance = 0; CAmount nBalance = 0;
for (map<uint256, CWalletTx>::iterator it = pwallet->mapWallet.begin(); it != pwallet->mapWallet.end(); ++it) for (const std::pair<uint256, CWalletTx>& pairWtx : pwallet->mapWallet) {
{ const CWalletTx& wtx = pairWtx.second;
const CWalletTx& wtx = (*it).second;
if (!CheckFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0 || wtx.GetDepthInMainChain() < 0) if (!CheckFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0 || wtx.GetDepthInMainChain() < 0)
continue; continue;
@ -774,8 +789,9 @@ UniValue getunconfirmedbalance(const JSONRPCRequest &request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() > 0) if (request.fHelp || request.params.size() > 0)
throw runtime_error( throw runtime_error(
@ -792,8 +808,9 @@ UniValue movecmd(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() < 3 || request.params.size() > 5) if (request.fHelp || request.params.size() < 3 || request.params.size() > 5)
throw runtime_error( throw runtime_error(
@ -830,8 +847,9 @@ UniValue movecmd(const JSONRPCRequest& request)
if (request.params.size() > 4) if (request.params.size() > 4)
strComment = request.params[4].get_str(); strComment = request.params[4].get_str();
if (!pwallet->AccountMove(strFrom, strTo, nAmount, strComment)) if (!pwallet->AccountMove(strFrom, strTo, nAmount, strComment)) {
throw JSONRPCError(RPC_DATABASE_ERROR, "database error"); throw JSONRPCError(RPC_DATABASE_ERROR, "database error");
}
return true; return true;
} }
@ -841,8 +859,9 @@ UniValue sendfrom(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() < 3 || request.params.size() > 6) if (request.fHelp || request.params.size() < 3 || request.params.size() > 6)
throw runtime_error( throw runtime_error(
@ -910,8 +929,9 @@ UniValue sendmany(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() < 2 || request.params.size() > 5) if (request.fHelp || request.params.size() < 2 || request.params.size() > 5)
throw runtime_error( throw runtime_error(
@ -951,8 +971,9 @@ UniValue sendmany(const JSONRPCRequest& request)
LOCK2(cs_main, pwallet->cs_wallet); LOCK2(cs_main, pwallet->cs_wallet);
if (pwallet->GetBroadcastTransactions() && !g_connman) if (pwallet->GetBroadcastTransactions() && !g_connman) {
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled"); throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
}
string strAccount = AccountFromValue(request.params[0]); string strAccount = AccountFromValue(request.params[0]);
UniValue sendTo = request.params[1].get_obj(); UniValue sendTo = request.params[1].get_obj();
@ -1032,8 +1053,9 @@ UniValue addmultisigaddress(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() < 2 || request.params.size() > 3) if (request.fHelp || request.params.size() < 2 || request.params.size() > 3)
{ {
@ -1130,8 +1152,9 @@ UniValue addwitnessaddress(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() < 1 || request.params.size() > 1) if (request.fHelp || request.params.size() < 1 || request.params.size() > 1)
{ {
@ -1205,9 +1228,8 @@ UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bool fByA
// Tally // Tally
map<CBitcoinAddress, tallyitem> mapTally; map<CBitcoinAddress, tallyitem> mapTally;
for (map<uint256, CWalletTx>::iterator it = pwallet->mapWallet.begin(); it != pwallet->mapWallet.end(); ++it) for (const std::pair<uint256, CWalletTx>& pairWtx : pwallet->mapWallet) {
{ const CWalletTx& wtx = pairWtx.second;
const CWalletTx& wtx = (*it).second;
if (wtx.IsCoinBase() || !CheckFinalTx(*wtx.tx)) if (wtx.IsCoinBase() || !CheckFinalTx(*wtx.tx))
continue; continue;
@ -1238,8 +1260,7 @@ UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bool fByA
// Reply // Reply
UniValue ret(UniValue::VARR); UniValue ret(UniValue::VARR);
map<string, tallyitem> mapAccountTally; map<string, tallyitem> mapAccountTally;
BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, CAddressBookData)& item, pwallet->mapAddressBook) for (const std::pair<CBitcoinAddress, CAddressBookData>& item : pwallet->mapAddressBook) {
{
const CBitcoinAddress& address = item.first; const CBitcoinAddress& address = item.first;
const string& strAccount = item.second.name; const string& strAccount = item.second.name;
map<CBitcoinAddress, tallyitem>::iterator it = mapTally.find(address); map<CBitcoinAddress, tallyitem>::iterator it = mapTally.find(address);
@ -1310,8 +1331,9 @@ UniValue listreceivedbyaddress(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() > 3) if (request.fHelp || request.params.size() > 3)
throw runtime_error( throw runtime_error(
@ -1354,8 +1376,9 @@ UniValue listreceivedbyaccount(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() > 3) if (request.fHelp || request.params.size() > 3)
throw runtime_error( throw runtime_error(
@ -1414,14 +1437,16 @@ void ListTransactions(CWallet * const pwallet, const CWalletTx& wtx, const strin
BOOST_FOREACH(const COutputEntry& s, listSent) BOOST_FOREACH(const COutputEntry& s, listSent)
{ {
UniValue entry(UniValue::VOBJ); UniValue entry(UniValue::VOBJ);
if(involvesWatchonly || (::IsMine(*pwallet, s.destination) & ISMINE_WATCH_ONLY)) if (involvesWatchonly || (::IsMine(*pwallet, s.destination) & ISMINE_WATCH_ONLY)) {
entry.push_back(Pair("involvesWatchonly", true)); entry.push_back(Pair("involvesWatchonly", true));
}
entry.push_back(Pair("account", strSentAccount)); entry.push_back(Pair("account", strSentAccount));
MaybePushAddress(entry, s.destination); MaybePushAddress(entry, s.destination);
entry.push_back(Pair("category", "send")); entry.push_back(Pair("category", "send"));
entry.push_back(Pair("amount", ValueFromAmount(-s.amount))); entry.push_back(Pair("amount", ValueFromAmount(-s.amount)));
if (pwallet->mapAddressBook.count(s.destination)) if (pwallet->mapAddressBook.count(s.destination)) {
entry.push_back(Pair("label", pwallet->mapAddressBook[s.destination].name)); entry.push_back(Pair("label", pwallet->mapAddressBook[s.destination].name));
}
entry.push_back(Pair("vout", s.vout)); entry.push_back(Pair("vout", s.vout));
entry.push_back(Pair("fee", ValueFromAmount(-nFee))); entry.push_back(Pair("fee", ValueFromAmount(-nFee)));
if (fLong) if (fLong)
@ -1437,13 +1462,15 @@ void ListTransactions(CWallet * const pwallet, const CWalletTx& wtx, const strin
BOOST_FOREACH(const COutputEntry& r, listReceived) BOOST_FOREACH(const COutputEntry& r, listReceived)
{ {
string account; string account;
if (pwallet->mapAddressBook.count(r.destination)) if (pwallet->mapAddressBook.count(r.destination)) {
account = pwallet->mapAddressBook[r.destination].name; account = pwallet->mapAddressBook[r.destination].name;
}
if (fAllAccounts || (account == strAccount)) if (fAllAccounts || (account == strAccount))
{ {
UniValue entry(UniValue::VOBJ); UniValue entry(UniValue::VOBJ);
if(involvesWatchonly || (::IsMine(*pwallet, r.destination) & ISMINE_WATCH_ONLY)) if (involvesWatchonly || (::IsMine(*pwallet, r.destination) & ISMINE_WATCH_ONLY)) {
entry.push_back(Pair("involvesWatchonly", true)); entry.push_back(Pair("involvesWatchonly", true));
}
entry.push_back(Pair("account", account)); entry.push_back(Pair("account", account));
MaybePushAddress(entry, r.destination); MaybePushAddress(entry, r.destination);
if (wtx.IsCoinBase()) if (wtx.IsCoinBase())
@ -1460,8 +1487,9 @@ void ListTransactions(CWallet * const pwallet, const CWalletTx& wtx, const strin
entry.push_back(Pair("category", "receive")); entry.push_back(Pair("category", "receive"));
} }
entry.push_back(Pair("amount", ValueFromAmount(r.amount))); entry.push_back(Pair("amount", ValueFromAmount(r.amount)));
if (pwallet->mapAddressBook.count(r.destination)) if (pwallet->mapAddressBook.count(r.destination)) {
entry.push_back(Pair("label", account)); entry.push_back(Pair("label", account));
}
entry.push_back(Pair("vout", r.vout)); entry.push_back(Pair("vout", r.vout));
if (fLong) if (fLong)
WalletTxToJSON(wtx, entry); WalletTxToJSON(wtx, entry);
@ -1492,8 +1520,9 @@ UniValue listtransactions(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() > 4) if (request.fHelp || request.params.size() > 4)
throw runtime_error( throw runtime_error(
@ -1622,8 +1651,9 @@ UniValue listaccounts(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() > 2) if (request.fHelp || request.params.size() > 2)
throw runtime_error( throw runtime_error(
@ -1659,14 +1689,14 @@ UniValue listaccounts(const JSONRPCRequest& request)
includeWatchonly = includeWatchonly | ISMINE_WATCH_ONLY; includeWatchonly = includeWatchonly | ISMINE_WATCH_ONLY;
map<string, CAmount> mapAccountBalances; map<string, CAmount> mapAccountBalances;
BOOST_FOREACH(const PAIRTYPE(CTxDestination, CAddressBookData)& entry, pwallet->mapAddressBook) { for (const std::pair<CTxDestination, CAddressBookData>& entry : pwallet->mapAddressBook) {
if (IsMine(*pwallet, entry.first) & includeWatchonly) // This address belongs to me if (IsMine(*pwallet, entry.first) & includeWatchonly) { // This address belongs to me
mapAccountBalances[entry.second.name] = 0; mapAccountBalances[entry.second.name] = 0;
} }
}
for (map<uint256, CWalletTx>::iterator it = pwallet->mapWallet.begin(); it != pwallet->mapWallet.end(); ++it) for (const std::pair<uint256, CWalletTx>& pairWtx : pwallet->mapWallet) {
{ const CWalletTx& wtx = pairWtx.second;
const CWalletTx& wtx = (*it).second;
CAmount nFee; CAmount nFee;
string strSentAccount; string strSentAccount;
list<COutputEntry> listReceived; list<COutputEntry> listReceived;
@ -1681,8 +1711,9 @@ UniValue listaccounts(const JSONRPCRequest& request)
if (nDepth >= nMinDepth) if (nDepth >= nMinDepth)
{ {
BOOST_FOREACH(const COutputEntry& r, listReceived) BOOST_FOREACH(const COutputEntry& r, listReceived)
if (pwallet->mapAddressBook.count(r.destination)) if (pwallet->mapAddressBook.count(r.destination)) {
mapAccountBalances[pwallet->mapAddressBook[r.destination].name] += r.amount; mapAccountBalances[pwallet->mapAddressBook[r.destination].name] += r.amount;
}
else else
mapAccountBalances[""] += r.amount; mapAccountBalances[""] += r.amount;
} }
@ -1703,8 +1734,9 @@ UniValue listsinceblock(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp) if (request.fHelp)
throw runtime_error( throw runtime_error(
@ -1789,9 +1821,8 @@ UniValue listsinceblock(const JSONRPCRequest& request)
UniValue transactions(UniValue::VARR); UniValue transactions(UniValue::VARR);
for (map<uint256, CWalletTx>::iterator it = pwallet->mapWallet.begin(); it != pwallet->mapWallet.end(); it++) for (const std::pair<uint256, CWalletTx>& pairWtx : pwallet->mapWallet) {
{ CWalletTx tx = pairWtx.second;
CWalletTx tx = (*it).second;
if (depth == -1 || tx.GetDepthInMainChain() < depth) if (depth == -1 || tx.GetDepthInMainChain() < depth)
ListTransactions(pwallet, tx, "*", 0, true, transactions, filter); ListTransactions(pwallet, tx, "*", 0, true, transactions, filter);
@ -1811,8 +1842,9 @@ UniValue gettransaction(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2) if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
throw runtime_error( throw runtime_error(
@ -1870,8 +1902,9 @@ UniValue gettransaction(const JSONRPCRequest& request)
filter = filter | ISMINE_WATCH_ONLY; filter = filter | ISMINE_WATCH_ONLY;
UniValue entry(UniValue::VOBJ); UniValue entry(UniValue::VOBJ);
if (!pwallet->mapWallet.count(hash)) if (!pwallet->mapWallet.count(hash)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid or non-wallet transaction id"); throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid or non-wallet transaction id");
}
const CWalletTx& wtx = pwallet->mapWallet[hash]; const CWalletTx& wtx = pwallet->mapWallet[hash];
CAmount nCredit = wtx.GetCredit(filter); CAmount nCredit = wtx.GetCredit(filter);
@ -1899,8 +1932,9 @@ UniValue abandontransaction(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() != 1) if (request.fHelp || request.params.size() != 1)
throw runtime_error( throw runtime_error(
@ -1923,10 +1957,12 @@ UniValue abandontransaction(const JSONRPCRequest& request)
uint256 hash; uint256 hash;
hash.SetHex(request.params[0].get_str()); hash.SetHex(request.params[0].get_str());
if (!pwallet->mapWallet.count(hash)) if (!pwallet->mapWallet.count(hash)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid or non-wallet transaction id"); throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid or non-wallet transaction id");
if (!pwallet->AbandonTransaction(hash)) }
if (!pwallet->AbandonTransaction(hash)) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not eligible for abandonment"); throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not eligible for abandonment");
}
return NullUniValue; return NullUniValue;
} }
@ -1936,8 +1972,9 @@ UniValue backupwallet(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() != 1) if (request.fHelp || request.params.size() != 1)
throw runtime_error( throw runtime_error(
@ -1953,8 +1990,9 @@ UniValue backupwallet(const JSONRPCRequest& request)
LOCK2(cs_main, pwallet->cs_wallet); LOCK2(cs_main, pwallet->cs_wallet);
string strDest = request.params[0].get_str(); string strDest = request.params[0].get_str();
if (!pwallet->BackupWallet(strDest)) if (!pwallet->BackupWallet(strDest)) {
throw JSONRPCError(RPC_WALLET_ERROR, "Error: Wallet backup failed!"); throw JSONRPCError(RPC_WALLET_ERROR, "Error: Wallet backup failed!");
}
return NullUniValue; return NullUniValue;
} }
@ -1964,8 +2002,9 @@ UniValue keypoolrefill(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() > 1) if (request.fHelp || request.params.size() > 1)
throw runtime_error( throw runtime_error(
@ -1992,8 +2031,9 @@ UniValue keypoolrefill(const JSONRPCRequest& request)
EnsureWalletIsUnlocked(pwallet); EnsureWalletIsUnlocked(pwallet);
pwallet->TopUpKeyPool(kpSize); pwallet->TopUpKeyPool(kpSize);
if (pwallet->GetKeyPoolSize() < kpSize) if (pwallet->GetKeyPoolSize() < kpSize) {
throw JSONRPCError(RPC_WALLET_ERROR, "Error refreshing keypool."); throw JSONRPCError(RPC_WALLET_ERROR, "Error refreshing keypool.");
}
return NullUniValue; return NullUniValue;
} }
@ -2010,10 +2050,11 @@ UniValue walletpassphrase(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (pwallet->IsCrypted() && (request.fHelp || request.params.size() != 2)) if (pwallet->IsCrypted() && (request.fHelp || request.params.size() != 2)) {
throw runtime_error( throw runtime_error(
"walletpassphrase \"passphrase\" timeout\n" "walletpassphrase \"passphrase\" timeout\n"
"\nStores the wallet decryption key in memory for 'timeout' seconds.\n" "\nStores the wallet decryption key in memory for 'timeout' seconds.\n"
@ -2032,13 +2073,15 @@ UniValue walletpassphrase(const JSONRPCRequest& request)
"\nAs json rpc call\n" "\nAs json rpc call\n"
+ HelpExampleRpc("walletpassphrase", "\"my pass phrase\", 60") + HelpExampleRpc("walletpassphrase", "\"my pass phrase\", 60")
); );
}
LOCK2(cs_main, pwallet->cs_wallet); LOCK2(cs_main, pwallet->cs_wallet);
if (request.fHelp) if (request.fHelp)
return true; return true;
if (!pwallet->IsCrypted()) if (!pwallet->IsCrypted()) {
throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletpassphrase was called."); throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletpassphrase was called.");
}
// Note that the walletpassphrase is stored in request.params[0] which is not mlock()ed // Note that the walletpassphrase is stored in request.params[0] which is not mlock()ed
SecureString strWalletPass; SecureString strWalletPass;
@ -2049,9 +2092,10 @@ UniValue walletpassphrase(const JSONRPCRequest& request)
if (strWalletPass.length() > 0) if (strWalletPass.length() > 0)
{ {
if (!pwallet->Unlock(strWalletPass)) if (!pwallet->Unlock(strWalletPass)) {
throw JSONRPCError(RPC_WALLET_PASSPHRASE_INCORRECT, "Error: The wallet passphrase entered was incorrect."); throw JSONRPCError(RPC_WALLET_PASSPHRASE_INCORRECT, "Error: The wallet passphrase entered was incorrect.");
} }
}
else else
throw runtime_error( throw runtime_error(
"walletpassphrase <passphrase> <timeout>\n" "walletpassphrase <passphrase> <timeout>\n"
@ -2071,10 +2115,11 @@ UniValue walletpassphrasechange(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (pwallet->IsCrypted() && (request.fHelp || request.params.size() != 2)) if (pwallet->IsCrypted() && (request.fHelp || request.params.size() != 2)) {
throw runtime_error( throw runtime_error(
"walletpassphrasechange \"oldpassphrase\" \"newpassphrase\"\n" "walletpassphrasechange \"oldpassphrase\" \"newpassphrase\"\n"
"\nChanges the wallet passphrase from 'oldpassphrase' to 'newpassphrase'.\n" "\nChanges the wallet passphrase from 'oldpassphrase' to 'newpassphrase'.\n"
@ -2085,13 +2130,15 @@ UniValue walletpassphrasechange(const JSONRPCRequest& request)
+ HelpExampleCli("walletpassphrasechange", "\"old one\" \"new one\"") + HelpExampleCli("walletpassphrasechange", "\"old one\" \"new one\"")
+ HelpExampleRpc("walletpassphrasechange", "\"old one\", \"new one\"") + HelpExampleRpc("walletpassphrasechange", "\"old one\", \"new one\"")
); );
}
LOCK2(cs_main, pwallet->cs_wallet); LOCK2(cs_main, pwallet->cs_wallet);
if (request.fHelp) if (request.fHelp)
return true; return true;
if (!pwallet->IsCrypted()) if (!pwallet->IsCrypted()) {
throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletpassphrasechange was called."); throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletpassphrasechange was called.");
}
// TODO: get rid of these .c_str() calls by implementing SecureString::operator=(std::string) // TODO: get rid of these .c_str() calls by implementing SecureString::operator=(std::string)
// Alternately, find a way to make request.params[0] mlock()'d to begin with. // Alternately, find a way to make request.params[0] mlock()'d to begin with.
@ -2108,8 +2155,9 @@ UniValue walletpassphrasechange(const JSONRPCRequest& request)
"walletpassphrasechange <oldpassphrase> <newpassphrase>\n" "walletpassphrasechange <oldpassphrase> <newpassphrase>\n"
"Changes the wallet passphrase from <oldpassphrase> to <newpassphrase>."); "Changes the wallet passphrase from <oldpassphrase> to <newpassphrase>.");
if (!pwallet->ChangeWalletPassphrase(strOldWalletPass, strNewWalletPass)) if (!pwallet->ChangeWalletPassphrase(strOldWalletPass, strNewWalletPass)) {
throw JSONRPCError(RPC_WALLET_PASSPHRASE_INCORRECT, "Error: The wallet passphrase entered was incorrect."); throw JSONRPCError(RPC_WALLET_PASSPHRASE_INCORRECT, "Error: The wallet passphrase entered was incorrect.");
}
return NullUniValue; return NullUniValue;
} }
@ -2119,10 +2167,11 @@ UniValue walletlock(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (pwallet->IsCrypted() && (request.fHelp || request.params.size() != 0)) if (pwallet->IsCrypted() && (request.fHelp || request.params.size() != 0)) {
throw runtime_error( throw runtime_error(
"walletlock\n" "walletlock\n"
"\nRemoves the wallet encryption key from memory, locking the wallet.\n" "\nRemoves the wallet encryption key from memory, locking the wallet.\n"
@ -2138,13 +2187,15 @@ UniValue walletlock(const JSONRPCRequest& request)
"\nAs json rpc call\n" "\nAs json rpc call\n"
+ HelpExampleRpc("walletlock", "") + HelpExampleRpc("walletlock", "")
); );
}
LOCK2(cs_main, pwallet->cs_wallet); LOCK2(cs_main, pwallet->cs_wallet);
if (request.fHelp) if (request.fHelp)
return true; return true;
if (!pwallet->IsCrypted()) if (!pwallet->IsCrypted()) {
throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletlock was called."); throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletlock was called.");
}
pwallet->Lock(); pwallet->Lock();
pwallet->nRelockTime = 0; pwallet->nRelockTime = 0;
@ -2157,10 +2208,11 @@ UniValue encryptwallet(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (!pwallet->IsCrypted() && (request.fHelp || request.params.size() != 1)) if (!pwallet->IsCrypted() && (request.fHelp || request.params.size() != 1)) {
throw runtime_error( throw runtime_error(
"encryptwallet \"passphrase\"\n" "encryptwallet \"passphrase\"\n"
"\nEncrypts the wallet with 'passphrase'. This is for first time encryption.\n" "\nEncrypts the wallet with 'passphrase'. This is for first time encryption.\n"
@ -2183,13 +2235,15 @@ UniValue encryptwallet(const JSONRPCRequest& request)
"\nAs a json rpc call\n" "\nAs a json rpc call\n"
+ HelpExampleRpc("encryptwallet", "\"my pass phrase\"") + HelpExampleRpc("encryptwallet", "\"my pass phrase\"")
); );
}
LOCK2(cs_main, pwallet->cs_wallet); LOCK2(cs_main, pwallet->cs_wallet);
if (request.fHelp) if (request.fHelp)
return true; return true;
if (pwallet->IsCrypted()) if (pwallet->IsCrypted()) {
throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an encrypted wallet, but encryptwallet was called."); throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an encrypted wallet, but encryptwallet was called.");
}
// TODO: get rid of this .c_str() by implementing SecureString::operator=(std::string) // TODO: get rid of this .c_str() by implementing SecureString::operator=(std::string)
// Alternately, find a way to make request.params[0] mlock()'d to begin with. // Alternately, find a way to make request.params[0] mlock()'d to begin with.
@ -2202,8 +2256,9 @@ UniValue encryptwallet(const JSONRPCRequest& request)
"encryptwallet <passphrase>\n" "encryptwallet <passphrase>\n"
"Encrypts the wallet with <passphrase>."); "Encrypts the wallet with <passphrase>.");
if (!pwallet->EncryptWallet(strWalletPass)) if (!pwallet->EncryptWallet(strWalletPass)) {
throw JSONRPCError(RPC_WALLET_ENCRYPTION_FAILED, "Error: Failed to encrypt the wallet."); throw JSONRPCError(RPC_WALLET_ENCRYPTION_FAILED, "Error: Failed to encrypt the wallet.");
}
// BDB seems to have a bad habit of writing old data into // BDB seems to have a bad habit of writing old data into
// slack space in .dat files; that is bad if the old data is // slack space in .dat files; that is bad if the old data is
@ -2216,8 +2271,9 @@ UniValue lockunspent(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2) if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
throw runtime_error( throw runtime_error(
@ -2307,8 +2363,9 @@ UniValue listlockunspent(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() > 0) if (request.fHelp || request.params.size() > 0)
throw runtime_error( throw runtime_error(
@ -2358,8 +2415,9 @@ UniValue settxfee(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() < 1 || request.params.size() > 1) if (request.fHelp || request.params.size() < 1 || request.params.size() > 1)
throw runtime_error( throw runtime_error(
@ -2387,8 +2445,9 @@ UniValue getwalletinfo(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() != 0) if (request.fHelp || request.params.size() != 0)
throw runtime_error( throw runtime_error(
@ -2422,8 +2481,9 @@ UniValue getwalletinfo(const JSONRPCRequest& request)
obj.push_back(Pair("txcount", (int)pwallet->mapWallet.size())); obj.push_back(Pair("txcount", (int)pwallet->mapWallet.size()));
obj.push_back(Pair("keypoololdest", pwallet->GetOldestKeyPoolTime())); obj.push_back(Pair("keypoololdest", pwallet->GetOldestKeyPoolTime()));
obj.push_back(Pair("keypoolsize", (int)pwallet->GetKeyPoolSize())); obj.push_back(Pair("keypoolsize", (int)pwallet->GetKeyPoolSize()));
if (pwallet->IsCrypted()) if (pwallet->IsCrypted()) {
obj.push_back(Pair("unlocked_until", pwallet->nRelockTime)); obj.push_back(Pair("unlocked_until", pwallet->nRelockTime));
}
obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK()))); obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK())));
CKeyID masterKeyID = pwallet->GetHDChain().masterKeyID; CKeyID masterKeyID = pwallet->GetHDChain().masterKeyID;
if (!masterKeyID.IsNull()) if (!masterKeyID.IsNull())
@ -2435,8 +2495,9 @@ UniValue resendwallettransactions(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() != 0) if (request.fHelp || request.params.size() != 0)
throw runtime_error( throw runtime_error(
@ -2465,8 +2526,9 @@ UniValue listunspent(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() > 4) if (request.fHelp || request.params.size() > 4)
throw runtime_error( throw runtime_error(
@ -2565,16 +2627,18 @@ UniValue listunspent(const JSONRPCRequest& request)
if (fValidAddress) { if (fValidAddress) {
entry.push_back(Pair("address", CBitcoinAddress(address).ToString())); entry.push_back(Pair("address", CBitcoinAddress(address).ToString()));
if (pwallet->mapAddressBook.count(address)) if (pwallet->mapAddressBook.count(address)) {
entry.push_back(Pair("account", pwallet->mapAddressBook[address].name)); entry.push_back(Pair("account", pwallet->mapAddressBook[address].name));
}
if (scriptPubKey.IsPayToScriptHash()) { if (scriptPubKey.IsPayToScriptHash()) {
const CScriptID& hash = boost::get<CScriptID>(address); const CScriptID& hash = boost::get<CScriptID>(address);
CScript redeemScript; CScript redeemScript;
if (pwallet->GetCScript(hash, redeemScript)) if (pwallet->GetCScript(hash, redeemScript)) {
entry.push_back(Pair("redeemScript", HexStr(redeemScript.begin(), redeemScript.end()))); entry.push_back(Pair("redeemScript", HexStr(redeemScript.begin(), redeemScript.end())));
} }
} }
}
entry.push_back(Pair("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end()))); entry.push_back(Pair("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end())));
entry.push_back(Pair("amount", ValueFromAmount(out.tx->tx->vout[out.i].nValue))); entry.push_back(Pair("amount", ValueFromAmount(out.tx->tx->vout[out.i].nValue)));
@ -2591,8 +2655,9 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
{ {
CWallet * const pwallet = GetWalletForJSONRPCRequest(request); CWallet * const pwallet = GetWalletForJSONRPCRequest(request);
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue; return NullUniValue;
}
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2) if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
throw runtime_error( throw runtime_error(
@ -2733,8 +2798,9 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
CAmount nFeeOut; CAmount nFeeOut;
string strFailReason; string strFailReason;
if(!pwallet->FundTransaction(tx, nFeeOut, overrideEstimatedFeerate, feeRate, changePosition, strFailReason, includeWatching, lockUnspents, setSubtractFeeFromOutputs, reserveChangeKey, changeAddress)) if (!pwallet->FundTransaction(tx, nFeeOut, overrideEstimatedFeerate, feeRate, changePosition, strFailReason, includeWatching, lockUnspents, setSubtractFeeFromOutputs, reserveChangeKey, changeAddress)) {
throw JSONRPCError(RPC_INTERNAL_ERROR, strFailReason); throw JSONRPCError(RPC_INTERNAL_ERROR, strFailReason);
}
UniValue result(UniValue::VOBJ); UniValue result(UniValue::VOBJ);
result.push_back(Pair("hex", EncodeHexTx(tx))); result.push_back(Pair("hex", EncodeHexTx(tx)));

Loading…
Cancel
Save