@ -6,6 +6,7 @@
# include "amount.h"
# include "amount.h"
# include "base58.h"
# include "base58.h"
# include "chain.h"
# include "chain.h"
# include "consensus/validation.h"
# include "core_io.h"
# include "core_io.h"
# include "init.h"
# include "init.h"
# include "main.h"
# include "main.h"
@ -365,8 +366,11 @@ static void SendMoney(const CTxDestination &address, CAmount nValue, bool fSubtr
strError = strprintf ( " Error: This transaction requires a transaction fee of at least %s " , FormatMoney ( nFeeRequired ) ) ;
strError = strprintf ( " Error: This transaction requires a transaction fee of at least %s " , FormatMoney ( nFeeRequired ) ) ;
throw JSONRPCError ( RPC_WALLET_ERROR , strError ) ;
throw JSONRPCError ( RPC_WALLET_ERROR , strError ) ;
}
}
if ( ! pwalletMain - > CommitTransaction ( wtxNew , reservekey , g_connman . get ( ) ) )
CValidationState state ;
throw JSONRPCError ( RPC_WALLET_ERROR , " Error: The transaction was rejected! This might happen if some of the coins in your wallet were already spent, such as if you used a copy of the wallet and coins were spent in the copy but not marked as spent here. " ) ;
if ( ! pwalletMain - > CommitTransaction ( wtxNew , reservekey , g_connman . get ( ) , state ) ) {
strError = strprintf ( " Error: The transaction was rejected! Reason given: %s " , state . GetRejectReason ( ) ) ;
throw JSONRPCError ( RPC_WALLET_ERROR , strError ) ;
}
}
}
UniValue sendtoaddress ( const JSONRPCRequest & request )
UniValue sendtoaddress ( const JSONRPCRequest & request )
@ -959,8 +963,11 @@ UniValue sendmany(const JSONRPCRequest& request)
bool fCreated = pwalletMain - > CreateTransaction ( vecSend , wtx , keyChange , nFeeRequired , nChangePosRet , strFailReason ) ;
bool fCreated = pwalletMain - > 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 ) ;
if ( ! pwalletMain - > CommitTransaction ( wtx , keyChange , g_connman . get ( ) ) )
CValidationState state ;
throw JSONRPCError ( RPC_WALLET_ERROR , " Transaction commit failed " ) ;
if ( ! pwalletMain - > CommitTransaction ( wtx , keyChange , g_connman . get ( ) , state ) ) {
strFailReason = strprintf ( " Transaction commit failed:: %s " , state . GetRejectReason ( ) ) ;
throw JSONRPCError ( RPC_WALLET_ERROR , strFailReason ) ;
}
return wtx . GetHash ( ) . GetHex ( ) ;
return wtx . GetHash ( ) . GetHex ( ) ;
}
}