Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
toAddress(Address, network) {
assert(util.equal(this.currency, 'handshake.'));
return Address.fromString(this.address, network);
}