Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 369 Lines • ▼ Show 20 Lines | if (!pwallet->CreateTransaction(locked_chain, vecSend, tx, nFeeRequired, | ||||
if (!fSubtractFeeFromAmount && nValue + nFeeRequired > curBalance) { | if (!fSubtractFeeFromAmount && nValue + nFeeRequired > curBalance) { | ||||
strError = strprintf("Error: This transaction requires a " | strError = strprintf("Error: This transaction requires a " | ||||
"transaction fee of at least %s", | "transaction fee of at least %s", | ||||
FormatMoney(nFeeRequired)); | FormatMoney(nFeeRequired)); | ||||
} | } | ||||
throw JSONRPCError(RPC_WALLET_ERROR, strError); | throw JSONRPCError(RPC_WALLET_ERROR, strError); | ||||
} | } | ||||
TxValidationState state; | TxValidationState state; | ||||
if (!pwallet->CommitTransaction(tx, std::move(mapValue), {} /* orderForm */, | pwallet->CommitTransaction(tx, std::move(mapValue), {} /* orderForm */, | ||||
state)) { | state); | ||||
strError = | |||||
strprintf("Error: The transaction was rejected! Reason given: %s", | |||||
FormatStateMessage(state)); | |||||
throw JSONRPCError(RPC_WALLET_ERROR, strError); | |||||
} | |||||
return tx; | return tx; | ||||
} | } | ||||
static UniValue sendtoaddress(const Config &config, | static UniValue sendtoaddress(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | ||||
CWallet *const pwallet = wallet.get(); | CWallet *const pwallet = wallet.get(); | ||||
▲ Show 20 Lines • Show All 666 Lines • ▼ Show 20 Lines | static UniValue sendmany(const Config &config, const JSONRPCRequest &request) { | ||||
CCoinControl coinControl; | CCoinControl coinControl; | ||||
bool fCreated = | bool fCreated = | ||||
pwallet->CreateTransaction(*locked_chain, vecSend, tx, nFeeRequired, | pwallet->CreateTransaction(*locked_chain, vecSend, tx, nFeeRequired, | ||||
nChangePosRet, strFailReason, coinControl); | nChangePosRet, strFailReason, coinControl); | ||||
if (!fCreated) { | if (!fCreated) { | ||||
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, strFailReason); | throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, strFailReason); | ||||
} | } | ||||
TxValidationState state; | TxValidationState state; | ||||
if (!pwallet->CommitTransaction(tx, std::move(mapValue), {} /* orderForm */, | pwallet->CommitTransaction(tx, std::move(mapValue), {} /* orderForm */, | ||||
state)) { | state); | ||||
strFailReason = strprintf("Transaction commit failed:: %s", | |||||
FormatStateMessage(state)); | |||||
throw JSONRPCError(RPC_WALLET_ERROR, strFailReason); | |||||
} | |||||
return tx->GetId().GetHex(); | return tx->GetId().GetHex(); | ||||
} | } | ||||
static UniValue addmultisigaddress(const Config &config, | static UniValue addmultisigaddress(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); | ||||
CWallet *const pwallet = wallet.get(); | CWallet *const pwallet = wallet.get(); | ||||
▲ Show 20 Lines • Show All 3,652 Lines • Show Last 20 Lines |