UNPKG

opnet

Version:

The perfect library for building Bitcoin-based applications.

25 lines (24 loc) 810 B
import { BufferHelper } from '@btc-vision/transaction'; export class StoredValue { pointer; value; height; proofs; constructor(iStoredValue) { this.pointer = typeof iStoredValue.pointer === 'string' ? this.base64ToBigInt(iStoredValue.pointer) : iStoredValue.pointer; if (typeof iStoredValue.value !== 'string') { this.value = iStoredValue.value; } else { this.value = Buffer.from(iStoredValue.value, iStoredValue.value.startsWith('0x') ? 'hex' : 'base64'); } this.height = BigInt(iStoredValue.height); this.proofs = iStoredValue.proofs || []; } base64ToBigInt(base64) { return BufferHelper.uint8ArrayToPointer(Buffer.from(base64, 'base64')); } }