UNPKG

opnet

Version:

The perfect library for building Bitcoin-based applications.

57 lines (56 loc) 1.73 kB
import { Address } from '@btc-vision/transaction'; import { TransactionParser } from '../transactions/TransactionParser.js'; export class Block { height; hash; previousBlockHash; previousBlockChecksum; bits; nonce; version; size; txCount; weight; strippedSize; time; medianTime; checksumRoot; merkleRoot; storageRoot; receiptRoot; ema; baseGas; gasUsed; checksumProofs; transactions = []; deployments = []; constructor(block, network) { this.height = BigInt(block.height.toString()); this.hash = block.hash; this.previousBlockHash = block.previousBlockHash; this.previousBlockChecksum = block.previousBlockChecksum; this.bits = block.bits; this.nonce = block.nonce; this.version = block.version; this.size = block.size; this.txCount = block.txCount; this.ema = BigInt(block.ema); this.baseGas = BigInt(block.baseGas); this.gasUsed = BigInt(block.gasUsed); this.weight = block.weight; this.strippedSize = block.strippedSize; this.time = block.time; this.medianTime = block.medianTime; this.checksumRoot = block.checksumRoot; this.merkleRoot = block.merkleRoot; this.storageRoot = block.storageRoot; this.receiptRoot = block.receiptRoot; this.checksumProofs = block.checksumProofs; this.transactions = TransactionParser.parseTransactions(block.transactions, network); this.deployments = block.deployments ? block.deployments.map((address) => { return Address.fromString(address); }) : []; } }