Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show All 14 Lines | |||||
#include <key.h> | #include <key.h> | ||||
#include <key_io.h> | #include <key_io.h> | ||||
#include <keystore.h> | #include <keystore.h> | ||||
#include <net.h> | #include <net.h> | ||||
#include <policy/policy.h> | #include <policy/policy.h> | ||||
#include <primitives/block.h> | #include <primitives/block.h> | ||||
#include <primitives/transaction.h> | #include <primitives/transaction.h> | ||||
#include <random.h> | #include <random.h> | ||||
#include <rpc/server.h> // for IsDeprecatedRPCEnabled | |||||
#include <script/script.h> | #include <script/script.h> | ||||
#include <script/sighashtype.h> | #include <script/sighashtype.h> | ||||
#include <script/sign.h> | #include <script/sign.h> | ||||
#include <timedata.h> | #include <timedata.h> | ||||
#include <txmempool.h> | #include <txmempool.h> | ||||
#include <ui_interface.h> | #include <ui_interface.h> | ||||
#include <util.h> | #include <util.h> | ||||
#include <utilmoneystr.h> | #include <utilmoneystr.h> | ||||
▲ Show 20 Lines • Show All 2,791 Lines • ▼ Show 20 Lines | bool CWallet::SignTransaction(CMutableTransaction &tx) { | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
bool CWallet::FundTransaction(CMutableTransaction &tx, Amount &nFeeRet, | bool CWallet::FundTransaction(CMutableTransaction &tx, Amount &nFeeRet, | ||||
int &nChangePosInOut, std::string &strFailReason, | int &nChangePosInOut, std::string &strFailReason, | ||||
bool lockUnspents, | bool lockUnspents, | ||||
const std::set<int> &setSubtractFeeFromOutputs, | const std::set<int> &setSubtractFeeFromOutputs, | ||||
CCoinControl coinControl, bool keepReserveKey) { | CCoinControl coinControl) { | ||||
std::vector<CRecipient> vecSend; | std::vector<CRecipient> vecSend; | ||||
// Turn the txout set into a CRecipient vector. | // Turn the txout set into a CRecipient vector. | ||||
for (size_t idx = 0; idx < tx.vout.size(); idx++) { | for (size_t idx = 0; idx < tx.vout.size(); idx++) { | ||||
const CTxOut &txOut = tx.vout[idx]; | const CTxOut &txOut = tx.vout[idx]; | ||||
CRecipient recipient = {txOut.scriptPubKey, txOut.nValue, | CRecipient recipient = {txOut.scriptPubKey, txOut.nValue, | ||||
setSubtractFeeFromOutputs.count(idx) == 1}; | setSubtractFeeFromOutputs.count(idx) == 1}; | ||||
vecSend.push_back(recipient); | vecSend.push_back(recipient); | ||||
Show All 18 Lines | bool CWallet::FundTransaction(CMutableTransaction &tx, Amount &nFeeRet, | ||||
} | } | ||||
if (nChangePosInOut != -1) { | if (nChangePosInOut != -1) { | ||||
tx.vout.insert(tx.vout.begin() + nChangePosInOut, | tx.vout.insert(tx.vout.begin() + nChangePosInOut, | ||||
tx_new->vout[nChangePosInOut]); | tx_new->vout[nChangePosInOut]); | ||||
// We don't have the normal Create/Commit cycle, and don't want to | // We don't have the normal Create/Commit cycle, and don't want to | ||||
// risk reusing change, so just remove the key from the keypool | // risk reusing change, so just remove the key from the keypool | ||||
// here. | // here. | ||||
if (!IsDeprecatedRPCEnabled(gArgs, "fundrawtransaction")) { | |||||
reservekey.KeepKey(); | reservekey.KeepKey(); | ||||
} | } | ||||
} | |||||
// Copy output sizes from new transaction; they may have had the fee | // Copy output sizes from new transaction; they may have had the fee | ||||
// subtracted from them. | // subtracted from them. | ||||
for (size_t idx = 0; idx < tx.vout.size(); idx++) { | for (size_t idx = 0; idx < tx.vout.size(); idx++) { | ||||
tx.vout[idx].nValue = tx_new->vout[idx].nValue; | tx.vout[idx].nValue = tx_new->vout[idx].nValue; | ||||
} | } | ||||
// Add new txins (keeping original txin scriptSig/order) | // Add new txins (keeping original txin scriptSig/order) | ||||
for (const CTxIn &txin : tx_new->vin) { | for (const CTxIn &txin : tx_new->vin) { | ||||
if (!coinControl.IsSelected(txin.prevout)) { | if (!coinControl.IsSelected(txin.prevout)) { | ||||
tx.vin.push_back(txin); | tx.vin.push_back(txin); | ||||
if (lockUnspents) { | if (lockUnspents) { | ||||
LockCoin(txin.prevout); | LockCoin(txin.prevout); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
// DEPRECATED, remove in 0.20 with -reserveChangeKey | |||||
// Optionally keep the change output key. | |||||
if (IsDeprecatedRPCEnabled(gArgs, "fundrawtransaction")) { | |||||
if (keepReserveKey) { | |||||
reservekey.KeepKey(); | |||||
} | |||||
} | |||||
return true; | return true; | ||||
} | } | ||||
OutputType | OutputType | ||||
CWallet::TransactionChangeType(OutputType change_type, | CWallet::TransactionChangeType(OutputType change_type, | ||||
const std::vector<CRecipient> &vecSend) { | const std::vector<CRecipient> &vecSend) { | ||||
// If -changetype is specified, always use that change type. | // If -changetype is specified, always use that change type. | ||||
if (change_type != OutputType::NONE) { | if (change_type != OutputType::NONE) { | ||||
▲ Show 20 Lines • Show All 1,882 Lines • Show Last 20 Lines |