Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 2,782 Lines • ▼ Show 20 Lines | bool CWallet::SelectCoins(const std::vector<COutput> &vAvailableCoins, | ||||
nValueRet += nValueFromPresetInputs; | nValueRet += nValueFromPresetInputs; | ||||
return res; | return res; | ||||
} | } | ||||
bool CWallet::SignTransaction(CMutableTransaction &tx) { | bool CWallet::SignTransaction(CMutableTransaction &tx) { | ||||
// sign the new tx | // sign the new tx | ||||
int nIn = 0; | int nIn = 0; | ||||
for (const auto &input : tx.vin) { | for (CTxIn &input : tx.vin) { | ||||
auto mi = mapWallet.find(input.prevout.GetTxId()); | auto mi = mapWallet.find(input.prevout.GetTxId()); | ||||
if (mi == mapWallet.end() || | if (mi == mapWallet.end() || | ||||
input.prevout.GetN() >= mi->second.tx->vout.size()) { | input.prevout.GetN() >= mi->second.tx->vout.size()) { | ||||
return false; | return false; | ||||
} | } | ||||
const CScript &scriptPubKey = | const CScript &scriptPubKey = | ||||
mi->second.tx->vout[input.prevout.GetN()].scriptPubKey; | mi->second.tx->vout[input.prevout.GetN()].scriptPubKey; | ||||
const Amount amount = mi->second.tx->vout[input.prevout.GetN()].nValue; | const Amount amount = mi->second.tx->vout[input.prevout.GetN()].nValue; | ||||
SignatureData sigdata; | SignatureData sigdata; | ||||
SigHashType sigHashType = SigHashType().withForkId(); | SigHashType sigHashType = SigHashType().withForkId(); | ||||
if (!ProduceSignature(*this, | if (!ProduceSignature(*this, | ||||
MutableTransactionSignatureCreator( | MutableTransactionSignatureCreator( | ||||
&tx, nIn, amount, sigHashType), | &tx, nIn, amount, sigHashType), | ||||
scriptPubKey, sigdata)) { | scriptPubKey, sigdata)) { | ||||
return false; | return false; | ||||
} | } | ||||
UpdateTransaction(tx, nIn, sigdata); | UpdateInput(input, sigdata); | ||||
nIn++; | nIn++; | ||||
} | } | ||||
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, | ||||
▲ Show 20 Lines • Show All 444 Lines • ▼ Show 20 Lines | assert(txNew.nLockTime < LOCKTIME_THRESHOLD); | ||||
*this, | *this, | ||||
MutableTransactionSignatureCreator( | MutableTransactionSignatureCreator( | ||||
&txNew, nIn, coin.txout.nValue, sigHashType), | &txNew, nIn, coin.txout.nValue, sigHashType), | ||||
scriptPubKey, sigdata)) { | scriptPubKey, sigdata)) { | ||||
strFailReason = _("Signing transaction failed"); | strFailReason = _("Signing transaction failed"); | ||||
return false; | return false; | ||||
} | } | ||||
UpdateTransaction(txNew, nIn, sigdata); | UpdateInput(txNew.vin.at(nIn), sigdata); | ||||
nIn++; | nIn++; | ||||
} | } | ||||
} | } | ||||
// Return the constructed transaction data. | // Return the constructed transaction data. | ||||
tx = MakeTransactionRef(std::move(txNew)); | tx = MakeTransactionRef(std::move(txNew)); | ||||
// Limit size. | // Limit size. | ||||
▲ Show 20 Lines • Show All 1,478 Lines • Show Last 20 Lines |