Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/rpcwallet.cpp
Show First 20 Lines • Show All 367 Lines • ▼ Show 20 Lines | if (!pwallet->CreateTransaction(locked_chain, vecSend, tx, nFeeRequired, | ||||
nChangePosRet, strError, coinControl)) { | nChangePosRet, strError, coinControl)) { | ||||
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); | ||||
} | } | ||||
CValidationState state; | TxValidationState state; | ||||
if (!pwallet->CommitTransaction(tx, std::move(mapValue), {} /* orderForm */, | if (!pwallet->CommitTransaction(tx, std::move(mapValue), {} /* orderForm */, | ||||
state)) { | state)) { | ||||
strError = | strError = | ||||
strprintf("Error: The transaction was rejected! Reason given: %s", | strprintf("Error: The transaction was rejected! Reason given: %s", | ||||
FormatStateMessage(state)); | FormatStateMessage(state)); | ||||
throw JSONRPCError(RPC_WALLET_ERROR, strError); | throw JSONRPCError(RPC_WALLET_ERROR, strError); | ||||
} | } | ||||
return tx; | return tx; | ||||
▲ Show 20 Lines • Show All 305 Lines • ▼ Show 20 Lines | if (!request.params[1].isNull()) { | ||||
nMinDepth = request.params[1].get_int(); | nMinDepth = request.params[1].get_int(); | ||||
} | } | ||||
// Tally | // Tally | ||||
Amount nAmount = Amount::zero(); | Amount nAmount = Amount::zero(); | ||||
for (const std::pair<const TxId, CWalletTx> &pairWtx : pwallet->mapWallet) { | for (const std::pair<const TxId, CWalletTx> &pairWtx : pwallet->mapWallet) { | ||||
const CWalletTx &wtx = pairWtx.second; | const CWalletTx &wtx = pairWtx.second; | ||||
CValidationState state; | TxValidationState state; | ||||
if (wtx.IsCoinBase() || | if (wtx.IsCoinBase() || | ||||
!locked_chain->contextualCheckTransactionForCurrentBlock( | !locked_chain->contextualCheckTransactionForCurrentBlock( | ||||
config.GetChainParams().GetConsensus(), *wtx.tx, state)) { | config.GetChainParams().GetConsensus(), *wtx.tx, state)) { | ||||
continue; | continue; | ||||
} | } | ||||
for (const CTxOut &txout : wtx.tx->vout) { | for (const CTxOut &txout : wtx.tx->vout) { | ||||
if (txout.scriptPubKey == scriptPubKey) { | if (txout.scriptPubKey == scriptPubKey) { | ||||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | static UniValue getreceivedbylabel(const Config &config, | ||||
// Get the set of pub keys assigned to label | // Get the set of pub keys assigned to label | ||||
std::string label = LabelFromValue(request.params[0]); | std::string label = LabelFromValue(request.params[0]); | ||||
std::set<CTxDestination> setAddress = pwallet->GetLabelAddresses(label); | std::set<CTxDestination> setAddress = pwallet->GetLabelAddresses(label); | ||||
// Tally | // Tally | ||||
Amount nAmount = Amount::zero(); | Amount nAmount = Amount::zero(); | ||||
for (const std::pair<const TxId, CWalletTx> &pairWtx : pwallet->mapWallet) { | for (const std::pair<const TxId, CWalletTx> &pairWtx : pwallet->mapWallet) { | ||||
const CWalletTx &wtx = pairWtx.second; | const CWalletTx &wtx = pairWtx.second; | ||||
CValidationState state; | TxValidationState state; | ||||
if (wtx.IsCoinBase() || | if (wtx.IsCoinBase() || | ||||
!locked_chain->contextualCheckTransactionForCurrentBlock( | !locked_chain->contextualCheckTransactionForCurrentBlock( | ||||
config.GetChainParams().GetConsensus(), *wtx.tx, state)) { | config.GetChainParams().GetConsensus(), *wtx.tx, state)) { | ||||
continue; | continue; | ||||
} | } | ||||
for (const CTxOut &txout : wtx.tx->vout) { | for (const CTxOut &txout : wtx.tx->vout) { | ||||
CTxDestination address; | CTxDestination address; | ||||
▲ Show 20 Lines • Show All 276 Lines • ▼ Show 20 Lines | static UniValue sendmany(const Config &config, const JSONRPCRequest &request) { | ||||
CTransactionRef tx; | CTransactionRef tx; | ||||
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); | ||||
} | } | ||||
CValidationState state; | TxValidationState state; | ||||
if (!pwallet->CommitTransaction(tx, std::move(mapValue), {} /* orderForm */, | if (!pwallet->CommitTransaction(tx, std::move(mapValue), {} /* orderForm */, | ||||
state)) { | state)) { | ||||
strFailReason = strprintf("Transaction commit failed:: %s", | strFailReason = strprintf("Transaction commit failed:: %s", | ||||
FormatStateMessage(state)); | FormatStateMessage(state)); | ||||
throw JSONRPCError(RPC_WALLET_ERROR, strFailReason); | throw JSONRPCError(RPC_WALLET_ERROR, strFailReason); | ||||
} | } | ||||
return tx->GetId().GetHex(); | return tx->GetId().GetHex(); | ||||
▲ Show 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | if (!by_label && params.size() > 3) { | ||||
has_filtered_address = true; | has_filtered_address = true; | ||||
} | } | ||||
// Tally | // Tally | ||||
std::map<CTxDestination, tallyitem> mapTally; | std::map<CTxDestination, tallyitem> mapTally; | ||||
for (const std::pair<const TxId, CWalletTx> &pairWtx : pwallet->mapWallet) { | for (const std::pair<const TxId, CWalletTx> &pairWtx : pwallet->mapWallet) { | ||||
const CWalletTx &wtx = pairWtx.second; | const CWalletTx &wtx = pairWtx.second; | ||||
CValidationState state; | TxValidationState state; | ||||
if (wtx.IsCoinBase() || | if (wtx.IsCoinBase() || | ||||
!locked_chain.contextualCheckTransactionForCurrentBlock( | !locked_chain.contextualCheckTransactionForCurrentBlock( | ||||
config.GetChainParams().GetConsensus(), *wtx.tx, state)) { | config.GetChainParams().GetConsensus(), *wtx.tx, state)) { | ||||
continue; | continue; | ||||
} | } | ||||
int nDepth = wtx.GetDepthInMainChain(locked_chain); | int nDepth = wtx.GetDepthInMainChain(locked_chain); | ||||
if (nDepth < nMinDepth) { | if (nDepth < nMinDepth) { | ||||
▲ Show 20 Lines • Show All 3,508 Lines • Show Last 20 Lines |