Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/rawtransaction.cpp
Show First 20 Lines • Show All 798 Lines • ▼ Show 20 Lines | static UniValue combinerawtransaction(const Config &config, | ||||
// Sign what we can: | // Sign what we can: | ||||
for (size_t i = 0; i < mergedTx.vin.size(); i++) { | for (size_t i = 0; i < mergedTx.vin.size(); i++) { | ||||
CTxIn &txin = mergedTx.vin[i]; | CTxIn &txin = mergedTx.vin[i]; | ||||
const Coin &coin = view.AccessCoin(txin.prevout); | const Coin &coin = view.AccessCoin(txin.prevout); | ||||
if (coin.IsSpent()) { | if (coin.IsSpent()) { | ||||
throw JSONRPCError(RPC_VERIFY_ERROR, | throw JSONRPCError(RPC_VERIFY_ERROR, | ||||
"Input not found or already spent"); | "Input not found or already spent"); | ||||
} | } | ||||
const CScript &prevPubKey = coin.GetTxOut().scriptPubKey; | |||||
const Amount &amount = coin.GetTxOut().nValue; | |||||
SignatureData sigdata; | SignatureData sigdata; | ||||
const CTxOut &txout = coin.GetTxOut(); | |||||
// ... and merge in other signatures: | // ... and merge in other signatures: | ||||
for (const CMutableTransaction &txv : txVariants) { | for (const CMutableTransaction &txv : txVariants) { | ||||
if (txv.vin.size() > i) { | if (txv.vin.size() > i) { | ||||
sigdata = CombineSignatures( | sigdata.MergeSignatureData(DataFromTransaction(txv, i, txout)); | ||||
prevPubKey, | |||||
TransactionSignatureChecker(&txConst, i, amount), sigdata, | |||||
DataFromTransaction(txv, i, coin.GetTxOut())); | |||||
} | } | ||||
} | } | ||||
ProduceSignature( | |||||
DUMMY_SIGNING_PROVIDER, | |||||
MutableTransactionSignatureCreator(&mergedTx, i, txout.nValue), | |||||
txout.scriptPubKey, sigdata); | |||||
UpdateInput(txin, sigdata); | UpdateInput(txin, sigdata); | ||||
} | } | ||||
return EncodeHexTx(CTransaction(mergedTx)); | return EncodeHexTx(CTransaction(mergedTx)); | ||||
} | } | ||||
UniValue SignTransaction(CMutableTransaction &mtx, | UniValue SignTransaction(CMutableTransaction &mtx, | ||||
▲ Show 20 Lines • Show All 158 Lines • ▼ Show 20 Lines | for (size_t i = 0; i < mtx.vin.size(); i++) { | ||||
// Only sign SIGHASH_SINGLE if there's a corresponding output: | // Only sign SIGHASH_SINGLE if there's a corresponding output: | ||||
if ((sigHashType.getBaseType() != BaseSigHashType::SINGLE) || | if ((sigHashType.getBaseType() != BaseSigHashType::SINGLE) || | ||||
(i < mtx.vout.size())) { | (i < mtx.vout.size())) { | ||||
ProduceSignature(*keystore, | ProduceSignature(*keystore, | ||||
MutableTransactionSignatureCreator(&mtx, i, amount, | MutableTransactionSignatureCreator(&mtx, i, amount, | ||||
sigHashType), | sigHashType), | ||||
prevPubKey, sigdata); | prevPubKey, sigdata); | ||||
} | } | ||||
sigdata = CombineSignatures( | |||||
prevPubKey, TransactionSignatureChecker(&txConst, i, amount), | |||||
sigdata, DataFromTransaction(mtx, i, coin.GetTxOut())); | |||||
UpdateInput(txin, sigdata); | UpdateInput(txin, sigdata); | ||||
ScriptError serror = ScriptError::OK; | ScriptError serror = ScriptError::OK; | ||||
if (!VerifyScript( | if (!VerifyScript( | ||||
txin.scriptSig, prevPubKey, STANDARD_SCRIPT_VERIFY_FLAGS, | txin.scriptSig, prevPubKey, STANDARD_SCRIPT_VERIFY_FLAGS, | ||||
TransactionSignatureChecker(&txConst, i, amount), &serror)) { | TransactionSignatureChecker(&txConst, i, amount), &serror)) { | ||||
if (serror == ScriptError::INVALID_STACK_OPERATION) { | if (serror == ScriptError::INVALID_STACK_OPERATION) { | ||||
▲ Show 20 Lines • Show All 353 Lines • Show Last 20 Lines |