MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / SignTransaction

Method SignTransaction

src/wallet/wallet.cpp:2557–2579  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2555}
2556
2557bool CWallet::SignTransaction(CMutableTransaction &tx, bool no_forkid)
2558{
2559 AssertLockHeld(cs_wallet); // mapWallet
2560
2561 // sign the new tx
2562 int nIn = 0;
2563 for (auto& input : tx.vin) {
2564 std::map<uint256, CWalletTx>::const_iterator mi = mapWallet.find(input.prevout.hash);
2565 if(mi == mapWallet.end() || input.prevout.n >= mi->second.tx->vout.size()) {
2566 return false;
2567 }
2568 const CScript& scriptPubKey = mi->second.tx->vout[input.prevout.n].scriptPubKey;
2569 const CAmount& amount = mi->second.tx->vout[input.prevout.n].nValue;
2570 SignatureData sigdata;
2571 const int sighash_flag = no_forkid ? SIGHASH_ALL : SIGHASH_ALL | SIGHASH_FORKID;
2572 if (!ProduceSignature(*this, MutableTransactionSignatureCreator(&tx, nIn, amount, no_forkid, sighash_flag), scriptPubKey, sigdata, no_forkid)) {
2573 return false;
2574 }
2575 UpdateInput(input, sigdata);
2576 nIn++;
2577 }
2578 return true;
2579}
2580
2581bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nChangePosInOut, std::string& strFailReason, bool lockUnspents, const std::set<int>& setSubtractFeeFromOutputs, CCoinControl coinControl)
2582{

Callers 1

SignTransactionFunction · 0.80

Calls 6

ProduceSignatureFunction · 0.85
UpdateInputFunction · 0.85
findMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected