Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function serializeUndo(items) {
const bw = bio.write();
for (const item of items) {
bw.writeI64(item.value);
bw.writeVarBytes(item.script.encode());
}
return bw.render();
}
signature(index, prev, value, key, type) {
if (type == null)
type = hashType.ALL;
const hash = this.signatureHash(index, prev, value, type);
const sig = secp256k1.sign(hash, key);
const bw = bio.write(65);
bw.writeBytes(sig);
bw.writeU8(type);
return bw.render();
}
static address(key) {
const bw = bio.write(27);
bw.writeU8(0x0f);
bw.writeU16BE(0xff01);
bw.writeBytes(hash160.digest(key));
bw.writeChecksum(hash256.digest);
return base58.encode(bw.render());
}
}
getToken(nonce) {
if (!this.master.key)
throw new Error('Cannot derive token.');
const key = this.master.key.derive(44, true);
const bw = bio.write(36);
bw.writeBytes(key.privateKey);
bw.writeU32(nonce);
return hash256.digest(bw.render());
}
getToken(nonce) {
if (!this.master.key)
throw new Error('Cannot derive token.');
const key = this.master.key.derive(44, true);
const bw = bio.write(36);
bw.writeBytes(key.privateKey);
bw.writeU32(nonce);
return blake2b.digest(bw.render());
}
writeKey() {
const bw = bio.write(this.keySize());
bw.writeBytes(this.key.chainCode);
bw.writeBytes(this.key.privateKey);
if (this.mnemonic) {
bw.writeU8(1);
this.mnemonic.write(bw);
} else {
bw.writeU8(0);
}
return bw.render();
}
encode() {
const size = this.getSize();
return this.write(bio.write(size)).render();
}
toRaw(writer) {
const size = this.getSize();
return this.toWriter(bio.write(size)).render();
}
function entryToRaw(entry, main) {
const bw = bio.write(116 + 1);
bw.writeU32(entry.version);
bw.writeHash(entry.prevBlock);
bw.writeHash(entry.merkleRoot);
bw.writeU32(entry.time);
bw.writeU32(entry.bits);
bw.writeU32(entry.nonce);
bw.writeU32(entry.height);
bw.writeBytes(entry.chainwork.toArrayLike(Buffer, 'le', 32));
bw.writeU8(main ? 1 : 0);
return bw.render();
}
toHead() {
const size = this.sizeHead();
return this.writeHead(bio.write(size)).render();
}