mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02:00
Do non-depth check for peg-in witness where possible
This commit is contained in:
parent
8b93cee2fd
commit
880945d303
2 changed files with 7 additions and 7 deletions
|
|
@ -162,7 +162,8 @@ int64_t GetTransactionSigOpCost(const CTransaction& tx, const CCoinsViewCache& i
|
||||||
CTxOut prevout;
|
CTxOut prevout;
|
||||||
if (tx.vin[i].m_is_pegin) {
|
if (tx.vin[i].m_is_pegin) {
|
||||||
std::string err;
|
std::string err;
|
||||||
if (tx.witness.vtxinwit.size() <= i || !IsValidPeginWitness(tx.witness.vtxinwit[i].m_pegin_witness, tx.vin[i].prevout, err, true)) {
|
// Make sure witness exists and is properly formatted
|
||||||
|
if (tx.witness.vtxinwit.size() != tx.vin.size() || !IsValidPeginWitness(tx.witness.vtxinwit[i].m_pegin_witness, tx.vin[i].prevout, err, false)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
prevout = GetPeginOutputFromWitness(tx.witness.vtxinwit[i].m_pegin_witness);
|
prevout = GetPeginOutputFromWitness(tx.witness.vtxinwit[i].m_pegin_witness);
|
||||||
|
|
|
||||||
|
|
@ -689,12 +689,11 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
|
||||||
// This only checks the UTXO set for already claimed pegins. For mempool conflicts,
|
// This only checks the UTXO set for already claimed pegins. For mempool conflicts,
|
||||||
// we rely on the GetConflictTx check done above.
|
// we rely on the GetConflictTx check done above.
|
||||||
if (txin.m_is_pegin) {
|
if (txin.m_is_pegin) {
|
||||||
// Quick sanity check on witness first.
|
// Peg-in witness is required, check here without validating existence in parent chain
|
||||||
if (tx.witness.vtxinwit.size() <= i ||
|
std::string err_msg = "no peg-in witness attached";
|
||||||
tx.witness.vtxinwit[i].m_pegin_witness.stack.size() < 6 ||
|
if (tx.witness.vtxinwit.size() != tx.vin.size() ||
|
||||||
uint256(tx.witness.vtxinwit[i].m_pegin_witness.stack[2]).IsNull() ||
|
!IsValidPeginWitness(tx.witness.vtxinwit[i].m_pegin_witness, tx.vin[i].prevout, err_msg, false)) {
|
||||||
tx.vin[i].prevout.hash.IsNull()) {
|
return state.Invalid(false, REJECT_INVALID, "pegin-no-witness", err_msg);
|
||||||
return state.Invalid(false, REJECT_INVALID, "pegin-no-witness");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<uint256, COutPoint> pegin = std::make_pair(uint256(tx.witness.vtxinwit[i].m_pegin_witness.stack[2]), tx.vin[i].prevout);
|
std::pair<uint256, COutPoint> pegin = std::make_pair(uint256(tx.witness.vtxinwit[i].m_pegin_witness.stack[2]), tx.vin[i].prevout);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue