diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index ddd9f0e982..c169e3190d 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -24,6 +24,7 @@ #include "txmempool.h" #include "uint256.h" #include "utilstrencodings.h" +#include "util.h" #ifdef ENABLE_WALLET #include "wallet/wallet.h" #endif @@ -1052,6 +1053,8 @@ UniValue signrawtransaction(const UniValue& params, bool fHelp) result.push_back(Pair("errors", vErrors)); } + AuditLogPrintf("%s : signrawtransaction %s\n", getUser(), EncodeHexTx(mergedTx)); + return result; } @@ -1127,6 +1130,8 @@ UniValue sendrawtransaction(const UniValue& params, bool fHelp) } RelayTransaction(tx); + AuditLogPrintf("%s : sendrawtransaction %s\n", getUser(), tx.ToString()); + return hashTx.GetHex(); } diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index a88aa78d0b..ec92c22c00 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -149,6 +149,8 @@ UniValue importprivkey(const UniValue& params, bool fHelp) } } + AuditLogPrintf("%s : importprivkey %s\n", getUser(), pubkey.GetHash().GetHex()); + return NullUniValue; } @@ -249,6 +251,8 @@ UniValue importaddress(const UniValue& params, bool fHelp) pwalletMain->ReacceptWalletTransactions(); } + AuditLogPrintf("%s : importaddress %s\n", getUser(), params[0].get_str()); + return NullUniValue; } @@ -403,6 +407,8 @@ UniValue importpubkey(const UniValue& params, bool fHelp) pwalletMain->ReacceptWalletTransactions(); } + AuditLogPrintf("%s : importpubkey %s\n", getUser(), params[0].get_str()); + return NullUniValue; } @@ -511,6 +517,8 @@ UniValue importwallet(const UniValue& params, bool fHelp) if (!fGood) throw JSONRPCError(RPC_WALLET_ERROR, "Error adding some keys to wallet"); + AuditLogPrintf("%s : importwallet %s\n", getUser(), params[0].get_str()); + return NullUniValue; } @@ -548,6 +556,9 @@ UniValue dumpprivkey(const UniValue& params, bool fHelp) CKey vchSecret; if (!pwalletMain->GetKey(keyID, vchSecret)) throw JSONRPCError(RPC_WALLET_ERROR, "Private key for address " + strAddress + " is not known"); + + AuditLogPrintf("%s : dumpprivkey %s\n", getUser(), strAddress); + return CBitcoinSecret(vchSecret).ToString(); } @@ -637,6 +648,9 @@ UniValue dumpwallet(const UniValue& params, bool fHelp) file << "\n"; file << "# End of dump\n"; file.close(); + + AuditLogPrintf("%s : dumpwallet %s\n", getUser(), params[0].get_str()); + return NullUniValue; } @@ -670,6 +684,7 @@ UniValue dumpblindingkey(const UniValue& params, bool fHelp) if (key.IsValid()) { CPubKey pubkey = key.GetPubKey(); if (pubkey == address.GetBlindingKey()) { + AuditLogPrintf("%s : dumpblindingkey %s\n", getUser(), address.ToString()); return HexStr(key.begin(), key.end()); } } @@ -678,6 +693,7 @@ UniValue dumpblindingkey(const UniValue& params, bool fHelp) if (key.IsValid()) { CPubKey pubkey = key.GetPubKey(); if (pubkey == address.GetBlindingKey()) { + AuditLogPrintf("%s : dumpblindingkey %s\n", getUser(), address.ToString()); return HexStr(key.begin(), key.end()); } } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e8e0a811c0..3306e14d0b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -442,7 +442,7 @@ UniValue sendtoaddress(const UniValue& params, bool fHelp) SendMoney(address.Get(), nAmount, fSubtractFeeFromAmount, confidentiality_pubkey, wtx); - AuditLogPrintf("%s : sendtoaddress %s %d", getUser(), wtx.GetHash().GetHex(), nAmount); + AuditLogPrintf("%s : sendtoaddress %s %s txid:%s\n", getUser(), params[0].get_str(), params[1].getValStr(), wtx.GetHash().GetHex()); return wtx.GetHash().GetHex(); } @@ -874,6 +874,8 @@ UniValue sendfrom(const UniValue& params, bool fHelp) SendMoney(address.Get(), nAmount, false, confidentiality_pubkey, wtx); + AuditLogPrintf("%s : sendfrom %s %s %s txid:%s\n", getUser(), params[0].get_str(), params[1].get_str(), params[2].getValStr(), wtx.GetHash().GetHex()); + return wtx.GetHash().GetHex(); } @@ -939,6 +941,9 @@ UniValue sendmany(const UniValue& params, bool fHelp) set setAddress; vector vecSend; + std::string strAudit(getUser()); + strAudit += " : sendmany \n"; + CAmount totalAmount = 0; vector keys = sendTo.getKeys(); BOOST_FOREACH(const string& name_, keys) @@ -957,6 +962,7 @@ UniValue sendmany(const UniValue& params, bool fHelp) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); totalAmount += nAmount; + strAudit += name_ + " " + sendTo[name_].getValStr() + "\n"; CPubKey confidentiality_pubkey; if (address.IsBlinded()) @@ -971,6 +977,7 @@ UniValue sendmany(const UniValue& params, bool fHelp) CRecipient recipient = {scriptPubKey, nAmount, confidentiality_pubkey, fSubtractFeeFromAmount}; vecSend.push_back(recipient); + } EnsureWalletIsUnlocked(); @@ -991,6 +998,8 @@ UniValue sendmany(const UniValue& params, bool fHelp) if (!pwalletMain->CommitTransaction(wtx, keyChange)) throw JSONRPCError(RPC_WALLET_ERROR, "Transaction commit failed"); + AuditLogPrintf("%s", strAudit); + return wtx.GetHash().GetHex(); } @@ -1042,6 +1051,9 @@ UniValue addmultisigaddress(const UniValue& params, bool fHelp) pwalletMain->AddCScript(inner); pwalletMain->SetAddressBook(innerID, strAccount, "send"); + + AuditLogPrintf("%s : addmultisigaddress %s\n", getUser(), CBitcoinAddress(innerID).ToString()); + return CBitcoinAddress(innerID).ToString(); } @@ -1131,6 +1143,8 @@ UniValue addwitnessaddress(const UniValue& params, bool fHelp) pwalletMain->SetAddressBook(w.result, "", "receive"); + AuditLogPrintf("%s : addwitnessaddress %s\n", getUser(), CBitcoinAddress(w.result).ToString()); + return CBitcoinAddress(w.result).ToString(); } @@ -1889,6 +1903,8 @@ UniValue backupwallet(const UniValue& params, bool fHelp) if (!pwalletMain->BackupWallet(strDest)) throw JSONRPCError(RPC_WALLET_ERROR, "Error: Wallet backup failed!"); + AuditLogPrintf("%s : backupwallet %s\n", getUser(), strDest); + return NullUniValue; } @@ -1993,6 +2009,8 @@ UniValue walletpassphrase(const UniValue& params, bool fHelp) nWalletUnlockTime = GetTime() + nSleepTime; RPCRunLater("lockwallet", boost::bind(LockWallet, pwalletMain), nSleepTime); + AuditLogPrintf("%s : walletpassphrase\n", getUser()); + return NullUniValue; } @@ -2039,6 +2057,8 @@ UniValue walletpassphrasechange(const UniValue& params, bool fHelp) if (!pwalletMain->ChangeWalletPassphrase(strOldWalletPass, strNewWalletPass)) throw JSONRPCError(RPC_WALLET_PASSPHRASE_INCORRECT, "Error: The wallet passphrase entered was incorrect."); + AuditLogPrintf("%s : walletpassphrasechange\n", getUser()); + return NullUniValue; } @@ -2132,6 +2152,8 @@ UniValue encryptwallet(const UniValue& params, bool fHelp) if (!pwalletMain->EncryptWallet(strWalletPass)) throw JSONRPCError(RPC_WALLET_ENCRYPTION_FAILED, "Error: Failed to encrypt the wallet."); + AuditLogPrintf("%s : encryptwallet\n", getUser()); + // 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 // unencrypted private keys. So: @@ -2301,6 +2323,9 @@ UniValue settxfee(const UniValue& params, bool fHelp) CAmount nAmount = AmountFromValue(params[0]); payTxFee = CFeeRate(nAmount, 1000); + + AuditLogPrintf("%s : settxfee %s\n", getUser(), params[0].getValStr()); + return true; } @@ -2767,6 +2792,8 @@ UniValue getpeginaddress(const UniValue& params, bool fHelp) UniValue fundinginfo(UniValue::VOBJ); + AuditLogPrintf("%s : getpeginaddress mainaddress: %s address: %s\n", getUser(), destAddr.ToString(), address.ToString()); + fundinginfo.pushKV("mainaddress", destAddr.ToString()); fundinginfo.pushKV("address", address.ToString()); return fundinginfo; @@ -2840,6 +2867,8 @@ UniValue sendtomainchain(const UniValue& params, bool fHelp) CWalletTx wtxNew; SendMoney(scriptPubKey, nAmount, false, CPubKey(), wtxNew); + AuditLogPrintf("%s : sendtomainchain %s\n", getUser(), wtxNew.ToString()); + return wtxNew.GetHash().GetHex(); } @@ -2969,7 +2998,10 @@ UniValue claimpegin(const UniValue& params, bool fHelp) CTransaction finalTxn(mtxn); UniValue signedTxnArray(UniValue::VARR); signedTxnArray.push_back(EncodeHexTx(finalTxn)); - return sendrawtransaction(signedTxnArray, false); + + sendrawtransaction(signedTxnArray, false); + AuditLogPrintf("%s : claimpegin %s\n", getUser(), finalTxn.ToString()); + return finalTxn.GetHash().GetHex(); } extern UniValue dumpprivkey(const UniValue& params, bool fHelp); // in rpcdump.cpp