Skip to content

Instantly share code, notes, and snippets.

@planethouki
planethouki / validateTransactionInBlock.ts
Last active February 12, 2020 23:38 — forked from dgarcia360/validateTransactionInBlock.ts
validate transaction in block (WIP)
import {BlockRepository, RepositoryFactoryHttp, UInt64} from "nem2-sdk";
import {sha3_256} from "js-sha3";
const validateTransactionInBlock = async (leaf: string, height: UInt64, blockHttp: BlockRepository) => {
// 1.Calculate H(B) (leaf)
// 2. Obtain HRoot; in Symbol, this is stored in the block header.
const HRoot = (await blockHttp.getBlockByHeight(height).toPromise()).blockTransactionsHash;
console.log('Hroot', HRoot);
// 3. Request merkle path H(A), HCD, HEE2.
const merklePath = (await blockHttp.getMerkleTransaction(height, leaf).toPromise()).merklePath;