exoticMerkleProof function
Returns a record of proofDepth as int, proofHash as Uint8List for one reference in Merkle Proof cell
Implementation
({
int proofDepth,
Uint8List proofHash,
}) exoticMerkleProof(BitString bits, List<Cell> refs) {
final reader = BitReader(bits);
// type + hash + depth
if (bits.length != 8 + 256 + 16) {
throw 'Merkle Proof cell must have exactly (8 + 256 + 16) bits, got ${bits.length}';
}
if (refs.length != 1) {
throw 'Merkle Proof cell must have exactly 1 reference, got ${refs.length}';
}
var type = reader.loadUint(8);
if (type != 3) {
throw 'Merkle Proof cell must have type 3, got $type';
}
final proofHash = reader.loadList(32);
final proofDepth = reader.loadUint(16);
final refHash = refs[0].hash(0);
final refDepth = refs[0].depth(0);
if (proofDepth != refDepth) {
throw 'Merkle Proof cell reference depth must be exactly $proofDepth, got $refDepth';
}
if (!proofHash.equals(refHash)) {
throw 'Merkle Proof cell reference hash must be exactly ${hex.encode(proofHash)}, got ${hex.encode(refHash)}';
}
return (
proofDepth: proofDepth,
proofHash: proofHash,
);
}