Expose only blockchain hash twice in header

This commit is contained in:
sanket1729 2021-01-25 19:38:15 -08:00
parent afb9e7b727
commit a26f6fead6
9 changed files with 37 additions and 34 deletions

View file

@ -77,7 +77,7 @@ static bool verify_flags(unsigned int flags)
return (flags & ~(bitcoinconsensus_SCRIPT_FLAGS_VERIFY_ALL)) == 0;
}
static int verify_script(const unsigned char *parent_genesis_hash, const unsigned char *parent_pegged_asset,
static int verify_script(const unsigned char *hash_genesis_block,
const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen, CConfidentialValue amount,
const unsigned char *txTo , unsigned int txToLen,
unsigned int nIn, unsigned int flags, bitcoinconsensus_error* err)
@ -96,9 +96,8 @@ static int verify_script(const unsigned char *parent_genesis_hash, const unsigne
// Regardless of the verification result, the tx did not error.
set_error(err, bitcoinconsensus_ERR_OK);
auto parent_genesis_hash_ = parent_genesis_hash ? uint256{parent_genesis_hash, 32} : uint256{};
auto parent_pegged_asset_ = CAsset(parent_pegged_asset ? uint256{parent_pegged_asset, 32} : uint256{});
PrecomputedTransactionData txdata(parent_genesis_hash_, parent_pegged_asset_);
auto hash_genesis_block_ = hash_genesis_block ? uint256{hash_genesis_block, 32} : uint256{};
PrecomputedTransactionData txdata(hash_genesis_block_);
txdata.Init(tx, {});
const CScriptWitness* pScriptWitness = (tx.witness.vtxinwit.size() > nIn ? &tx.witness.vtxinwit[nIn].scriptWitness : NULL);
return VerifyScript(tx.vin[nIn].scriptSig, CScript(scriptPubKey, scriptPubKey + scriptPubKeyLen), pScriptWitness, flags, TransactionSignatureChecker(&tx, nIn, amount, txdata), NULL);
@ -107,7 +106,7 @@ static int verify_script(const unsigned char *parent_genesis_hash, const unsigne
}
}
int bitcoinconsensus_verify_script_with_amount(const unsigned char *parent_genesis_hash, const unsigned char *parent_pegged_asset,
int bitcoinconsensus_verify_script_with_amount(const unsigned char *hash_genesis_block,
const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen,
const unsigned char *amount, unsigned int amountLen,
const unsigned char *txTo , unsigned int txToLen,
@ -118,14 +117,14 @@ int bitcoinconsensus_verify_script_with_amount(const unsigned char *parent_genes
CConfidentialValue am;
stream >> am;
return ::verify_script(parent_genesis_hash, parent_pegged_asset, scriptPubKey, scriptPubKeyLen, am, txTo, txToLen, nIn, flags, err);
return ::verify_script(hash_genesis_block, scriptPubKey, scriptPubKeyLen, am, txTo, txToLen, nIn, flags, err);
} catch (const std::exception&) {
return set_error(err, bitcoinconsensus_ERR_TX_DESERIALIZE); // Error deserializing
}
}
int bitcoinconsensus_verify_script(const unsigned char *parent_genesis_hash, const unsigned char *parent_pegged_asset,
int bitcoinconsensus_verify_script(const unsigned char *hash_genesis_block,
const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen,
const unsigned char *txTo , unsigned int txToLen,
unsigned int nIn, unsigned int flags, bitcoinconsensus_error* err)
@ -135,7 +134,7 @@ int bitcoinconsensus_verify_script(const unsigned char *parent_genesis_hash, con
}
CConfidentialValue am(0);
return ::verify_script(parent_genesis_hash, parent_pegged_asset, scriptPubKey, scriptPubKeyLen, am, txTo, txToLen, nIn, flags, err);
return ::verify_script(hash_genesis_block, scriptPubKey, scriptPubKeyLen, am, txTo, txToLen, nIn, flags, err);
}
unsigned int bitcoinconsensus_version()