UNPKG

opnet

Version:

The perfect library for building Bitcoin-based applications.

36 lines (35 loc) 1.01 kB
import { fromBase64 } from '@btc-vision/bitcoin'; export class UTXO { transactionId; outputIndex; value; scriptPubKey; nonWitnessUtxoBase64; nonWitnessUtxo; witnessScript; redeemScript; isCSV; constructor(iUTXO, isCSV) { this.transactionId = iUTXO.transactionId; this.outputIndex = iUTXO.outputIndex; this.isCSV = isCSV || false; this.value = BigInt(iUTXO.value); this.scriptPubKey = iUTXO.scriptPubKey; this.nonWitnessUtxoBase64 = iUTXO.raw; this.witnessScript = iUTXO.witnessScript; if (iUTXO.raw) { const raw = iUTXO.raw; let cached; Object.defineProperty(this, 'nonWitnessUtxo', { get() { if (!cached) { cached = fromBase64(raw); } return cached; }, enumerable: true, configurable: true, }); } } }