UNPKG

@btc-vision/transaction

Version:

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

50 lines (49 loc) 1.17 kB
export class AddressSet { constructor(keys = []) { this.keys = keys; } get size() { return this.keys.length; } add(address) { if (!this.has(address)) { this.keys.push(address); } } has(address) { for (let i = 0; i < this.keys.length; i++) { if (this.keys[i].equals(address)) { return true; } } return false; } remove(address) { const index = this.keys.findIndex((key) => key.equals(address)); if (index !== -1) { this.keys.splice(index, 1); } } clone() { const clone = new AddressSet(); for (let i = 0; i < this.keys.length; i++) { clone.add(this.keys[i]); } return clone; } clear() { this.keys = []; } combine(set) { const clone = this.clone(); for (let i = 0; i < set.keys.length; i++) { clone.add(set.keys[i]); } return clone; } *[Symbol.iterator]() { for (let i = 0; i < this.keys.length; i++) { yield this.keys[i]; } } }