@ -27,8 +27,6 @@
# include <univalue.h>
# include <univalue.h>
using namespace std ;
CWallet * GetWalletForJSONRPCRequest ( const JSONRPCRequest & request )
CWallet * GetWalletForJSONRPCRequest ( const JSONRPCRequest & request )
{
{
return pwalletMain ;
return pwalletMain ;
@ -94,13 +92,13 @@ void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry)
}
}
entry . push_back ( Pair ( " bip125-replaceable " , rbfStatus ) ) ;
entry . push_back ( Pair ( " bip125-replaceable " , rbfStatus ) ) ;
BOOST_FOREACH ( const PAIRTYPE ( string , string ) & item , wtx . mapValue )
BOOST_FOREACH ( const PAIRTYPE ( std : : st ring , std : : string ) & item , wtx . mapValue )
entry . push_back ( Pair ( item . first , item . second ) ) ;
entry . push_back ( Pair ( item . first , item . second ) ) ;
}
}
string AccountFromValue ( const UniValue & value )
std : : string AccountFromValue ( const UniValue & value )
{
{
string strAccount = value . get_str ( ) ;
std : : st ring strAccount = value . get_str ( ) ;
if ( strAccount = = " * " )
if ( strAccount = = " * " )
throw JSONRPCError ( RPC_WALLET_INVALID_ACCOUNT_NAME , " Invalid account name " ) ;
throw JSONRPCError ( RPC_WALLET_INVALID_ACCOUNT_NAME , " Invalid account name " ) ;
return strAccount ;
return strAccount ;
@ -114,7 +112,7 @@ UniValue getnewaddress(const JSONRPCRequest& request)
}
}
if ( request . fHelp | | request . params . size ( ) > 1 )
if ( request . fHelp | | request . params . size ( ) > 1 )
throw runtime_error (
throw std : : runtime_error (
" getnewaddress ( \" account \" ) \n "
" getnewaddress ( \" account \" ) \n "
" \n Returns a new Bitcoin address for receiving payments. \n "
" \n Returns a new Bitcoin address for receiving payments. \n "
" If 'account' is specified (DEPRECATED), it is added to the address book \n "
" If 'account' is specified (DEPRECATED), it is added to the address book \n "
@ -131,7 +129,7 @@ UniValue getnewaddress(const JSONRPCRequest& request)
LOCK2 ( cs_main , pwallet - > cs_wallet ) ;
LOCK2 ( cs_main , pwallet - > cs_wallet ) ;
// Parse the account first so we don't generate a key if there's an error
// Parse the account first so we don't generate a key if there's an error
string strAccount ;
std : : st ring strAccount ;
if ( request . params . size ( ) > 0 )
if ( request . params . size ( ) > 0 )
strAccount = AccountFromValue ( request . params [ 0 ] ) ;
strAccount = AccountFromValue ( request . params [ 0 ] ) ;
@ -152,7 +150,7 @@ UniValue getnewaddress(const JSONRPCRequest& request)
}
}
CBitcoinAddress GetAccountAddress ( CWallet * const pwallet , string strAccount , bool bForceNew = false )
CBitcoinAddress GetAccountAddress ( CWallet * const pwallet , std : : string strAccount , bool bForceNew = false )
{
{
CPubKey pubKey ;
CPubKey pubKey ;
if ( ! pwallet - > GetAccountPubkey ( pubKey , strAccount , bForceNew ) ) {
if ( ! pwallet - > GetAccountPubkey ( pubKey , strAccount , bForceNew ) ) {
@ -170,7 +168,7 @@ UniValue getaccountaddress(const JSONRPCRequest& request)
}
}
if ( request . fHelp | | request . params . size ( ) ! = 1 )
if ( request . fHelp | | request . params . size ( ) ! = 1 )
throw runtime_error (
throw std : : runtime_error (
" getaccountaddress \" account \" \n "
" getaccountaddress \" account \" \n "
" \n DEPRECATED. Returns the current Bitcoin address for receiving payments to this account. \n "
" \n DEPRECATED. Returns the current Bitcoin address for receiving payments to this account. \n "
" \n Arguments: \n "
" \n Arguments: \n "
@ -187,7 +185,7 @@ UniValue getaccountaddress(const JSONRPCRequest& request)
LOCK2 ( cs_main , pwallet - > cs_wallet ) ;
LOCK2 ( cs_main , pwallet - > cs_wallet ) ;
// Parse the account first so we don't generate a key if there's an error
// Parse the account first so we don't generate a key if there's an error
string strAccount = AccountFromValue ( request . params [ 0 ] ) ;
std : : st ring strAccount = AccountFromValue ( request . params [ 0 ] ) ;
UniValue ret ( UniValue : : VSTR ) ;
UniValue ret ( UniValue : : VSTR ) ;
@ -204,7 +202,7 @@ UniValue getrawchangeaddress(const JSONRPCRequest& request)
}
}
if ( request . fHelp | | request . params . size ( ) > 1 )
if ( request . fHelp | | request . params . size ( ) > 1 )
throw runtime_error (
throw std : : runtime_error (
" getrawchangeaddress \n "
" getrawchangeaddress \n "
" \n Returns a new Bitcoin address, for receiving change. \n "
" \n Returns a new Bitcoin address, for receiving change. \n "
" This is for use with raw transactions, NOT normal use. \n "
" This is for use with raw transactions, NOT normal use. \n "
@ -242,7 +240,7 @@ UniValue setaccount(const JSONRPCRequest& request)
}
}
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 std : : runtime_error (
" setaccount \" address \" \" account \" \n "
" setaccount \" address \" \" account \" \n "
" \n DEPRECATED. Sets the account associated with the given address. \n "
" \n DEPRECATED. Sets the account associated with the given address. \n "
" \n Arguments: \n "
" \n Arguments: \n "
@ -259,7 +257,7 @@ UniValue setaccount(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 " ) ;
string strAccount ;
std : : st ring strAccount ;
if ( request . params . size ( ) > 1 )
if ( request . params . size ( ) > 1 )
strAccount = AccountFromValue ( request . params [ 1 ] ) ;
strAccount = AccountFromValue ( request . params [ 1 ] ) ;
@ -267,7 +265,7 @@ UniValue setaccount(const JSONRPCRequest& request)
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 ;
std : : st ring strOldAccount = pwallet - > mapAddressBook [ address . Get ( ) ] . name ;
if ( address = = GetAccountAddress ( pwallet , strOldAccount ) ) {
if ( address = = GetAccountAddress ( pwallet , strOldAccount ) ) {
GetAccountAddress ( pwallet , strOldAccount , true ) ;
GetAccountAddress ( pwallet , strOldAccount , true ) ;
}
}
@ -289,7 +287,7 @@ UniValue getaccount(const JSONRPCRequest& request)
}
}
if ( request . fHelp | | request . params . size ( ) ! = 1 )
if ( request . fHelp | | request . params . size ( ) ! = 1 )
throw runtime_error (
throw std : : runtime_error (
" getaccount \" address \" \n "
" getaccount \" address \" \n "
" \n DEPRECATED. Returns the account associated with the given address. \n "
" \n DEPRECATED. Returns the account associated with the given address. \n "
" \n Arguments: \n "
" \n Arguments: \n "
@ -307,8 +305,8 @@ UniValue getaccount(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 " ) ;
string strAccount ;
std : : st ring strAccount ;
map < CTxDestination , CAddressBookData > : : iterator mi = pwallet - > mapAddressBook . find ( address . Get ( ) ) ;
std : : 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 ;
}
}
@ -324,7 +322,7 @@ UniValue getaddressesbyaccount(const JSONRPCRequest& request)
}
}
if ( request . fHelp | | request . params . size ( ) ! = 1 )
if ( request . fHelp | | request . params . size ( ) ! = 1 )
throw runtime_error (
throw std : : runtime_error (
" getaddressesbyaccount \" account \" \n "
" getaddressesbyaccount \" account \" \n "
" \n DEPRECATED. Returns the list of addresses for the given account. \n "
" \n DEPRECATED. Returns the list of addresses for the given account. \n "
" \n Arguments: \n "
" \n Arguments: \n "
@ -341,13 +339,13 @@ UniValue getaddressesbyaccount(const JSONRPCRequest& request)
LOCK2 ( cs_main , pwallet - > cs_wallet ) ;
LOCK2 ( cs_main , pwallet - > cs_wallet ) ;
string strAccount = AccountFromValue ( request . params [ 0 ] ) ;
std : : st ring strAccount = AccountFromValue ( request . params [ 0 ] ) ;
// Find all addresses that have the given account
// Find all addresses that have the given account
UniValue ret ( UniValue : : VARR ) ;
UniValue ret ( UniValue : : VARR ) ;
for ( const std : : pair < 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 std : : st ring & strName = item . second . name ;
if ( strName = = strAccount )
if ( strName = = strAccount )
ret . push_back ( address . ToString ( ) ) ;
ret . push_back ( address . ToString ( ) ) ;
}
}
@ -376,7 +374,7 @@ static void SendMoney(CWallet * const pwallet, const CTxDestination &address, CA
CReserveKey reservekey ( pwallet ) ;
CReserveKey reservekey ( pwallet ) ;
CAmount nFeeRequired ;
CAmount nFeeRequired ;
std : : string strError ;
std : : string strError ;
vector < CRecipient > vecSend ;
std : : vector < CRecipient > vecSend ;
int nChangePosRet = - 1 ;
int nChangePosRet = - 1 ;
CRecipient recipient = { scriptPubKey , nValue , fSubtractFeeFromAmount } ;
CRecipient recipient = { scriptPubKey , nValue , fSubtractFeeFromAmount } ;
vecSend . push_back ( recipient ) ;
vecSend . push_back ( recipient ) ;
@ -400,7 +398,7 @@ UniValue sendtoaddress(const JSONRPCRequest& request)
}
}
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 std : : runtime_error (
" sendtoaddress \" address \" amount ( \" comment \" \" comment_to \" subtractfeefromamount ) \n "
" sendtoaddress \" address \" amount ( \" comment \" \" comment_to \" subtractfeefromamount ) \n "
" \n Send an amount to a given address. \n "
" \n Send an amount to a given address. \n "
+ HelpRequiringPassphrase ( pwallet ) +
+ HelpRequiringPassphrase ( pwallet ) +
@ -460,7 +458,7 @@ UniValue listaddressgroupings(const JSONRPCRequest& request)
}
}
if ( request . fHelp )
if ( request . fHelp )
throw runtime_error (
throw std : : runtime_error (
" listaddressgroupings \n "
" listaddressgroupings \n "
" \n Lists groups of addresses which have had their common ownership \n "
" \n Lists groups of addresses which have had their common ownership \n "
" made public by common use as inputs or as the resulting change \n "
" made public by common use as inputs or as the resulting change \n "
@ -485,8 +483,8 @@ UniValue listaddressgroupings(const JSONRPCRequest& request)
LOCK2 ( cs_main , pwallet - > cs_wallet ) ;
LOCK2 ( cs_main , pwallet - > cs_wallet ) ;
UniValue jsonGroupings ( UniValue : : VARR ) ;
UniValue jsonGroupings ( UniValue : : VARR ) ;
map < CTxDestination , CAmount > balances = pwallet - > GetAddressBalances ( ) ;
std : : map < CTxDestination , CAmount > balances = pwallet - > GetAddressBalances ( ) ;
for ( set < CTxDestination > grouping : pwallet - > GetAddressGroupings ( ) ) {
for ( std : : s et < CTxDestination > grouping : pwallet - > GetAddressGroupings ( ) ) {
UniValue jsonGrouping ( UniValue : : VARR ) ;
UniValue jsonGrouping ( UniValue : : VARR ) ;
BOOST_FOREACH ( CTxDestination address , grouping )
BOOST_FOREACH ( CTxDestination address , grouping )
{
{
@ -513,7 +511,7 @@ UniValue signmessage(const JSONRPCRequest& request)
}
}
if ( request . fHelp | | request . params . size ( ) ! = 2 )
if ( request . fHelp | | request . params . size ( ) ! = 2 )
throw runtime_error (
throw std : : runtime_error (
" signmessage \" address \" \" message \" \n "
" signmessage \" address \" \" message \" \n "
" \n Sign a message with the private key of an address "
" \n Sign a message with the private key of an address "
+ HelpRequiringPassphrase ( pwallet ) + " \n "
+ HelpRequiringPassphrase ( pwallet ) + " \n "
@ -537,8 +535,8 @@ UniValue signmessage(const JSONRPCRequest& request)
EnsureWalletIsUnlocked ( pwallet ) ;
EnsureWalletIsUnlocked ( pwallet ) ;
string strAddress = request . params [ 0 ] . get_str ( ) ;
std : : st ring strAddress = request . params [ 0 ] . get_str ( ) ;
string strMessage = request . params [ 1 ] . get_str ( ) ;
std : : st ring strMessage = request . params [ 1 ] . get_str ( ) ;
CBitcoinAddress addr ( strAddress ) ;
CBitcoinAddress addr ( strAddress ) ;
if ( ! addr . IsValid ( ) )
if ( ! addr . IsValid ( ) )
@ -557,7 +555,7 @@ UniValue signmessage(const JSONRPCRequest& request)
ss < < strMessageMagic ;
ss < < strMessageMagic ;
ss < < strMessage ;
ss < < strMessage ;
vector < unsigned char > vchSig ;
std : : vector < unsigned char > vchSig ;
if ( ! key . SignCompact ( ss . GetHash ( ) , vchSig ) )
if ( ! key . SignCompact ( ss . GetHash ( ) , vchSig ) )
throw JSONRPCError ( RPC_INVALID_ADDRESS_OR_KEY , " Sign failed " ) ;
throw JSONRPCError ( RPC_INVALID_ADDRESS_OR_KEY , " Sign failed " ) ;
@ -572,7 +570,7 @@ UniValue getreceivedbyaddress(const JSONRPCRequest& request)
}
}
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 std : : runtime_error (
" getreceivedbyaddress \" address \" ( minconf ) \n "
" getreceivedbyaddress \" address \" ( minconf ) \n "
" \n Returns the total amount received by the given address in transactions with at least minconf confirmations. \n "
" \n Returns the total amount received by the given address in transactions with at least minconf confirmations. \n "
" \n Arguments: \n "
" \n Arguments: \n "
@ -632,7 +630,7 @@ UniValue getreceivedbyaccount(const JSONRPCRequest& request)
}
}
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 std : : runtime_error (
" getreceivedbyaccount \" account \" ( minconf ) \n "
" getreceivedbyaccount \" account \" ( minconf ) \n "
" \n DEPRECATED. Returns the total amount received by addresses with <account> in transactions with at least [minconf] confirmations. \n "
" \n DEPRECATED. Returns the total amount received by addresses with <account> in transactions with at least [minconf] confirmations. \n "
" \n Arguments: \n "
" \n Arguments: \n "
@ -659,8 +657,8 @@ UniValue getreceivedbyaccount(const JSONRPCRequest& request)
nMinDepth = request . params [ 1 ] . get_int ( ) ;
nMinDepth = request . params [ 1 ] . get_int ( ) ;
// Get the set of pub keys assigned to account
// Get the set of pub keys assigned to account
string strAccount = AccountFromValue ( request . params [ 0 ] ) ;
std : : st ring strAccount = AccountFromValue ( request . params [ 0 ] ) ;
set < CTxDestination > setAddress = pwallet - > GetAccountAddresses ( strAccount ) ;
std : : s et < CTxDestination > setAddress = pwallet - > GetAccountAddresses ( strAccount ) ;
// Tally
// Tally
CAmount nAmount = 0 ;
CAmount nAmount = 0 ;
@ -691,7 +689,7 @@ UniValue getbalance(const JSONRPCRequest& request)
}
}
if ( request . fHelp | | request . params . size ( ) > 3 )
if ( request . fHelp | | request . params . size ( ) > 3 )
throw runtime_error (
throw std : : runtime_error (
" getbalance ( \" account \" minconf include_watchonly ) \n "
" getbalance ( \" account \" minconf include_watchonly ) \n "
" \n If account is not specified, returns the server's total available balance. \n "
" \n If account is not specified, returns the server's total available balance. \n "
" If account is specified (DEPRECATED), returns the balance in the account. \n "
" If account is specified (DEPRECATED), returns the balance in the account. \n "
@ -750,9 +748,9 @@ UniValue getbalance(const JSONRPCRequest& request)
continue ;
continue ;
CAmount allFee ;
CAmount allFee ;
string strSentAccount ;
std : : st ring strSentAccount ;
list < COutputEntry > listReceived ;
std : : list < COutputEntry > listReceived ;
list < COutputEntry > listSent ;
std : : list < COutputEntry > listSent ;
wtx . GetAmounts ( listReceived , listSent , allFee , strSentAccount , filter ) ;
wtx . GetAmounts ( listReceived , listSent , allFee , strSentAccount , filter ) ;
if ( wtx . GetDepthInMainChain ( ) > = nMinDepth )
if ( wtx . GetDepthInMainChain ( ) > = nMinDepth )
{
{
@ -766,7 +764,7 @@ UniValue getbalance(const JSONRPCRequest& request)
return ValueFromAmount ( nBalance ) ;
return ValueFromAmount ( nBalance ) ;
}
}
string strAccount = AccountFromValue ( request . params [ 0 ] ) ;
std : : st ring strAccount = AccountFromValue ( request . params [ 0 ] ) ;
CAmount nBalance = pwallet - > GetAccountBalance ( strAccount , nMinDepth , filter ) ;
CAmount nBalance = pwallet - > GetAccountBalance ( strAccount , nMinDepth , filter ) ;
@ -781,7 +779,7 @@ UniValue getunconfirmedbalance(const JSONRPCRequest &request)
}
}
if ( request . fHelp | | request . params . size ( ) > 0 )
if ( request . fHelp | | request . params . size ( ) > 0 )
throw runtime_error (
throw std : : runtime_error (
" getunconfirmedbalance \n "
" getunconfirmedbalance \n "
" Returns the server's total unconfirmed balance \n " ) ;
" Returns the server's total unconfirmed balance \n " ) ;
@ -799,7 +797,7 @@ UniValue movecmd(const JSONRPCRequest& request)
}
}
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 std : : runtime_error (
" move \" fromaccount \" \" toaccount \" amount ( minconf \" comment \" ) \n "
" move \" fromaccount \" \" toaccount \" amount ( minconf \" comment \" ) \n "
" \n DEPRECATED. Move a specified amount from one account in your wallet to another. \n "
" \n DEPRECATED. Move a specified amount from one account in your wallet to another. \n "
" \n Arguments: \n "
" \n Arguments: \n "
@ -821,15 +819,15 @@ UniValue movecmd(const JSONRPCRequest& request)
LOCK2 ( cs_main , pwallet - > cs_wallet ) ;
LOCK2 ( cs_main , pwallet - > cs_wallet ) ;
string strFrom = AccountFromValue ( request . params [ 0 ] ) ;
std : : st ring strFrom = AccountFromValue ( request . params [ 0 ] ) ;
string strTo = AccountFromValue ( request . params [ 1 ] ) ;
std : : st ring strTo = AccountFromValue ( request . params [ 1 ] ) ;
CAmount nAmount = AmountFromValue ( request . params [ 2 ] ) ;
CAmount nAmount = AmountFromValue ( request . params [ 2 ] ) ;
if ( nAmount < = 0 )
if ( nAmount < = 0 )
throw JSONRPCError ( RPC_TYPE_ERROR , " Invalid amount for send " ) ;
throw JSONRPCError ( RPC_TYPE_ERROR , " Invalid amount for send " ) ;
if ( request . params . size ( ) > 3 )
if ( request . params . size ( ) > 3 )
// unused parameter, used to be nMinDepth, keep type-checking it though
// unused parameter, used to be nMinDepth, keep type-checking it though
( void ) request . params [ 3 ] . get_int ( ) ;
( void ) request . params [ 3 ] . get_int ( ) ;
string strComment ;
std : : st ring strComment ;
if ( request . params . size ( ) > 4 )
if ( request . params . size ( ) > 4 )
strComment = request . params [ 4 ] . get_str ( ) ;
strComment = request . params [ 4 ] . get_str ( ) ;
@ -849,7 +847,7 @@ UniValue sendfrom(const JSONRPCRequest& request)
}
}
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 std : : runtime_error (
" sendfrom \" fromaccount \" \" toaddress \" amount ( minconf \" comment \" \" comment_to \" ) \n "
" sendfrom \" fromaccount \" \" toaddress \" amount ( minconf \" comment \" \" comment_to \" ) \n "
" \n DEPRECATED (use sendtoaddress). Sent an amount from an account to a bitcoin address. "
" \n DEPRECATED (use sendtoaddress). Sent an amount from an account to a bitcoin address. "
+ HelpRequiringPassphrase ( pwallet ) + " \n "
+ HelpRequiringPassphrase ( pwallet ) + " \n "
@ -879,7 +877,7 @@ UniValue sendfrom(const JSONRPCRequest& request)
LOCK2 ( cs_main , pwallet - > cs_wallet ) ;
LOCK2 ( cs_main , pwallet - > cs_wallet ) ;
string strAccount = AccountFromValue ( request . params [ 0 ] ) ;
std : : st ring strAccount = AccountFromValue ( request . params [ 0 ] ) ;
CBitcoinAddress address ( request . params [ 1 ] . get_str ( ) ) ;
CBitcoinAddress address ( request . params [ 1 ] . get_str ( ) ) ;
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 " ) ;
@ -918,7 +916,7 @@ UniValue sendmany(const JSONRPCRequest& request)
}
}
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 std : : runtime_error (
" sendmany \" fromaccount \" { \" address \" :amount,...} ( minconf \" comment \" [ \" address \" ,...] ) \n "
" sendmany \" fromaccount \" { \" address \" :amount,...} ( minconf \" comment \" [ \" address \" ,...] ) \n "
" \n Send multiple times. Amounts are double-precision floating point numbers. "
" \n Send multiple times. Amounts are double-precision floating point numbers. "
+ HelpRequiringPassphrase ( pwallet ) + " \n "
+ HelpRequiringPassphrase ( pwallet ) + " \n "
@ -959,7 +957,7 @@ UniValue sendmany(const JSONRPCRequest& request)
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 ] ) ;
std : : st ring strAccount = AccountFromValue ( request . params [ 0 ] ) ;
UniValue sendTo = request . params [ 1 ] . get_obj ( ) ;
UniValue sendTo = request . params [ 1 ] . get_obj ( ) ;
int nMinDepth = 1 ;
int nMinDepth = 1 ;
if ( request . params . size ( ) > 2 )
if ( request . params . size ( ) > 2 )
@ -974,19 +972,19 @@ UniValue sendmany(const JSONRPCRequest& request)
if ( request . params . size ( ) > 4 )
if ( request . params . size ( ) > 4 )
subtractFeeFromAmount = request . params [ 4 ] . get_array ( ) ;
subtractFeeFromAmount = request . params [ 4 ] . get_array ( ) ;
set < CBitcoinAddress > setAddress ;
std : : s et < CBitcoinAddress > setAddress ;
vector < CRecipient > vecSend ;
std : : vector < CRecipient > vecSend ;
CAmount totalAmount = 0 ;
CAmount totalAmount = 0 ;
vector < string > keys = sendTo . getKeys ( ) ;
std : : vector < std : : string > keys = sendTo . getKeys ( ) ;
BOOST_FOREACH ( const string & name_ , keys )
BOOST_FOREACH ( const std : : st ring & name_ , keys )
{
{
CBitcoinAddress address ( name_ ) ;
CBitcoinAddress address ( name_ ) ;
if ( ! address . IsValid ( ) )
if ( ! address . IsValid ( ) )
throw JSONRPCError ( RPC_INVALID_ADDRESS_OR_KEY , string ( " Invalid Bitcoin address: " ) + name_ ) ;
throw JSONRPCError ( RPC_INVALID_ADDRESS_OR_KEY , std : : st ring ( " Invalid Bitcoin address: " ) + name_ ) ;
if ( setAddress . count ( address ) )
if ( setAddress . count ( address ) )
throw JSONRPCError ( RPC_INVALID_PARAMETER , string ( " Invalid parameter, duplicated address: " ) + name_ ) ;
throw JSONRPCError ( RPC_INVALID_PARAMETER , std : : st ring ( " Invalid parameter, duplicated address: " ) + name_ ) ;
setAddress . insert ( address ) ;
setAddress . insert ( address ) ;
CScript scriptPubKey = GetScriptForDestination ( address . Get ( ) ) ;
CScript scriptPubKey = GetScriptForDestination ( address . Get ( ) ) ;
@ -1017,7 +1015,7 @@ UniValue sendmany(const JSONRPCRequest& request)
CReserveKey keyChange ( pwallet ) ;
CReserveKey keyChange ( pwallet ) ;
CAmount nFeeRequired = 0 ;
CAmount nFeeRequired = 0 ;
int nChangePosRet = - 1 ;
int nChangePosRet = - 1 ;
string strFailReason ;
std : : st ring strFailReason ;
bool fCreated = pwallet - > CreateTransaction ( vecSend , wtx , keyChange , nFeeRequired , nChangePosRet , strFailReason ) ;
bool fCreated = pwallet - > CreateTransaction ( vecSend , wtx , keyChange , nFeeRequired , nChangePosRet , strFailReason ) ;
if ( ! fCreated )
if ( ! fCreated )
throw JSONRPCError ( RPC_WALLET_INSUFFICIENT_FUNDS , strFailReason ) ;
throw JSONRPCError ( RPC_WALLET_INSUFFICIENT_FUNDS , strFailReason ) ;
@ -1042,7 +1040,7 @@ UniValue addmultisigaddress(const JSONRPCRequest& request)
if ( request . fHelp | | request . params . size ( ) < 2 | | request . params . size ( ) > 3 )
if ( request . fHelp | | request . params . size ( ) < 2 | | request . params . size ( ) > 3 )
{
{
string msg = " addmultisigaddress nrequired [ \" key \" ,...] ( \" account \" ) \n "
std : : st ring msg = " addmultisigaddress nrequired [ \" key \" ,...] ( \" account \" ) \n "
" \n Add a nrequired-to-sign multisignature address to the wallet. \n "
" \n Add a nrequired-to-sign multisignature address to the wallet. \n "
" Each key is a Bitcoin address or hex-encoded public key. \n "
" Each key is a Bitcoin address or hex-encoded public key. \n "
" If 'account' is specified (DEPRECATED), assign address to that account. \n "
" If 'account' is specified (DEPRECATED), assign address to that account. \n "
@ -1065,12 +1063,12 @@ UniValue addmultisigaddress(const JSONRPCRequest& request)
" \n As json rpc call \n "
" \n As json rpc call \n "
+ HelpExampleRpc ( " addmultisigaddress " , " 2, \" [ \\ \" 16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5 \\ \" , \\ \" 171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV \\ \" ] \" " )
+ HelpExampleRpc ( " addmultisigaddress " , " 2, \" [ \\ \" 16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5 \\ \" , \\ \" 171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV \\ \" ] \" " )
;
;
throw runtime_error ( msg ) ;
throw std : : runtime_error ( msg ) ;
}
}
LOCK2 ( cs_main , pwallet - > cs_wallet ) ;
LOCK2 ( cs_main , pwallet - > cs_wallet ) ;
string strAccount ;
std : : st ring strAccount ;
if ( request . params . size ( ) > 2 )
if ( request . params . size ( ) > 2 )
strAccount = AccountFromValue ( request . params [ 2 ] ) ;
strAccount = AccountFromValue ( request . params [ 2 ] ) ;
@ -1140,7 +1138,7 @@ UniValue addwitnessaddress(const JSONRPCRequest& request)
if ( request . fHelp | | request . params . size ( ) < 1 | | request . params . size ( ) > 1 )
if ( request . fHelp | | request . params . size ( ) < 1 | | request . params . size ( ) > 1 )
{
{
string msg = " addwitnessaddress \" address \" \n "
std : : st ring msg = " addwitnessaddress \" address \" \n "
" \n Add a witness address for a script (with pubkey or redeemscript known). \n "
" \n Add a witness address for a script (with pubkey or redeemscript known). \n "
" It returns the witness script. \n "
" It returns the witness script. \n "
@ -1151,7 +1149,7 @@ UniValue addwitnessaddress(const JSONRPCRequest& request)
" \" witnessaddress \" , (string) The value of the new address (P2SH of witness script). \n "
" \" witnessaddress \" , (string) The value of the new address (P2SH of witness script). \n "
" } \n "
" } \n "
;
;
throw runtime_error ( msg ) ;
throw std : : runtime_error ( msg ) ;
}
}
{
{
@ -1181,7 +1179,7 @@ struct tallyitem
{
{
CAmount nAmount ;
CAmount nAmount ;
int nConf ;
int nConf ;
vector < uint256 > txids ;
std : : vector < uint256 > txids ;
bool fIsWatchonly ;
bool fIsWatchonly ;
tallyitem ( )
tallyitem ( )
{
{
@ -1209,7 +1207,7 @@ UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bool fByA
filter = filter | ISMINE_WATCH_ONLY ;
filter = filter | ISMINE_WATCH_ONLY ;
// Tally
// Tally
map < CBitcoinAddress , tallyitem > mapTally ;
std : : map < CBitcoinAddress , tallyitem > mapTally ;
for ( const std : : pair < uint256 , CWalletTx > & pairWtx : pwallet - > mapWallet ) {
for ( const std : : pair < uint256 , CWalletTx > & pairWtx : pwallet - > mapWallet ) {
const CWalletTx & wtx = pairWtx . second ;
const CWalletTx & wtx = pairWtx . second ;
@ -1232,7 +1230,7 @@ UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bool fByA
tallyitem & item = mapTally [ address ] ;
tallyitem & item = mapTally [ address ] ;
item . nAmount + = txout . nValue ;
item . nAmount + = txout . nValue ;
item . nConf = min ( item . nConf , nDepth ) ;
item . nConf = std : : min ( item . nConf , nDepth ) ;
item . txids . push_back ( wtx . GetHash ( ) ) ;
item . txids . push_back ( wtx . GetHash ( ) ) ;
if ( mine & ISMINE_WATCH_ONLY )
if ( mine & ISMINE_WATCH_ONLY )
item . fIsWatchonly = true ;
item . fIsWatchonly = true ;
@ -1241,11 +1239,11 @@ UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bool fByA
// Reply
// Reply
UniValue ret ( UniValue : : VARR ) ;
UniValue ret ( UniValue : : VARR ) ;
map < string , tallyitem > mapAccountTally ;
std : : map < std : : string , tallyitem > mapAccountTally ;
for ( const std : : pair < 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 std : : st ring & strAccount = item . second . name ;
map < CBitcoinAddress , tallyitem > : : iterator it = mapTally . find ( address ) ;
std : : map < CBitcoinAddress , tallyitem > : : iterator it = mapTally . find ( address ) ;
if ( it = = mapTally . end ( ) & & ! fIncludeEmpty )
if ( it = = mapTally . end ( ) & & ! fIncludeEmpty )
continue ;
continue ;
@ -1263,7 +1261,7 @@ UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bool fByA
{
{
tallyitem & _item = mapAccountTally [ strAccount ] ;
tallyitem & _item = mapAccountTally [ strAccount ] ;
_item . nAmount + = nAmount ;
_item . nAmount + = nAmount ;
_item . nConf = min ( _item . nConf , nConf ) ;
_item . nConf = std : : min ( _item . nConf , nConf ) ;
_item . fIsWatchonly = fIsWatchonly ;
_item . fIsWatchonly = fIsWatchonly ;
}
}
else
else
@ -1292,7 +1290,7 @@ UniValue ListReceived(CWallet * const pwallet, const UniValue& params, bool fByA
if ( fByAccounts )
if ( fByAccounts )
{
{
for ( map < string , tallyitem > : : iterator it = mapAccountTally . begin ( ) ; it ! = mapAccountTally . end ( ) ; + + it )
for ( std : : map < std : : string , tallyitem > : : iterator it = mapAccountTally . begin ( ) ; it ! = mapAccountTally . end ( ) ; + + it )
{
{
CAmount nAmount = ( * it ) . second . nAmount ;
CAmount nAmount = ( * it ) . second . nAmount ;
int nConf = ( * it ) . second . nConf ;
int nConf = ( * it ) . second . nConf ;
@ -1317,7 +1315,7 @@ UniValue listreceivedbyaddress(const JSONRPCRequest& request)
}
}
if ( request . fHelp | | request . params . size ( ) > 3 )
if ( request . fHelp | | request . params . size ( ) > 3 )
throw runtime_error (
throw std : : runtime_error (
" listreceivedbyaddress ( minconf include_empty include_watchonly) \n "
" listreceivedbyaddress ( minconf include_empty include_watchonly) \n "
" \n List balances by receiving address. \n "
" \n List balances by receiving address. \n "
" \n Arguments: \n "
" \n Arguments: \n "
@ -1361,7 +1359,7 @@ UniValue listreceivedbyaccount(const JSONRPCRequest& request)
}
}
if ( request . fHelp | | request . params . size ( ) > 3 )
if ( request . fHelp | | request . params . size ( ) > 3 )
throw runtime_error (
throw std : : runtime_error (
" listreceivedbyaccount ( minconf include_empty include_watchonly) \n "
" listreceivedbyaccount ( minconf include_empty include_watchonly) \n "
" \n DEPRECATED. List balances by account. \n "
" \n DEPRECATED. List balances by account. \n "
" \n Arguments: \n "
" \n Arguments: \n "
@ -1399,16 +1397,16 @@ static void MaybePushAddress(UniValue & entry, const CTxDestination &dest)
entry . push_back ( Pair ( " address " , addr . ToString ( ) ) ) ;
entry . push_back ( Pair ( " address " , addr . ToString ( ) ) ) ;
}
}
void ListTransactions ( CWallet * const pwallet , const CWalletTx & wtx , const string & strAccount , int nMinDepth , bool fLong , UniValue & ret , const isminefilter & filter )
void ListTransactions ( CWallet * const pwallet , const CWalletTx & wtx , const std : : string & strAccount , int nMinDepth , bool fLong , UniValue & ret , const isminefilter & filter )
{
{
CAmount nFee ;
CAmount nFee ;
string strSentAccount ;
std : : st ring strSentAccount ;
list < COutputEntry > listReceived ;
std : : list < COutputEntry > listReceived ;
list < COutputEntry > listSent ;
std : : list < COutputEntry > listSent ;
wtx . GetAmounts ( listReceived , listSent , nFee , strSentAccount , filter ) ;
wtx . GetAmounts ( listReceived , listSent , nFee , strSentAccount , filter ) ;
bool fAllAccounts = ( strAccount = = string ( " * " ) ) ;
bool fAllAccounts = ( strAccount = = std : : st ring ( " * " ) ) ;
bool involvesWatchonly = wtx . IsFromMe ( ISMINE_WATCH_ONLY ) ;
bool involvesWatchonly = wtx . IsFromMe ( ISMINE_WATCH_ONLY ) ;
// Sent
// Sent
@ -1441,7 +1439,7 @@ void ListTransactions(CWallet * const pwallet, const CWalletTx& wtx, const strin
{
{
BOOST_FOREACH ( const COutputEntry & r , listReceived )
BOOST_FOREACH ( const COutputEntry & r , listReceived )
{
{
string account ;
std : : st ring 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 ;
}
}
@ -1479,9 +1477,9 @@ void ListTransactions(CWallet * const pwallet, const CWalletTx& wtx, const strin
}
}
}
}
void AcentryToJSON ( const CAccountingEntry & acentry , const string & strAccount , UniValue & ret )
void AcentryToJSON ( const CAccountingEntry & acentry , const std : : st ring & strAccount , UniValue & ret )
{
{
bool fAllAccounts = ( strAccount = = string ( " * " ) ) ;
bool fAllAccounts = ( strAccount = = std : : st ring ( " * " ) ) ;
if ( fAllAccounts | | acentry . strAccount = = strAccount )
if ( fAllAccounts | | acentry . strAccount = = strAccount )
{
{
@ -1504,7 +1502,7 @@ UniValue listtransactions(const JSONRPCRequest& request)
}
}
if ( request . fHelp | | request . params . size ( ) > 4 )
if ( request . fHelp | | request . params . size ( ) > 4 )
throw runtime_error (
throw std : : runtime_error (
" listtransactions ( \" account \" count skip include_watchonly) \n "
" listtransactions ( \" account \" count skip include_watchonly) \n "
" \n Returns up to 'count' most recent transactions skipping the first 'from' transactions for account 'account'. \n "
" \n Returns up to 'count' most recent transactions skipping the first 'from' transactions for account 'account'. \n "
" \n Arguments: \n "
" \n Arguments: \n "
@ -1565,7 +1563,7 @@ UniValue listtransactions(const JSONRPCRequest& request)
LOCK2 ( cs_main , pwallet - > cs_wallet ) ;
LOCK2 ( cs_main , pwallet - > cs_wallet ) ;
string strAccount = " * " ;
std : : st ring strAccount = " * " ;
if ( request . params . size ( ) > 0 )
if ( request . params . size ( ) > 0 )
strAccount = request . params [ 0 ] . get_str ( ) ;
strAccount = request . params [ 0 ] . get_str ( ) ;
int nCount = 10 ;
int nCount = 10 ;
@ -1607,11 +1605,11 @@ UniValue listtransactions(const JSONRPCRequest& request)
if ( ( nFrom + nCount ) > ( int ) ret . size ( ) )
if ( ( nFrom + nCount ) > ( int ) ret . size ( ) )
nCount = ret . size ( ) - nFrom ;
nCount = ret . size ( ) - nFrom ;
vector < UniValue > arrTmp = ret . getValues ( ) ;
std : : vector < UniValue > arrTmp = ret . getValues ( ) ;
vector < UniValue > : : iterator first = arrTmp . begin ( ) ;
std : : vector < UniValue > : : iterator first = arrTmp . begin ( ) ;
std : : advance ( first , nFrom ) ;
std : : advance ( first , nFrom ) ;
vector < UniValue > : : iterator last = arrTmp . begin ( ) ;
std : : vector < UniValue > : : iterator last = arrTmp . begin ( ) ;
std : : advance ( last , nFrom + nCount ) ;
std : : advance ( last , nFrom + nCount ) ;
if ( last ! = arrTmp . end ( ) ) arrTmp . erase ( last , arrTmp . end ( ) ) ;
if ( last ! = arrTmp . end ( ) ) arrTmp . erase ( last , arrTmp . end ( ) ) ;
@ -1634,7 +1632,7 @@ UniValue listaccounts(const JSONRPCRequest& request)
}
}
if ( request . fHelp | | request . params . size ( ) > 2 )
if ( request . fHelp | | request . params . size ( ) > 2 )
throw runtime_error (
throw std : : runtime_error (
" listaccounts ( minconf include_watchonly) \n "
" listaccounts ( minconf include_watchonly) \n "
" \n DEPRECATED. Returns Object that has account names as keys, account balances as values. \n "
" \n DEPRECATED. Returns Object that has account names as keys, account balances as values. \n "
" \n Arguments: \n "
" \n Arguments: \n "
@ -1666,7 +1664,7 @@ UniValue listaccounts(const JSONRPCRequest& request)
if ( request . params [ 1 ] . get_bool ( ) )
if ( request . params [ 1 ] . get_bool ( ) )
includeWatchonly = includeWatchonly | ISMINE_WATCH_ONLY ;
includeWatchonly = includeWatchonly | ISMINE_WATCH_ONLY ;
map < string , CAmount > mapAccountBalances ;
std : : map < std : : string , CAmount > mapAccountBalances ;
for ( const std : : pair < 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 ;
@ -1676,9 +1674,9 @@ UniValue listaccounts(const JSONRPCRequest& request)
for ( const std : : pair < uint256 , CWalletTx > & pairWtx : pwallet - > mapWallet ) {
for ( const std : : pair < uint256 , CWalletTx > & pairWtx : pwallet - > mapWallet ) {
const CWalletTx & wtx = pairWtx . second ;
const CWalletTx & wtx = pairWtx . second ;
CAmount nFee ;
CAmount nFee ;
string strSentAccount ;
std : : st ring strSentAccount ;
list < COutputEntry > listReceived ;
std : : list < COutputEntry > listReceived ;
list < COutputEntry > listSent ;
std : : list < COutputEntry > listSent ;
int nDepth = wtx . GetDepthInMainChain ( ) ;
int nDepth = wtx . GetDepthInMainChain ( ) ;
if ( wtx . GetBlocksToMaturity ( ) > 0 | | nDepth < 0 )
if ( wtx . GetBlocksToMaturity ( ) > 0 | | nDepth < 0 )
continue ;
continue ;
@ -1697,12 +1695,12 @@ UniValue listaccounts(const JSONRPCRequest& request)
}
}
}
}
const list < CAccountingEntry > & acentries = pwallet - > laccentries ;
const std : : list < CAccountingEntry > & acentries = pwallet - > laccentries ;
BOOST_FOREACH ( const CAccountingEntry & entry , acentries )
BOOST_FOREACH ( const CAccountingEntry & entry , acentries )
mapAccountBalances [ entry . strAccount ] + = entry . nCreditDebit ;
mapAccountBalances [ entry . strAccount ] + = entry . nCreditDebit ;
UniValue ret ( UniValue : : VOBJ ) ;
UniValue ret ( UniValue : : VOBJ ) ;
BOOST_FOREACH ( const PAIRTYPE ( string , CAmount ) & accountBalance , mapAccountBalances ) {
BOOST_FOREACH ( const PAIRTYPE ( std : : st ring , CAmount ) & accountBalance , mapAccountBalances ) {
ret . push_back ( Pair ( accountBalance . first , ValueFromAmount ( accountBalance . second ) ) ) ;
ret . push_back ( Pair ( accountBalance . first , ValueFromAmount ( accountBalance . second ) ) ) ;
}
}
return ret ;
return ret ;
@ -1716,7 +1714,7 @@ UniValue listsinceblock(const JSONRPCRequest& request)
}
}
if ( request . fHelp )
if ( request . fHelp )
throw runtime_error (
throw std : : runtime_error (
" listsinceblock ( \" blockhash \" target_confirmations include_watchonly) \n "
" listsinceblock ( \" blockhash \" target_confirmations include_watchonly) \n "
" \n Get all transactions in blocks since block [blockhash], or all transactions if omitted \n "
" \n Get all transactions in blocks since block [blockhash], or all transactions if omitted \n "
" \n Arguments: \n "
" \n Arguments: \n "
@ -1823,7 +1821,7 @@ UniValue gettransaction(const JSONRPCRequest& request)
}
}
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 std : : runtime_error (
" gettransaction \" txid \" ( include_watchonly ) \n "
" gettransaction \" txid \" ( include_watchonly ) \n "
" \n Get detailed information about in-wallet transaction <txid> \n "
" \n Get detailed information about in-wallet transaction <txid> \n "
" \n Arguments: \n "
" \n Arguments: \n "
@ -1898,7 +1896,7 @@ UniValue gettransaction(const JSONRPCRequest& request)
ListTransactions ( pwallet , wtx , " * " , 0 , false , details , filter ) ;
ListTransactions ( pwallet , wtx , " * " , 0 , false , details , filter ) ;
entry . push_back ( Pair ( " details " , details ) ) ;
entry . push_back ( Pair ( " details " , details ) ) ;
string strHex = EncodeHexTx ( static_cast < CTransaction > ( wtx ) , RPCSerializationFlags ( ) ) ;
std : : st ring strHex = EncodeHexTx ( static_cast < CTransaction > ( wtx ) , RPCSerializationFlags ( ) ) ;
entry . push_back ( Pair ( " hex " , strHex ) ) ;
entry . push_back ( Pair ( " hex " , strHex ) ) ;
return entry ;
return entry ;
@ -1912,7 +1910,7 @@ UniValue abandontransaction(const JSONRPCRequest& request)
}
}
if ( request . fHelp | | request . params . size ( ) ! = 1 )
if ( request . fHelp | | request . params . size ( ) ! = 1 )
throw runtime_error (
throw std : : runtime_error (
" abandontransaction \" txid \" \n "
" abandontransaction \" txid \" \n "
" \n Mark in-wallet transaction <txid> as abandoned \n "
" \n Mark in-wallet transaction <txid> as abandoned \n "
" This will mark this transaction and all its in-wallet descendants as abandoned which will allow \n "
" This will mark this transaction and all its in-wallet descendants as abandoned which will allow \n "
@ -1951,7 +1949,7 @@ UniValue backupwallet(const JSONRPCRequest& request)
}
}
if ( request . fHelp | | request . params . size ( ) ! = 1 )
if ( request . fHelp | | request . params . size ( ) ! = 1 )
throw runtime_error (
throw std : : runtime_error (
" backupwallet \" destination \" \n "
" backupwallet \" destination \" \n "
" \n Safely copies current wallet file to destination, which can be a directory or a path with filename. \n "
" \n Safely copies current wallet file to destination, which can be a directory or a path with filename. \n "
" \n Arguments: \n "
" \n Arguments: \n "
@ -1963,7 +1961,7 @@ UniValue backupwallet(const JSONRPCRequest& request)
LOCK2 ( cs_main , pwallet - > cs_wallet ) ;
LOCK2 ( cs_main , pwallet - > cs_wallet ) ;
string strDest = request . params [ 0 ] . get_str ( ) ;
std : : st ring 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! " ) ;
}
}
@ -1980,7 +1978,7 @@ UniValue keypoolrefill(const JSONRPCRequest& request)
}
}
if ( request . fHelp | | request . params . size ( ) > 1 )
if ( request . fHelp | | request . params . size ( ) > 1 )
throw runtime_error (
throw std : : runtime_error (
" keypoolrefill ( newsize ) \n "
" keypoolrefill ( newsize ) \n "
" \n Fills the keypool. "
" \n Fills the keypool. "
+ HelpRequiringPassphrase ( pwallet ) + " \n "
+ HelpRequiringPassphrase ( pwallet ) + " \n "
@ -2027,7 +2025,7 @@ UniValue walletpassphrase(const JSONRPCRequest& request)
}
}
if ( pwallet - > IsCrypted ( ) & & ( request . fHelp | | request . params . size ( ) ! = 2 ) ) {
if ( pwallet - > IsCrypted ( ) & & ( request . fHelp | | request . params . size ( ) ! = 2 ) ) {
throw runtime_error (
throw std : : runtime_error (
" walletpassphrase \" passphrase \" timeout \n "
" walletpassphrase \" passphrase \" timeout \n "
" \n Stores the wallet decryption key in memory for 'timeout' seconds. \n "
" \n Stores the wallet decryption key in memory for 'timeout' seconds. \n "
" This is needed prior to performing transactions related to private keys such as sending bitcoins \n "
" This is needed prior to performing transactions related to private keys such as sending bitcoins \n "
@ -2069,7 +2067,7 @@ UniValue walletpassphrase(const JSONRPCRequest& request)
}
}
}
}
else
else
throw runtime_error (
throw std : : runtime_error (
" walletpassphrase <passphrase> <timeout> \n "
" walletpassphrase <passphrase> <timeout> \n "
" Stores the wallet decryption key in memory for <timeout> seconds. " ) ;
" Stores the wallet decryption key in memory for <timeout> seconds. " ) ;
@ -2091,7 +2089,7 @@ UniValue walletpassphrasechange(const JSONRPCRequest& request)
}
}
if ( pwallet - > IsCrypted ( ) & & ( request . fHelp | | request . params . size ( ) ! = 2 ) ) {
if ( pwallet - > IsCrypted ( ) & & ( request . fHelp | | request . params . size ( ) ! = 2 ) ) {
throw runtime_error (
throw std : : runtime_error (
" walletpassphrasechange \" oldpassphrase \" \" newpassphrase \" \n "
" walletpassphrasechange \" oldpassphrase \" \" newpassphrase \" \n "
" \n Changes the wallet passphrase from 'oldpassphrase' to 'newpassphrase'. \n "
" \n Changes the wallet passphrase from 'oldpassphrase' to 'newpassphrase'. \n "
" \n Arguments: \n "
" \n Arguments: \n "
@ -2122,7 +2120,7 @@ UniValue walletpassphrasechange(const JSONRPCRequest& request)
strNewWalletPass = request . params [ 1 ] . get_str ( ) . c_str ( ) ;
strNewWalletPass = request . params [ 1 ] . get_str ( ) . c_str ( ) ;
if ( strOldWalletPass . length ( ) < 1 | | strNewWalletPass . length ( ) < 1 )
if ( strOldWalletPass . length ( ) < 1 | | strNewWalletPass . length ( ) < 1 )
throw runtime_error (
throw std : : runtime_error (
" walletpassphrasechange <oldpassphrase> <newpassphrase> \n "
" walletpassphrasechange <oldpassphrase> <newpassphrase> \n "
" Changes the wallet passphrase from <oldpassphrase> to <newpassphrase>. " ) ;
" Changes the wallet passphrase from <oldpassphrase> to <newpassphrase>. " ) ;
@ -2142,7 +2140,7 @@ UniValue walletlock(const JSONRPCRequest& request)
}
}
if ( pwallet - > IsCrypted ( ) & & ( request . fHelp | | request . params . size ( ) ! = 0 ) ) {
if ( pwallet - > IsCrypted ( ) & & ( request . fHelp | | request . params . size ( ) ! = 0 ) ) {
throw runtime_error (
throw std : : runtime_error (
" walletlock \n "
" walletlock \n "
" \n Removes the wallet encryption key from memory, locking the wallet. \n "
" \n Removes the wallet encryption key from memory, locking the wallet. \n "
" After calling this method, you will need to call walletpassphrase again \n "
" After calling this method, you will need to call walletpassphrase again \n "
@ -2182,7 +2180,7 @@ UniValue encryptwallet(const JSONRPCRequest& request)
}
}
if ( ! pwallet - > IsCrypted ( ) & & ( request . fHelp | | request . params . size ( ) ! = 1 ) ) {
if ( ! pwallet - > IsCrypted ( ) & & ( request . fHelp | | request . params . size ( ) ! = 1 ) ) {
throw runtime_error (
throw std : : runtime_error (
" encryptwallet \" passphrase \" \n "
" encryptwallet \" passphrase \" \n "
" \n Encrypts the wallet with 'passphrase'. This is for first time encryption. \n "
" \n Encrypts the wallet with 'passphrase'. This is for first time encryption. \n "
" After this, any calls that interact with private keys such as sending or signing \n "
" After this, any calls that interact with private keys such as sending or signing \n "
@ -2221,7 +2219,7 @@ UniValue encryptwallet(const JSONRPCRequest& request)
strWalletPass = request . params [ 0 ] . get_str ( ) . c_str ( ) ;
strWalletPass = request . params [ 0 ] . get_str ( ) . c_str ( ) ;
if ( strWalletPass . length ( ) < 1 )
if ( strWalletPass . length ( ) < 1 )
throw runtime_error (
throw std : : runtime_error (
" encryptwallet <passphrase> \n "
" encryptwallet <passphrase> \n "
" Encrypts the wallet with <passphrase>. " ) ;
" Encrypts the wallet with <passphrase>. " ) ;
@ -2244,7 +2242,7 @@ UniValue lockunspent(const JSONRPCRequest& request)
}
}
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 std : : runtime_error (
" lockunspent unlock ([{ \" txid \" : \" txid \" , \" vout \" :n},...]) \n "
" lockunspent unlock ([{ \" txid \" : \" txid \" , \" vout \" :n},...]) \n "
" \n Updates list of temporarily unspendable outputs. \n "
" \n Updates list of temporarily unspendable outputs. \n "
" Temporarily lock (unlock=false) or unlock (unlock=true) specified transaction outputs. \n "
" Temporarily lock (unlock=false) or unlock (unlock=true) specified transaction outputs. \n "
@ -2308,7 +2306,7 @@ UniValue lockunspent(const JSONRPCRequest& request)
{ " vout " , UniValueType ( UniValue : : VNUM ) } ,
{ " vout " , UniValueType ( UniValue : : VNUM ) } ,
} ) ;
} ) ;
string txid = find_value ( o , " txid " ) . get_str ( ) ;
std : : st ring txid = find_value ( o , " txid " ) . get_str ( ) ;
if ( ! IsHex ( txid ) )
if ( ! IsHex ( txid ) )
throw JSONRPCError ( RPC_INVALID_PARAMETER , " Invalid parameter, expected hex txid " ) ;
throw JSONRPCError ( RPC_INVALID_PARAMETER , " Invalid parameter, expected hex txid " ) ;
@ -2335,7 +2333,7 @@ UniValue listlockunspent(const JSONRPCRequest& request)
}
}
if ( request . fHelp | | request . params . size ( ) > 0 )
if ( request . fHelp | | request . params . size ( ) > 0 )
throw runtime_error (
throw std : : runtime_error (
" listlockunspent \n "
" listlockunspent \n "
" \n Returns list of temporarily unspendable outputs. \n "
" \n Returns list of temporarily unspendable outputs. \n "
" See the lockunspent call to lock and unlock transactions for spending. \n "
" See the lockunspent call to lock and unlock transactions for spending. \n "
@ -2362,7 +2360,7 @@ UniValue listlockunspent(const JSONRPCRequest& request)
LOCK2 ( cs_main , pwallet - > cs_wallet ) ;
LOCK2 ( cs_main , pwallet - > cs_wallet ) ;
vector < COutPoint > vOutpts ;
std : : vector < COutPoint > vOutpts ;
pwallet - > ListLockedCoins ( vOutpts ) ;
pwallet - > ListLockedCoins ( vOutpts ) ;
UniValue ret ( UniValue : : VARR ) ;
UniValue ret ( UniValue : : VARR ) ;
@ -2386,7 +2384,7 @@ UniValue settxfee(const JSONRPCRequest& request)
}
}
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 std : : runtime_error (
" settxfee amount \n "
" settxfee amount \n "
" \n Set the transaction fee per kB. Overwrites the paytxfee parameter. \n "
" \n Set the transaction fee per kB. Overwrites the paytxfee parameter. \n "
" \n Arguments: \n "
" \n Arguments: \n "
@ -2415,7 +2413,7 @@ UniValue getwalletinfo(const JSONRPCRequest& request)
}
}
if ( request . fHelp | | request . params . size ( ) ! = 0 )
if ( request . fHelp | | request . params . size ( ) ! = 0 )
throw runtime_error (
throw std : : runtime_error (
" getwalletinfo \n "
" getwalletinfo \n "
" Returns an object containing various wallet state info. \n "
" Returns an object containing various wallet state info. \n "
" \n Result: \n "
" \n Result: \n "
@ -2464,7 +2462,7 @@ UniValue resendwallettransactions(const JSONRPCRequest& request)
}
}
if ( request . fHelp | | request . params . size ( ) ! = 0 )
if ( request . fHelp | | request . params . size ( ) ! = 0 )
throw runtime_error (
throw std : : runtime_error (
" resendwallettransactions \n "
" resendwallettransactions \n "
" Immediately re-broadcast unconfirmed wallet transactions to all peers. \n "
" Immediately re-broadcast unconfirmed wallet transactions to all peers. \n "
" Intended only for testing; the wallet code periodically re-broadcasts \n "
" Intended only for testing; the wallet code periodically re-broadcasts \n "
@ -2494,7 +2492,7 @@ UniValue listunspent(const JSONRPCRequest& request)
}
}
if ( request . fHelp | | request . params . size ( ) > 4 )
if ( request . fHelp | | request . params . size ( ) > 4 )
throw runtime_error (
throw std : : runtime_error (
" listunspent ( minconf maxconf [ \" addresses \" ,...] [include_unsafe] ) \n "
" listunspent ( minconf maxconf [ \" addresses \" ,...] [include_unsafe] ) \n "
" \n Returns array of unspent transaction outputs \n "
" \n Returns array of unspent transaction outputs \n "
" with between minconf and maxconf (inclusive) confirmations. \n "
" with between minconf and maxconf (inclusive) confirmations. \n "
@ -2546,7 +2544,7 @@ UniValue listunspent(const JSONRPCRequest& request)
nMaxDepth = request . params [ 1 ] . get_int ( ) ;
nMaxDepth = request . params [ 1 ] . get_int ( ) ;
}
}
set < CBitcoinAddress > setAddress ;
std : : s et < CBitcoinAddress > setAddress ;
if ( request . params . size ( ) > 2 & & ! request . params [ 2 ] . isNull ( ) ) {
if ( request . params . size ( ) > 2 & & ! request . params [ 2 ] . isNull ( ) ) {
RPCTypeCheckArgument ( request . params [ 2 ] , UniValue : : VARR ) ;
RPCTypeCheckArgument ( request . params [ 2 ] , UniValue : : VARR ) ;
UniValue inputs = request . params [ 2 ] . get_array ( ) ;
UniValue inputs = request . params [ 2 ] . get_array ( ) ;
@ -2554,9 +2552,9 @@ UniValue listunspent(const JSONRPCRequest& request)
const UniValue & input = inputs [ idx ] ;
const UniValue & input = inputs [ idx ] ;
CBitcoinAddress address ( input . get_str ( ) ) ;
CBitcoinAddress address ( input . get_str ( ) ) ;
if ( ! address . IsValid ( ) )
if ( ! address . IsValid ( ) )
throw JSONRPCError ( RPC_INVALID_ADDRESS_OR_KEY , string ( " Invalid Bitcoin address: " ) + input . get_str ( ) ) ;
throw JSONRPCError ( RPC_INVALID_ADDRESS_OR_KEY , std : : st ring ( " Invalid Bitcoin address: " ) + input . get_str ( ) ) ;
if ( setAddress . count ( address ) )
if ( setAddress . count ( address ) )
throw JSONRPCError ( RPC_INVALID_PARAMETER , string ( " Invalid parameter, duplicated address: " ) + input . get_str ( ) ) ;
throw JSONRPCError ( RPC_INVALID_PARAMETER , std : : st ring ( " Invalid parameter, duplicated address: " ) + input . get_str ( ) ) ;
setAddress . insert ( address ) ;
setAddress . insert ( address ) ;
}
}
}
}
@ -2568,7 +2566,7 @@ UniValue listunspent(const JSONRPCRequest& request)
}
}
UniValue results ( UniValue : : VARR ) ;
UniValue results ( UniValue : : VARR ) ;
vector < COutput > vecOutputs ;
std : : vector < COutput > vecOutputs ;
assert ( pwallet ! = NULL ) ;
assert ( pwallet ! = NULL ) ;
LOCK2 ( cs_main , pwallet - > cs_wallet ) ;
LOCK2 ( cs_main , pwallet - > cs_wallet ) ;
pwallet - > AvailableCoins ( vecOutputs , ! include_unsafe , NULL , true ) ;
pwallet - > AvailableCoins ( vecOutputs , ! include_unsafe , NULL , true ) ;
@ -2622,7 +2620,7 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
}
}
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 std : : runtime_error (
" fundrawtransaction \" hexstring \" ( options ) \n "
" fundrawtransaction \" hexstring \" ( options ) \n "
" \n Add inputs to a transaction until it has enough in value to meet its out value. \n "
" \n Add inputs to a transaction until it has enough in value to meet its out value. \n "
" This will not modify existing inputs, and will add at most one change output to the outputs. \n "
" This will not modify existing inputs, and will add at most one change output to the outputs. \n "
@ -2679,7 +2677,7 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
CFeeRate feeRate = CFeeRate ( 0 ) ;
CFeeRate feeRate = CFeeRate ( 0 ) ;
bool overrideEstimatedFeerate = false ;
bool overrideEstimatedFeerate = false ;
UniValue subtractFeeFromOutputs ;
UniValue subtractFeeFromOutputs ;
set < int > setSubtractFeeFromOutputs ;
std : : s et < int > setSubtractFeeFromOutputs ;
if ( request . params . size ( ) > 1 ) {
if ( request . params . size ( ) > 1 ) {
if ( request . params [ 1 ] . type ( ) = = UniValue : : VBOOL ) {
if ( request . params [ 1 ] . type ( ) = = UniValue : : VBOOL ) {
@ -2758,7 +2756,7 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
}
}
CAmount nFeeOut ;
CAmount nFeeOut ;
string strFailReason ;
std : : st ring 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 ) ;
@ -2782,14 +2780,14 @@ UniValue fundrawtransaction(const JSONRPCRequest& request)
int64_t CalculateMaximumSignedTxSize ( const CTransaction & tx , CWallet & wallet )
int64_t CalculateMaximumSignedTxSize ( const CTransaction & tx , CWallet & wallet )
{
{
CMutableTransaction txNew ( tx ) ;
CMutableTransaction txNew ( tx ) ;
std : : vector < pair < CWalletTx * , unsigned int > > vCoins ;
std : : vector < std : : pair < CWalletTx * , unsigned int > > vCoins ;
// Look up the inputs. We should have already checked that this transaction
// Look up the inputs. We should have already checked that this transaction
// IsAllFromMe(ISMINE_SPENDABLE), so every input should already be in our
// IsAllFromMe(ISMINE_SPENDABLE), so every input should already be in our
// wallet, with a valid index into the vout array.
// wallet, with a valid index into the vout array.
for ( auto & input : tx . vin ) {
for ( auto & input : tx . vin ) {
const auto mi = wallet . mapWallet . find ( input . prevout . hash ) ;
const auto mi = wallet . mapWallet . find ( input . prevout . hash ) ;
assert ( mi ! = wallet . mapWallet . end ( ) & & input . prevout . n < mi - > second . tx - > vout . size ( ) ) ;
assert ( mi ! = wallet . mapWallet . end ( ) & & input . prevout . n < mi - > second . tx - > vout . size ( ) ) ;
vCoins . emplace_back ( make_pair ( & ( mi - > second ) , input . prevout . n ) ) ;
vCoins . emplace_back ( std : : make_pair ( & ( mi - > second ) , input . prevout . n ) ) ;
}
}
if ( ! wallet . DummySignTx ( txNew , vCoins ) ) {
if ( ! wallet . DummySignTx ( txNew , vCoins ) ) {
// This should never happen, because IsAllFromMe(ISMINE_SPENDABLE)
// This should never happen, because IsAllFromMe(ISMINE_SPENDABLE)
@ -2807,7 +2805,7 @@ UniValue bumpfee(const JSONRPCRequest& request)
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 std : : runtime_error (
" bumpfee \" txid \" ( options ) \n "
" bumpfee \" txid \" ( options ) \n "
" \n Bumps the fee of an opt-in-RBF transaction T, replacing it with a new transaction B. \n "
" \n Bumps the fee of an opt-in-RBF transaction T, replacing it with a new transaction B. \n "
" An opt-in RBF transaction with the given txid must be in the wallet. \n "
" An opt-in RBF transaction with the given txid must be in the wallet. \n "