UNPKG

@btc-vision/transaction

Version:

OPNet transaction library allows you to create and sign transactions for the OPNet network.

52 lines 1.26 kB
import { Address } from '../keypair/Address.js'; export class AddressSet { items; keys; constructor(keys = []) { this.items = new Set(); this.keys = []; for (const key of keys) { this.add(key); } } get size() { return this.keys.length; } add(address) { const addressBigInt = address.toBigInt(); if (!this.items.has(addressBigInt)) { this.items.add(addressBigInt); this.keys.push(address); } } has(address) { return this.items.has(address.toBigInt()); } remove(address) { const addressBigInt = address.toBigInt(); if (this.items.delete(addressBigInt)) { this.keys = this.keys.filter((k) => k.toBigInt() !== addressBigInt); } } clone() { return new AddressSet(this.keys); } clear() { this.items.clear(); this.keys = []; } [Symbol.dispose]() { this.clear(); } combine(set) { const clone = this.clone(); for (const key of set.keys) { clone.add(key); } return clone; } *[Symbol.iterator]() { yield* this.keys; } } //# sourceMappingURL=AddressSet.js.map