diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-12-21 14:04:03 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-12-21 14:04:06 +0100 |
commit | e8cfe1ee2d01c493b758a67ad14707dca15792ea (patch) | |
tree | 8164f54ddbb171d62bb9bf54949c18a06e5e40dc /src/script | |
parent | 0698639a38069cee268f764e7b732d67622fb3df (diff) | |
parent | f6fb7acda4aefd01b8ef6cd77063bfc0c4f4ab36 (diff) |
Merge #8589: Inline CTxInWitness inside CTxIn
f6fb7ac Move CTxInWitness inside CTxIn (Pieter Wuille)
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/bitcoinconsensus.cpp | 3 | ||||
-rw-r--r-- | src/script/script.h | 2 | ||||
-rw-r--r-- | src/script/sign.cpp | 9 |
3 files changed, 6 insertions, 8 deletions
diff --git a/src/script/bitcoinconsensus.cpp b/src/script/bitcoinconsensus.cpp index 036d6ca7bf..be7fa5d3b7 100644 --- a/src/script/bitcoinconsensus.cpp +++ b/src/script/bitcoinconsensus.cpp @@ -93,8 +93,9 @@ static int verify_script(const unsigned char *scriptPubKey, unsigned int scriptP // Regardless of the verification result, the tx did not error. set_error(err, bitcoinconsensus_ERR_OK); + PrecomputedTransactionData txdata(tx); - return VerifyScript(tx.vin[nIn].scriptSig, CScript(scriptPubKey, scriptPubKey + scriptPubKeyLen), nIn < tx.wit.vtxinwit.size() ? &tx.wit.vtxinwit[nIn].scriptWitness : NULL, flags, TransactionSignatureChecker(&tx, nIn, amount, txdata), NULL); + return VerifyScript(tx.vin[nIn].scriptSig, CScript(scriptPubKey, scriptPubKey + scriptPubKeyLen), &tx.vin[nIn].scriptWitness, flags, TransactionSignatureChecker(&tx, nIn, amount, txdata), NULL); } catch (const std::exception&) { return set_error(err, bitcoinconsensus_ERR_TX_DESERIALIZE); // Error deserializing } diff --git a/src/script/script.h b/src/script/script.h index 278774d32e..76419c1495 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -656,6 +656,8 @@ struct CScriptWitness bool IsNull() const { return stack.empty(); } + void SetNull() { stack.clear(); stack.shrink_to_fit(); } + std::string ToString() const; }; diff --git a/src/script/sign.cpp b/src/script/sign.cpp index f552ad5bba..b008df2591 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -194,9 +194,7 @@ SignatureData DataFromTransaction(const CMutableTransaction& tx, unsigned int nI SignatureData data; assert(tx.vin.size() > nIn); data.scriptSig = tx.vin[nIn].scriptSig; - if (tx.wit.vtxinwit.size() > nIn) { - data.scriptWitness = tx.wit.vtxinwit[nIn].scriptWitness; - } + data.scriptWitness = tx.vin[nIn].scriptWitness; return data; } @@ -204,10 +202,7 @@ void UpdateTransaction(CMutableTransaction& tx, unsigned int nIn, const Signatur { assert(tx.vin.size() > nIn); tx.vin[nIn].scriptSig = data.scriptSig; - if (!data.scriptWitness.IsNull() || tx.wit.vtxinwit.size() > nIn) { - tx.wit.vtxinwit.resize(tx.vin.size()); - tx.wit.vtxinwit[nIn].scriptWitness = data.scriptWitness; - } + tx.vin[nIn].scriptWitness = data.scriptWitness; } bool SignSignature(const CKeyStore &keystore, const CScript& fromPubKey, CMutableTransaction& txTo, unsigned int nIn, const CAmount& amount, int nHashType) |