mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
Merge b557a24be9 into merged_master (Bitcoin PR bitcoin/bitcoin#19426)
This commit is contained in:
commit
cf81ccbd1f
10 changed files with 28 additions and 26 deletions
20
src/script/sign.cpp
Normal file → Executable file
20
src/script/sign.cpp
Normal file → Executable file
|
|
@ -22,16 +22,16 @@
|
|||
|
||||
typedef std::vector<unsigned char> valtype;
|
||||
|
||||
MutableTransactionSignatureCreator::MutableTransactionSignatureCreator(const CMutableTransaction* tx, unsigned int input_idx, const CConfidentialValue& amount, int hash_type)
|
||||
: txTo{tx}, nIn{input_idx}, nHashType{hash_type}, amount{amount}, checker{txTo, nIn, amount, MissingDataBehavior::FAIL},
|
||||
MutableTransactionSignatureCreator::MutableTransactionSignatureCreator(const CMutableTransaction& tx, unsigned int input_idx, const CConfidentialValue& amount, int hash_type)
|
||||
: m_txto{tx}, nIn{input_idx}, nHashType{hash_type}, amount{amount}, checker{&m_txto, nIn, amount, MissingDataBehavior::FAIL},
|
||||
m_txdata(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
MutableTransactionSignatureCreator::MutableTransactionSignatureCreator(const CMutableTransaction* tx, unsigned int input_idx, const CConfidentialValue& amount, const PrecomputedTransactionData* txdata, int hash_type)
|
||||
: txTo{tx}, nIn{input_idx}, nHashType{hash_type}, amount{amount},
|
||||
checker{txdata ? MutableTransactionSignatureChecker{txTo, nIn, amount, *txdata, MissingDataBehavior::FAIL} :
|
||||
MutableTransactionSignatureChecker{txTo, nIn, amount, MissingDataBehavior::FAIL}},
|
||||
MutableTransactionSignatureCreator::MutableTransactionSignatureCreator(const CMutableTransaction& tx, unsigned int input_idx, const CConfidentialValue& amount, const PrecomputedTransactionData* txdata, int hash_type)
|
||||
: m_txto{tx}, nIn{input_idx}, nHashType{hash_type}, amount{amount},
|
||||
checker{txdata ? MutableTransactionSignatureChecker{&m_txto, nIn, amount, *txdata, MissingDataBehavior::FAIL} :
|
||||
MutableTransactionSignatureChecker{&m_txto, nIn, amount, MissingDataBehavior::FAIL}},
|
||||
m_txdata(txdata)
|
||||
{
|
||||
}
|
||||
|
|
@ -54,7 +54,7 @@ bool MutableTransactionSignatureCreator::CreateSig(const SigningProvider& provid
|
|||
// BASE/WITNESS_V0 signatures don't support explicit SIGHASH_DEFAULT, use SIGHASH_ALL instead.
|
||||
const int hashtype = nHashType == SIGHASH_DEFAULT ? SIGHASH_ALL : nHashType;
|
||||
|
||||
uint256 hash = SignatureHash(scriptCode, *txTo, nIn, hashtype, amount, sigversion, flags, m_txdata);
|
||||
uint256 hash = SignatureHash(scriptCode, m_txto, nIn, hashtype, amount, sigversion, flags, m_txdata);
|
||||
if (!key.Sign(hash, vchSig))
|
||||
return false;
|
||||
vchSig.push_back((unsigned char)hashtype);
|
||||
|
|
@ -84,7 +84,7 @@ bool MutableTransactionSignatureCreator::CreateSchnorrSig(const SigningProvider&
|
|||
execdata.m_tapleaf_hash = *leaf_hash;
|
||||
}
|
||||
uint256 hash;
|
||||
if (!SignatureHashSchnorr(hash, execdata, *txTo, nIn, nHashType, sigversion, *m_txdata, MissingDataBehavior::FAIL)) return false;
|
||||
if (!SignatureHashSchnorr(hash, execdata, m_txto, nIn, nHashType, sigversion, *m_txdata, MissingDataBehavior::FAIL)) return false;
|
||||
sig.resize(64);
|
||||
// Use uint256{} as aux_rnd for now.
|
||||
if (!key.SignSchnorr(hash, sig, merkle_root, {})) return false;
|
||||
|
|
@ -564,7 +564,7 @@ bool SignSignature(const SigningProvider &provider, const CScript& fromPubKey, C
|
|||
CTransaction txToConst(txTo);
|
||||
//TransactionSignatureCreator creator(&keystore, &txToConst, nIn, amount, nHashType);
|
||||
|
||||
MutableTransactionSignatureCreator creator(&txTo, nIn, amount, nHashType);
|
||||
MutableTransactionSignatureCreator creator(txTo, nIn, amount, nHashType);
|
||||
|
||||
SignatureData sigdata;
|
||||
bool ret = ProduceSignature(provider, creator, fromPubKey, sigdata);
|
||||
|
|
@ -713,7 +713,7 @@ bool SignTransaction(CMutableTransaction& mtx, const SigningProvider* keystore,
|
|||
SignatureData sigdata = DataFromTransaction(mtx, i, prevTxOut);
|
||||
// Only sign SIGHASH_SINGLE if there's a corresponding output:
|
||||
if (!fHashSingle || (i < mtx.vout.size())) {
|
||||
ProduceSignature(*keystore, MutableTransactionSignatureCreator(&mtx, i, amount, &txdata, nHashType), prevPubKey, sigdata);
|
||||
ProduceSignature(*keystore, MutableTransactionSignatureCreator(mtx, i, amount, &txdata, nHashType), prevPubKey, sigdata);
|
||||
}
|
||||
|
||||
UpdateTransaction(mtx, i, sigdata); // ELEMENTS: is UpdateInput in Core
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue