How to use the bns.util.equal function in bns

To help you get started, we’ve selected a few bns examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github handshake-org / hsd / lib / dns / records.js View on Github external
getSize() {
    if (util.equal(this.currency, 'handshake.')) {
      const {hash} = bech32.decode(this.address);
      return 1 + 2 + hash.length;
    }

    if (util.equal(this.currency, 'bitcoin.') && bech32.test(this.address)) {
      const {hash} = bech32.decode(this.address);
      return 1 + 2 + hash.length;
    }

    if (util.equal(this.currency, 'ethereum.'))
      return 1 + 20;

    return 1 + sizeName(this.currency) + 1 + this.address.length;
  }
github handshake-org / hsd / lib / dns / records.js View on Github external
getSize() {
    if (util.equal(this.currency, 'handshake.')) {
      const {hash} = bech32.decode(this.address);
      return 1 + 2 + hash.length;
    }

    if (util.equal(this.currency, 'bitcoin.') && bech32.test(this.address)) {
      const {hash} = bech32.decode(this.address);
      return 1 + 2 + hash.length;
    }

    if (util.equal(this.currency, 'ethereum.'))
      return 1 + 20;

    return 1 + sizeName(this.currency) + 1 + this.address.length;
  }
github handshake-org / hsd / lib / dns / records.js View on Github external
getSize() {
    if (util.equal(this.currency, 'handshake.')) {
      const {hash} = bech32.decode(this.address);
      return 1 + 2 + hash.length;
    }

    if (util.equal(this.currency, 'bitcoin.') && bech32.test(this.address)) {
      const {hash} = bech32.decode(this.address);
      return 1 + 2 + hash.length;
    }

    if (util.equal(this.currency, 'ethereum.'))
      return 1 + 20;

    return 1 + sizeName(this.currency) + 1 + this.address.length;
  }
github handshake-org / hsd / lib / dns / records.js View on Github external
assert(hash.length >= 1);
      assert(hash.length <= 128);

      const test = hrp === 'ts' ? 0x80 : 0x00;
      const size = hash.length - 1;
      const field = test | size;

      bw.writeU8(1);
      bw.writeU8(field);
      bw.writeU8(version);
      bw.writeBytes(hash);

      return this;
    }

    if (util.equal(this.currency, 'bitcoin.') && bech32.test(this.address)) {
      const {hrp, version, hash} = bech32.decode(this.address);

      assert(hash.length >= 1);
      assert(hash.length <= 128);

      const test = hrp === 'tb' ? 0x80 : 0x00;
      const size = hash.length - 1;
      const field = test | size;

      bw.writeU8(2);
      bw.writeU8(field);
      bw.writeU8(version);
      bw.writeBytes(hash);

      return this;
    }
github handshake-org / hsd / lib / dns / records.js View on Github external
write(bw, c) {
    if (util.equal(this.currency, 'handshake.')) {
      const {hrp, version, hash} = bech32.decode(this.address);

      assert(hash.length >= 1);
      assert(hash.length <= 128);

      const test = hrp === 'ts' ? 0x80 : 0x00;
      const size = hash.length - 1;
      const field = test | size;

      bw.writeU8(1);
      bw.writeU8(field);
      bw.writeU8(version);
      bw.writeBytes(hash);

      return this;
    }
github handshake-org / hsd / lib / dns / records.js View on Github external
assert(hash.length >= 1);
      assert(hash.length <= 128);

      const test = hrp === 'tb' ? 0x80 : 0x00;
      const size = hash.length - 1;
      const field = test | size;

      bw.writeU8(2);
      bw.writeU8(field);
      bw.writeU8(version);
      bw.writeBytes(hash);

      return this;
    }

    if (util.equal(this.currency, 'ethereum.')) {
      bw.writeU8(3);
      bw.writeString(this.address.substring(2), 'hex');
      return this;
    }

    bw.writeU8(0);
    writeNameBW(bw, this.currency, c.labels);
    bw.writeU8(this.address.length);
    bw.writeString(this.address, 'ascii');

    return this;
  }
github handshake-org / hsd / lib / dns / records.js View on Github external
toAddress(Address, network) {
    assert(util.equal(this.currency, 'handshake.'));
    return Address.fromString(this.address, network);
  }