Skip to main content

WitnessTx

Git Source

State Variables

SEGWIT_MARKER

bytes1 constant SEGWIT_MARKER = hex"00";

SEGWIT_FLAG

bytes1 constant SEGWIT_FLAG = hex"01";

Functions

validateWitnessProof

Validates the SPV proof of the Bitcoin transaction with witness data. Reverts in case the validation or proof verification fail.

function validateWitnessProof(WitnessInfo memory txInfo, WitnessProof memory proof)
internal
view
returns (bytes32 wTxHash);

Parameters

NameTypeDescription
txInfoWitnessInfoBitcoin transaction data.
proofWitnessProofBitcoin proof data.

Returns

NameTypeDescription
wTxHashbytes32Proven 32-byte transaction hash.

validateWitnessProofAndDifficulty

Validates the witness SPV proof using the relay.

function validateWitnessProofAndDifficulty(
IRelay relay,
uint256 txProofDifficultyFactor,
WitnessInfo memory txInfo,
WitnessProof memory proof
) internal view returns (bytes32 wTxHash);

Parameters

NameTypeDescription
relayIRelayBitcoin relay providing the current Bitcoin network difficulty.
txProofDifficultyFactoruint256The number of confirmations required on the Bitcoin chain.
txInfoWitnessInfoBitcoin transaction data.
proofWitnessProofBitcoin proof data.

Returns

NameTypeDescription
wTxHashbytes32Proven 32-byte transaction hash.

Structs

WitnessInfo

Represents a Bitcoin transaction with the witness data.

struct WitnessInfo {
BitcoinTx.Info info;
bytes witnessVector;
}

WitnessProof

Represents data needed to perform a Bitcoin SPV proof with witness data.

struct WitnessProof {
bytes32 witnessNonce;
bytes32 paymentMerkleRoot;
BitcoinTx.Proof coinbaseProof;
BitcoinTx.Proof paymentProof;
BitcoinTx.Info coinbaseTx;
}