Skip to content

Commit

Permalink
Trivial: Reformat touched lines with C++11
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-jr committed Oct 25, 2016
1 parent 324abf4 commit ab5ce98
Show file tree
Hide file tree
Showing 4 changed files with 224 additions and 139 deletions.
15 changes: 8 additions & 7 deletions src/rpc/misc.cpp
Expand Up @@ -103,8 +103,9 @@ UniValue getinfo(const JSONRPCRequest& request)
obj.push_back(Pair("keypoololdest", pwallet->GetOldestKeyPoolTime()));
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("paytxfee", ValueFromAmount(payTxFee.GetFeePerK())));
#endif
obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK())));
Expand Down Expand Up @@ -211,11 +212,11 @@ UniValue validateaddress(const JSONRPCRequest& request)
ret.push_back(Pair("iswatchonly", (mine & ISMINE_WATCH_ONLY) ? true: false));
UniValue detail = boost::apply_visitor(DescribeAddressVisitor(pwallet), dest);
ret.pushKVs(detail);
if (pwallet && pwallet->mapAddressBook.count(dest))
if (pwallet && pwallet->mapAddressBook.count(dest)) {
ret.push_back(Pair("account", pwallet->mapAddressBook[dest].name));
}
CKeyID keyID;
if (pwallet && address.GetKeyID(keyID) && pwallet->mapKeyMetadata.count(keyID) && !pwallet->mapKeyMetadata[keyID].hdKeypath.empty())
{
if (pwallet && address.GetKeyID(keyID) && pwallet->mapKeyMetadata.count(keyID) && !pwallet->mapKeyMetadata[keyID].hdKeypath.empty()) {
ret.push_back(Pair("hdkeypath", pwallet->mapKeyMetadata[keyID].hdKeypath));
ret.push_back(Pair("hdmasterkeyid", pwallet->mapKeyMetadata[keyID].hdMasterKeyID.GetHex()));
}
Expand Down Expand Up @@ -252,16 +253,16 @@ CScript _createmultisig_redeemScript(void * const _pwallet, const UniValue& para
#ifdef ENABLE_WALLET
// Case 1: Bitcoin address and we have full public key:
CBitcoinAddress address(ks);
if (pwallet && address.IsValid())
{
if (pwallet && address.IsValid()) {
CKeyID keyID;
if (!address.GetKeyID(keyID))
throw runtime_error(
strprintf("%s does not refer to a key",ks));
CPubKey vchPubKey;
if (!pwallet->GetPubKey(keyID, vchPubKey))
if (!pwallet->GetPubKey(keyID, vchPubKey)) {
throw runtime_error(
strprintf("no full public key for address %s",ks));
}
if (!vchPubKey.IsFullyValid())
throw runtime_error(" Invalid public key: "+ks);
pubkeys[i] = vchPubKey;
Expand Down
3 changes: 2 additions & 1 deletion src/rpc/rawtransaction.cpp
Expand Up @@ -711,8 +711,9 @@ UniValue signrawtransaction(const JSONRPCRequest& request)
}
}
#ifdef ENABLE_WALLET
else if (pwallet)
else if (pwallet) {
EnsureWalletIsUnlocked(pwallet);
}
#endif

// Add previous txouts given in the RPC call:
Expand Down
52 changes: 33 additions & 19 deletions src/wallet/rpcdump.cpp
Expand Up @@ -80,8 +80,9 @@ UniValue importprivkey(const JSONRPCRequest& request)
{
CWallet * const pwallet = GetWalletForJSONRPCRequest(request);

if (!EnsureWalletIsAvailable(pwallet, request.fHelp))
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue;
}

if (request.fHelp || request.params.size() < 1 || request.params.size() > 3)
throw runtime_error(
Expand Down Expand Up @@ -137,13 +138,15 @@ UniValue importprivkey(const JSONRPCRequest& request)
pwallet->SetAddressBook(vchAddress, strLabel, "receive");

// Don't throw error in case a key is already there
if (pwallet->HaveKey(vchAddress))
if (pwallet->HaveKey(vchAddress)) {
return NullUniValue;
}

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");
}

// whenever a key is imported, we need to scan the whole chain
pwallet->nTimeFirstKey = 1; // 0 would be considered 'no value'
Expand All @@ -159,17 +162,20 @@ UniValue importprivkey(const JSONRPCRequest& request)
void ImportAddress(CWallet*, const CBitcoinAddress& address, const string& strLabel);
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");
}

pwallet->MarkDirty();

if (!pwallet->HaveWatchOnly(script) && !pwallet->AddWatchOnly(script))
if (!pwallet->HaveWatchOnly(script) && !pwallet->AddWatchOnly(script)) {
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding address to wallet");
}

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");
}
ImportAddress(pwallet, CBitcoinAddress(CScriptID(script)), strLabel);
} else {
CTxDestination destination;
Expand All @@ -192,8 +198,9 @@ UniValue importaddress(const JSONRPCRequest& request)
{
CWallet * const pwallet = GetWalletForJSONRPCRequest(request);

if (!EnsureWalletIsAvailable(pwallet, request.fHelp))
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue;
}

if (request.fHelp || request.params.size() < 1 || request.params.size() > 4)
throw runtime_error(
Expand Down Expand Up @@ -262,8 +269,9 @@ UniValue importprunedfunds(const JSONRPCRequest& request)
{
CWallet * const pwallet = GetWalletForJSONRPCRequest(request);

if (!EnsureWalletIsAvailable(pwallet, request.fHelp))
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue;
}

if (request.fHelp || request.params.size() != 2)
throw runtime_error(
Expand All @@ -278,7 +286,7 @@ UniValue importprunedfunds(const JSONRPCRequest& request)
if (!DecodeHexTx(tx, request.params[0].get_str()))
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
uint256 hashTx = tx.GetHash();
CWalletTx wtx(pwallet,tx);
CWalletTx wtx(pwallet, tx);

CDataStream ssMB(ParseHexV(request.params[1], "proof"), SER_NETWORK, PROTOCOL_VERSION);
CMerkleBlock merkleBlock;
Expand Down Expand Up @@ -323,8 +331,9 @@ UniValue removeprunedfunds(const JSONRPCRequest& request)
{
CWallet * const pwallet = GetWalletForJSONRPCRequest(request);

if (!EnsureWalletIsAvailable(pwallet, request.fHelp))
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue;
}

if (request.fHelp || request.params.size() != 1)
throw runtime_error(
Expand All @@ -346,7 +355,7 @@ UniValue removeprunedfunds(const JSONRPCRequest& request)
vHash.push_back(hash);
vector<uint256> vHashOut;

if(pwallet->ZapSelectTx(vHash, vHashOut) != DB_LOAD_OK) {
if (pwallet->ZapSelectTx(vHash, vHashOut) != DB_LOAD_OK) {
throw JSONRPCError(RPC_INTERNAL_ERROR, "Could not properly delete the transaction.");
}

Expand All @@ -361,8 +370,9 @@ UniValue importpubkey(const JSONRPCRequest& request)
{
CWallet * const pwallet = GetWalletForJSONRPCRequest(request);

if (!EnsureWalletIsAvailable(pwallet, request.fHelp))
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue;
}

if (request.fHelp || request.params.size() < 1 || request.params.size() > 4)
throw runtime_error(
Expand Down Expand Up @@ -421,8 +431,9 @@ UniValue importwallet(const JSONRPCRequest& request)
{
CWallet * const pwallet = GetWalletForJSONRPCRequest(request);

if (!EnsureWalletIsAvailable(pwallet, request.fHelp))
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue;
}

if (request.fHelp || request.params.size() != 1)
throw runtime_error(
Expand Down Expand Up @@ -513,8 +524,9 @@ UniValue importwallet(const JSONRPCRequest& request)
while (pindex && pindex->pprev && pindex->GetBlockTime() > nTimeBegin - 7200)
pindex = pindex->pprev;

if (!pwallet->nTimeFirstKey || nTimeBegin < pwallet->nTimeFirstKey)
if (!pwallet->nTimeFirstKey || nTimeBegin < pwallet->nTimeFirstKey) {
pwallet->nTimeFirstKey = nTimeBegin;
}

LogPrintf("Rescanning last %i blocks\n", chainActive.Height() - pindex->nHeight + 1);
pwallet->ScanForWalletTransactions(pindex);
Expand All @@ -530,8 +542,9 @@ UniValue dumpprivkey(const JSONRPCRequest& request)
{
CWallet * const pwallet = GetWalletForJSONRPCRequest(request);

if (!EnsureWalletIsAvailable(pwallet, request.fHelp))
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue;
}

if (request.fHelp || request.params.size() != 1)
throw runtime_error(
Expand Down Expand Up @@ -560,8 +573,9 @@ UniValue dumpprivkey(const JSONRPCRequest& request)
if (!address.GetKeyID(keyID))
throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to a key");
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");
}
return CBitcoinSecret(vchSecret).ToString();
}

Expand All @@ -570,8 +584,9 @@ UniValue dumpwallet(const JSONRPCRequest& request)
{
CWallet * const pwallet = GetWalletForJSONRPCRequest(request);

if (!EnsureWalletIsAvailable(pwallet, request.fHelp))
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
return NullUniValue;
}

if (request.fHelp || request.params.size() != 1)
throw runtime_error(
Expand Down Expand Up @@ -618,8 +633,7 @@ UniValue dumpwallet(const JSONRPCRequest& request)
if (!masterKeyID.IsNull())
{
CKey key;
if (pwallet->GetKey(masterKeyID, key))
{
if (pwallet->GetKey(masterKeyID, key)) {
CExtKey masterKey;
masterKey.SetMaster(key.begin(), key.size());

Expand Down

0 comments on commit ab5ce98

Please sign in to comment.