refactor: switch to bio module.
This commit is contained in:
parent
bf4f5e3bac
commit
21ab415769
@ -10,7 +10,7 @@ const assert = require('assert');
|
||||
const EventEmitter = require('events');
|
||||
const bsock = require('bsock');
|
||||
const hash256 = require('bcrypto/lib/hash256');
|
||||
const BufferWriter = require('bufio/lib/writer');
|
||||
const bio = require('bufio');
|
||||
|
||||
function ProxySocket(uri) {
|
||||
if (!(this instanceof ProxySocket))
|
||||
@ -116,7 +116,7 @@ ProxySocket.prototype.connect = function connect(port, host) {
|
||||
let nonce = 0;
|
||||
|
||||
if (this.info.pow) {
|
||||
const bw = new BufferWriter();
|
||||
const bw = bio.write();
|
||||
|
||||
bw.writeU32(nonce);
|
||||
bw.writeBytes(this.snonce);
|
||||
@ -130,7 +130,7 @@ ProxySocket.prototype.connect = function connect(port, host) {
|
||||
port, host);
|
||||
|
||||
do {
|
||||
nonce++;
|
||||
nonce += 1;
|
||||
assert(nonce <= 0xffffffff, 'Could not create socket.');
|
||||
pow.writeUInt32LE(nonce, 0, true);
|
||||
} while (hash256.digest(pow).compare(this.target) > 0);
|
||||
|
||||
@ -6,7 +6,7 @@ const EventEmitter = require('events');
|
||||
const bsock = require('bsock');
|
||||
const hash256 = require('bcrypto/lib/hash256');
|
||||
const IP = require('binet');
|
||||
const BufferWriter = require('bufio/lib/writer');
|
||||
const bio = require('bufio');
|
||||
|
||||
const TARGET = Buffer.from(
|
||||
'0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
|
||||
@ -92,7 +92,7 @@ WSProxy.prototype.handleConnect = function handleConnect(ws, port, host, nonce)
|
||||
return;
|
||||
}
|
||||
|
||||
const bw = new BufferWriter();
|
||||
const bw = bio.write();
|
||||
bw.writeU32(nonce);
|
||||
bw.writeBytes(state.snonce);
|
||||
bw.writeU32(port);
|
||||
|
||||
@ -12,7 +12,7 @@ const path = require('path');
|
||||
const AsyncEmitter = require('bevent');
|
||||
const Logger = require('blgr');
|
||||
const {Lock} = require('bmutex');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const {encoding} = require('bufio');
|
||||
const Network = require('../protocol/network');
|
||||
const ChainDB = require('./chaindb');
|
||||
const common = require('./common');
|
||||
|
||||
@ -9,10 +9,8 @@
|
||||
|
||||
const assert = require('assert');
|
||||
const BDB = require('bdb');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const bio = require('bufio');
|
||||
const Amount = require('../btc/amount');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const Network = require('../protocol/network');
|
||||
const CoinView = require('../coins/coinview');
|
||||
const UndoCoins = require('../coins/undocoins');
|
||||
@ -24,6 +22,7 @@ const Address = require('../primitives/address');
|
||||
const ChainEntry = require('./chainentry');
|
||||
const TXMeta = require('../primitives/txmeta');
|
||||
const CoinEntry = require('../coins/coinentry');
|
||||
const {encoding} = bio;
|
||||
const u8 = encoding.u8;
|
||||
const u32 = encoding.u32;
|
||||
|
||||
@ -648,7 +647,7 @@ class ChainDB {
|
||||
*/
|
||||
|
||||
writeDeployments(batch) {
|
||||
const bw = new StaticWriter(1 + 17 * this.network.deploys.length);
|
||||
const bw = bio.write(1 + 17 * this.network.deploys.length);
|
||||
|
||||
bw.writeU8(this.network.deploys.length);
|
||||
|
||||
@ -674,7 +673,7 @@ class ChainDB {
|
||||
|
||||
assert(raw, 'No deployment table found.');
|
||||
|
||||
const br = new BufferReader(raw);
|
||||
const br = bio.read(raw);
|
||||
const count = br.readU8();
|
||||
const invalid = [];
|
||||
|
||||
@ -2062,7 +2061,7 @@ class ChainFlags {
|
||||
}
|
||||
|
||||
toRaw() {
|
||||
const bw = new StaticWriter(12);
|
||||
const bw = bio.write(12);
|
||||
let flags = 0;
|
||||
|
||||
if (this.spv)
|
||||
@ -2094,7 +2093,7 @@ class ChainFlags {
|
||||
}
|
||||
|
||||
fromRaw(data) {
|
||||
const br = new BufferReader(data);
|
||||
const br = bio.read(data);
|
||||
|
||||
this.network = Network.fromMagic(br.readU32());
|
||||
|
||||
@ -2175,7 +2174,7 @@ class ChainState {
|
||||
}
|
||||
|
||||
toRaw() {
|
||||
const bw = new StaticWriter(56);
|
||||
const bw = bio.write(56);
|
||||
bw.writeHash(this.tip);
|
||||
bw.writeU64(this.tx);
|
||||
bw.writeU64(this.coin);
|
||||
@ -2185,7 +2184,7 @@ class ChainState {
|
||||
|
||||
static fromRaw(data) {
|
||||
const state = new ChainState();
|
||||
const br = new BufferReader(data);
|
||||
const br = bio.read(data);
|
||||
state.tip = br.readHash('hex');
|
||||
state.tx = br.readU64();
|
||||
state.coin = br.readU64();
|
||||
|
||||
@ -8,14 +8,18 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const bio = require('bufio');
|
||||
const BN = require('bcrypto/lib/bn');
|
||||
const consensus = require('../protocol/consensus');
|
||||
const hash256 = require('bcrypto/lib/hash256');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const Headers = require('../primitives/headers');
|
||||
const InvItem = require('../primitives/invitem');
|
||||
const {encoding} = bio;
|
||||
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
|
||||
const ZERO = new BN(0);
|
||||
|
||||
/**
|
||||
@ -213,7 +217,7 @@ class ChainEntry {
|
||||
*/
|
||||
|
||||
toRaw() {
|
||||
const bw = new StaticWriter(116);
|
||||
const bw = bio.write(116);
|
||||
|
||||
bw.writeU32(this.version);
|
||||
bw.writeHash(this.prevBlock);
|
||||
@ -234,7 +238,7 @@ class ChainEntry {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
const br = new BufferReader(data, true);
|
||||
const br = bio.read(data, true);
|
||||
const hash = hash256.digest(br.readBytes(80));
|
||||
|
||||
br.seek(-80);
|
||||
|
||||
@ -7,12 +7,11 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const bio = require('bufio');
|
||||
const Coin = require('../primitives/coin');
|
||||
const Output = require('../primitives/output');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const compress = require('./compress');
|
||||
const {encoding} = bio;
|
||||
|
||||
/*
|
||||
* Constants
|
||||
@ -208,7 +207,7 @@ class CoinEntry {
|
||||
return this.raw;
|
||||
|
||||
const size = this.getSize();
|
||||
const bw = new StaticWriter(size);
|
||||
const bw = bio.write(size);
|
||||
|
||||
this.toWriter(bw);
|
||||
|
||||
@ -258,7 +257,7 @@ class CoinEntry {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
this.fromReader(new BufferReader(data));
|
||||
this.fromReader(bio.read(data));
|
||||
this.raw = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -12,8 +12,8 @@
|
||||
*/
|
||||
|
||||
const assert = require('assert');
|
||||
const {encoding} = require('bufio');
|
||||
const secp256k1 = require('bcrypto/lib/secp256k1');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const consensus = require('../protocol/consensus');
|
||||
|
||||
/*
|
||||
|
||||
@ -7,8 +7,7 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const bio = require('bufio');
|
||||
const CoinEntry = require('../coins/coinentry');
|
||||
|
||||
/**
|
||||
@ -64,7 +63,7 @@ class UndoCoins {
|
||||
|
||||
toRaw() {
|
||||
const size = this.getSize();
|
||||
const bw = new StaticWriter(size);
|
||||
const bw = bio.write(size);
|
||||
|
||||
bw.writeU32(this.items.length);
|
||||
|
||||
@ -82,7 +81,7 @@ class UndoCoins {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
const br = new BufferReader(data);
|
||||
const br = bio.read(data);
|
||||
const count = br.readU32();
|
||||
|
||||
for (let i = 0; i < count; i++)
|
||||
|
||||
@ -7,17 +7,16 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const bio = require('bufio');
|
||||
const sha256 = require('bcrypto/lib/sha256');
|
||||
const cleanse = require('bcrypto/lib/cleanse');
|
||||
const random = require('bcrypto/lib/random');
|
||||
const pbkdf2 = require('bcrypto/lib/pbkdf2');
|
||||
const sha512 = require('bcrypto/lib/sha512');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const wordlist = require('./wordlist');
|
||||
const common = require('./common');
|
||||
const nfkd = require('./nfkd');
|
||||
const {encoding} = bio;
|
||||
|
||||
/*
|
||||
* Constants
|
||||
@ -458,7 +457,7 @@ class Mnemonic {
|
||||
|
||||
toRaw(writer) {
|
||||
const size = this.getSize();
|
||||
return this.toWriter(new StaticWriter(size)).render();
|
||||
return this.toWriter(bio.write(size)).render();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -493,7 +492,7 @@ class Mnemonic {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
return this.fromReader(new BufferReader(data));
|
||||
return this.fromReader(bio.read(data));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const bio = require('bufio');
|
||||
const {base58} = require('bstring');
|
||||
const sha512 = require('bcrypto/lib/sha512');
|
||||
const hash160 = require('bcrypto/lib/hash160');
|
||||
@ -14,13 +15,11 @@ const hash256 = require('bcrypto/lib/hash256');
|
||||
const cleanse = require('bcrypto/lib/cleanse');
|
||||
const random = require('bcrypto/lib/random');
|
||||
const secp256k1 = require('bcrypto/lib/secp256k1');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const Network = require('../protocol/network');
|
||||
const common = require('./common');
|
||||
const Mnemonic = require('./mnemonic');
|
||||
const HDPublicKey = require('./public');
|
||||
const {encoding} = bio;
|
||||
|
||||
/*
|
||||
* Constants
|
||||
@ -189,7 +188,7 @@ class HDPrivateKey {
|
||||
if (cache)
|
||||
return cache;
|
||||
|
||||
const bw = StaticWriter.pool(37);
|
||||
const bw = bio.pool(37);
|
||||
|
||||
if (index & common.HARDENED) {
|
||||
bw.writeU8(0);
|
||||
@ -586,7 +585,7 @@ class HDPrivateKey {
|
||||
*/
|
||||
|
||||
fromRaw(data, network) {
|
||||
return this.fromReader(new BufferReader(data), network);
|
||||
return this.fromReader(bio.read(data), network);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -636,7 +635,7 @@ class HDPrivateKey {
|
||||
*/
|
||||
|
||||
toRaw(network) {
|
||||
return this.toWriter(new StaticWriter(82), network).render();
|
||||
return this.toWriter(bio.write(82), network).render();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const bio = require('bufio');
|
||||
const {base58} = require('bstring');
|
||||
const sha512 = require('bcrypto/lib/sha512');
|
||||
const hash160 = require('bcrypto/lib/hash160');
|
||||
@ -14,10 +15,8 @@ const hash256 = require('bcrypto/lib/hash256');
|
||||
const cleanse = require('bcrypto/lib/cleanse');
|
||||
const secp256k1 = require('bcrypto/lib/secp256k1');
|
||||
const Network = require('../protocol/network');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const common = require('./common');
|
||||
const {encoding} = bio;
|
||||
|
||||
/**
|
||||
* HDPublicKey
|
||||
@ -157,7 +156,7 @@ class HDPublicKey {
|
||||
if (cache)
|
||||
return cache;
|
||||
|
||||
const bw = StaticWriter.pool(37);
|
||||
const bw = bio.pool(37);
|
||||
|
||||
bw.writeBytes(this.publicKey);
|
||||
bw.writeU32BE(index);
|
||||
@ -456,7 +455,7 @@ class HDPublicKey {
|
||||
*/
|
||||
|
||||
fromRaw(data, network) {
|
||||
return this.fromReader(new BufferReader(data), network);
|
||||
return this.fromReader(bio.read(data), network);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -505,7 +504,7 @@ class HDPublicKey {
|
||||
*/
|
||||
|
||||
toRaw(network) {
|
||||
return this.toWriter(new StaticWriter(82), network).render();
|
||||
return this.toWriter(bio.write(82), network).render();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -9,13 +9,12 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const bio = require('bufio');
|
||||
const Logger = require('blgr');
|
||||
const binary = require('../utils/binary');
|
||||
const consensus = require('../protocol/consensus');
|
||||
const policy = require('../protocol/policy');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const Logger = require('blgr');
|
||||
const {encoding} = bio;
|
||||
|
||||
/*
|
||||
* Constants
|
||||
@ -316,7 +315,7 @@ ConfirmStats.prototype.getSize = function getSize() {
|
||||
|
||||
ConfirmStats.prototype.toRaw = function toRaw() {
|
||||
const size = this.getSize();
|
||||
const bw = new StaticWriter(size);
|
||||
const bw = bio.write(size);
|
||||
|
||||
bw.writeDouble(this.decay);
|
||||
writeArray(bw, this.buckets);
|
||||
@ -338,7 +337,7 @@ ConfirmStats.prototype.toRaw = function toRaw() {
|
||||
*/
|
||||
|
||||
ConfirmStats.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data);
|
||||
const br = bio.read(data);
|
||||
const decay = br.readDouble();
|
||||
const buckets = readArray(br);
|
||||
const avg = readArray(br);
|
||||
@ -780,7 +779,7 @@ PolicyEstimator.prototype.getSize = function getSize() {
|
||||
|
||||
PolicyEstimator.prototype.toRaw = function toRaw() {
|
||||
const size = this.getSize();
|
||||
const bw = new StaticWriter(size);
|
||||
const bw = bio.write(size);
|
||||
|
||||
bw.writeU8(PolicyEstimator.VERSION);
|
||||
bw.writeU32(this.bestHeight);
|
||||
@ -797,7 +796,7 @@ PolicyEstimator.prototype.toRaw = function toRaw() {
|
||||
*/
|
||||
|
||||
PolicyEstimator.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data);
|
||||
const br = bio.read(data);
|
||||
|
||||
if (br.readU8() !== PolicyEstimator.VERSION)
|
||||
throw new Error('Bad serialization version for estimator.');
|
||||
|
||||
@ -10,6 +10,7 @@ const assert = require('assert');
|
||||
const path = require('path');
|
||||
const EventEmitter = require('events');
|
||||
const BDB = require('bdb');
|
||||
const {encoding} = require('bufio');
|
||||
const common = require('../blockchain/common');
|
||||
const consensus = require('../protocol/consensus');
|
||||
const policy = require('../protocol/policy');
|
||||
@ -25,7 +26,6 @@ const Coin = require('../primitives/coin');
|
||||
const TXMeta = require('../primitives/txmeta');
|
||||
const MempoolEntry = require('./mempoolentry');
|
||||
const Network = require('../protocol/network');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const layout = require('./layout');
|
||||
const Fees = require('./fees');
|
||||
const CoinView = require('../coins/coinview');
|
||||
|
||||
@ -6,11 +6,10 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const bio = require('bufio');
|
||||
const policy = require('../protocol/policy');
|
||||
const util = require('../utils/util');
|
||||
const Script = require('../script/script');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const TX = require('../primitives/tx');
|
||||
|
||||
/**
|
||||
@ -319,7 +318,7 @@ class MempoolEntry {
|
||||
*/
|
||||
|
||||
toRaw() {
|
||||
const bw = new StaticWriter(this.getSize());
|
||||
const bw = bio.write(this.getSize());
|
||||
bw.writeBytes(this.tx.toRaw());
|
||||
bw.writeU32(this.height);
|
||||
bw.writeU32(this.size);
|
||||
@ -341,7 +340,7 @@ class MempoolEntry {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
const br = new BufferReader(data);
|
||||
const br = bio.read(data);
|
||||
this.tx = TX.fromReader(br);
|
||||
this.height = br.readU32();
|
||||
this.size = br.readU32();
|
||||
|
||||
@ -9,8 +9,8 @@
|
||||
|
||||
const assert = require('assert');
|
||||
const EventEmitter = require('events');
|
||||
const {encoding} = require('bufio');
|
||||
const {Lock} = require('bmutex');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const util = require('../utils/util');
|
||||
const mine = require('./mine');
|
||||
|
||||
|
||||
@ -8,9 +8,9 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const bio = require('bufio');
|
||||
const hash256 = require('bcrypto/lib/hash256');
|
||||
const merkle = require('bcrypto/lib/merkle');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const Address = require('../primitives/address');
|
||||
const TX = require('../primitives/tx');
|
||||
const Block = require('../primitives/block');
|
||||
@ -18,10 +18,10 @@ const Input = require('../primitives/input');
|
||||
const Output = require('../primitives/output');
|
||||
const consensus = require('../protocol/consensus');
|
||||
const policy = require('../protocol/policy');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const CoinView = require('../coins/coinview');
|
||||
const Script = require('../script/script');
|
||||
const common = require('./common');
|
||||
const {encoding} = bio;
|
||||
const DUMMY = Buffer.alloc(0);
|
||||
|
||||
/**
|
||||
@ -366,7 +366,7 @@ class BlockTemplate {
|
||||
size += 4 + 4;
|
||||
size += this.right.length;
|
||||
|
||||
const bw = new StaticWriter(size);
|
||||
const bw = bio.write(size);
|
||||
bw.writeBytes(this.left);
|
||||
bw.writeU32BE(nonce1);
|
||||
bw.writeU32BE(nonce2);
|
||||
@ -397,7 +397,7 @@ class BlockTemplate {
|
||||
*/
|
||||
|
||||
getHeader(root, time, nonce) {
|
||||
const bw = new StaticWriter(80);
|
||||
const bw = bio.write(80);
|
||||
|
||||
bw.writeU32(this.version);
|
||||
bw.writeHash(this.prevBlock);
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
const EventEmitter = require('events');
|
||||
const bio = require('bufio');
|
||||
const fs = require('bfile');
|
||||
const dns = require('bdns');
|
||||
const IP = require('binet');
|
||||
@ -21,9 +22,8 @@ const hash160 = require('bcrypto/lib/hash160');
|
||||
const hash256 = require('bcrypto/lib/hash256');
|
||||
const random = require('bcrypto/lib/random');
|
||||
const secp256k1 = require('bcrypto/lib/secp256k1');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const packets = require('./packets');
|
||||
const {encoding} = bio;
|
||||
|
||||
/**
|
||||
* Represents a BIP150 input/output stream.
|
||||
@ -442,7 +442,7 @@ BIP150.prototype.getAddress = function getAddress() {
|
||||
*/
|
||||
|
||||
BIP150.address = function address(key) {
|
||||
const bw = new StaticWriter(27);
|
||||
const bw = bio.write(27);
|
||||
bw.writeU8(0x0f);
|
||||
bw.writeU16BE(0xff01);
|
||||
bw.writeBytes(hash160.digest(key));
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
const assert = require('assert');
|
||||
const EventEmitter = require('events');
|
||||
const {format} = require('util');
|
||||
const bio = require('bufio');
|
||||
const util = require('../utils/util');
|
||||
const hash256 = require('bcrypto/lib/hash256');
|
||||
const sha256 = require('bcrypto/lib/sha256');
|
||||
@ -24,11 +25,8 @@ const AEAD = require('bcrypto/lib/aead');
|
||||
const hkdf = require('bcrypto/lib/hkdf');
|
||||
const secp256k1 = require('bcrypto/lib/secp256k1');
|
||||
const packets = require('./packets');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const EncinitPacket = packets.EncinitPacket;
|
||||
const EncackPacket = packets.EncackPacket;
|
||||
const {encoding} = bio;
|
||||
const {EncinitPacket, EncackPacket} = packets;
|
||||
|
||||
/*
|
||||
* Constants
|
||||
@ -99,7 +97,7 @@ BIP151Stream.prototype.init = function init(publicKey) {
|
||||
|
||||
const secret = secp256k1.ecdh(this.publicKey, this.privateKey);
|
||||
|
||||
const bw = StaticWriter.pool(33);
|
||||
const bw = bio.pool(33);
|
||||
|
||||
bw.writeBytes(secret);
|
||||
bw.writeU8(this.cipher);
|
||||
@ -593,7 +591,7 @@ BIP151.prototype.packetSize = function packetSize(cmd, body) {
|
||||
|
||||
BIP151.prototype.packet = function packet(cmd, body) {
|
||||
const size = this.packetSize(cmd, body);
|
||||
const bw = new StaticWriter(size);
|
||||
const bw = bio.write(size);
|
||||
const payloadSize = size - 20;
|
||||
|
||||
bw.writeU32(payloadSize);
|
||||
@ -731,7 +729,7 @@ BIP151.prototype.parse = function parse(data) {
|
||||
this.input.decrypt(payload);
|
||||
this.input.sequence();
|
||||
|
||||
const br = new BufferReader(payload);
|
||||
const br = bio.read(payload);
|
||||
|
||||
while (br.left()) {
|
||||
let cmd, body;
|
||||
|
||||
@ -11,9 +11,7 @@
|
||||
*/
|
||||
|
||||
const assert = require('assert');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const bio = require('bufio');
|
||||
const consensus = require('../protocol/consensus');
|
||||
const sha256 = require('bcrypto/lib/sha256');
|
||||
const siphash256 = require('bcrypto/lib/siphash').siphash256;
|
||||
@ -22,6 +20,7 @@ const TX = require('../primitives/tx');
|
||||
const Headers = require('../primitives/headers');
|
||||
const Block = require('../primitives/block');
|
||||
const common = require('./common');
|
||||
const {encoding} = bio;
|
||||
|
||||
/**
|
||||
* Compact Block
|
||||
@ -122,7 +121,7 @@ class CompactBlock extends AbstractBlock {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
const br = new BufferReader(data);
|
||||
const br = bio.read(data);
|
||||
|
||||
this.readHead(br);
|
||||
|
||||
@ -217,7 +216,7 @@ class CompactBlock extends AbstractBlock {
|
||||
|
||||
frameRaw(witness) {
|
||||
const size = this.getSize(witness);
|
||||
return this.writeRaw(new StaticWriter(size), witness).render();
|
||||
return this.writeRaw(bio.write(size), witness).render();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -655,7 +654,7 @@ class TXRequest {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
return this.fromReader(new BufferReader(data));
|
||||
return this.fromReader(bio.read(data));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -730,7 +729,7 @@ class TXRequest {
|
||||
|
||||
toRaw() {
|
||||
const size = this.getSize();
|
||||
return this.toWriter(new StaticWriter(size)).render();
|
||||
return this.toWriter(bio.write(size)).render();
|
||||
}
|
||||
}
|
||||
|
||||
@ -809,7 +808,7 @@ class TXResponse {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
return this.fromReader(new BufferReader(data));
|
||||
return this.fromReader(bio.read(data));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -952,7 +951,7 @@ class TXResponse {
|
||||
|
||||
frameRaw(witness) {
|
||||
const size = this.getSize(witness);
|
||||
return this.writeRaw(new StaticWriter(size), witness).render();
|
||||
return this.writeRaw(bio.write(size), witness).render();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
*/
|
||||
|
||||
const assert = require('assert');
|
||||
const bio = require('bufio');
|
||||
const common = require('./common');
|
||||
const util = require('../utils/util');
|
||||
const BloomFilter = require('bfilter/lib/bloom');
|
||||
@ -22,9 +23,7 @@ const InvItem = require('../primitives/invitem');
|
||||
const MemBlock = require('../primitives/memblock');
|
||||
const MerkleBlock = require('../primitives/merkleblock');
|
||||
const TX = require('../primitives/tx');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const {encoding} = bio;
|
||||
const DUMMY = Buffer.alloc(0);
|
||||
|
||||
/**
|
||||
@ -317,7 +316,7 @@ class VersionPacket extends Packet {
|
||||
|
||||
toRaw() {
|
||||
const size = this.getSize();
|
||||
return this.toWriter(new StaticWriter(size)).render();
|
||||
return this.toWriter(bio.write(size)).render();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -381,7 +380,7 @@ class VersionPacket extends Packet {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
return this.fromReader(new BufferReader(data));
|
||||
return this.fromReader(bio.read(data));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -477,7 +476,7 @@ class PingPacket extends Packet {
|
||||
|
||||
toRaw() {
|
||||
const size = this.getSize();
|
||||
return this.toWriter(new StaticWriter(size)).render();
|
||||
return this.toWriter(bio.write(size)).render();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -510,7 +509,7 @@ class PingPacket extends Packet {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
return this.fromReader(new BufferReader(data));
|
||||
return this.fromReader(bio.read(data));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -584,7 +583,7 @@ class PongPacket extends Packet {
|
||||
*/
|
||||
|
||||
toRaw() {
|
||||
return this.toWriter(new StaticWriter(8)).render();
|
||||
return this.toWriter(bio.write(8)).render();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -605,7 +604,7 @@ class PongPacket extends Packet {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
return this.fromReader(new BufferReader(data));
|
||||
return this.fromReader(bio.read(data));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -728,7 +727,7 @@ class AddrPacket extends Packet {
|
||||
|
||||
toRaw() {
|
||||
const size = this.getSize();
|
||||
return this.toWriter(new StaticWriter(size)).render();
|
||||
return this.toWriter(bio.write(size)).render();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -738,7 +737,7 @@ class AddrPacket extends Packet {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
const br = new BufferReader(data);
|
||||
const br = bio.read(data);
|
||||
const count = br.readVarint();
|
||||
|
||||
for (let i = 0; i < count; i++)
|
||||
@ -828,7 +827,7 @@ class InvPacket extends Packet {
|
||||
|
||||
toRaw() {
|
||||
const size = this.getSize();
|
||||
return this.toWriter(new StaticWriter(size)).render();
|
||||
return this.toWriter(bio.write(size)).render();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -855,7 +854,7 @@ class InvPacket extends Packet {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
return this.fromReader(new BufferReader(data));
|
||||
return this.fromReader(bio.read(data));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1032,7 +1031,7 @@ class GetBlocksPacket extends Packet {
|
||||
|
||||
toRaw() {
|
||||
const size = this.getSize();
|
||||
return this.toWriter(new StaticWriter(size)).render();
|
||||
return this.toWriter(bio.write(size)).render();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1066,7 +1065,7 @@ class GetBlocksPacket extends Packet {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
return this.fromReader(new BufferReader(data));
|
||||
return this.fromReader(bio.read(data));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1187,7 +1186,7 @@ class HeadersPacket extends Packet {
|
||||
|
||||
toRaw() {
|
||||
const size = this.getSize();
|
||||
return this.toWriter(new StaticWriter(size)).render();
|
||||
return this.toWriter(bio.write(size)).render();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1214,7 +1213,7 @@ class HeadersPacket extends Packet {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
return this.fromReader(new BufferReader(data));
|
||||
return this.fromReader(bio.read(data));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1619,7 +1618,7 @@ class RejectPacket extends Packet {
|
||||
|
||||
toRaw() {
|
||||
const size = this.getSize();
|
||||
return this.toWriter(new StaticWriter(size)).render();
|
||||
return this.toWriter(bio.write(size)).render();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1653,7 +1652,7 @@ class RejectPacket extends Packet {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
return this.fromReader(new BufferReader(data));
|
||||
return this.fromReader(bio.read(data));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1988,7 +1987,7 @@ class FilterAddPacket extends Packet {
|
||||
|
||||
toRaw() {
|
||||
const size = this.getSize();
|
||||
return this.toWriter(new StaticWriter(size)).render();
|
||||
return this.toWriter(bio.write(size)).render();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2009,7 +2008,7 @@ class FilterAddPacket extends Packet {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
return this.fromReader(new BufferReader(data));
|
||||
return this.fromReader(bio.read(data));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2189,7 +2188,7 @@ class FeeFilterPacket extends Packet {
|
||||
*/
|
||||
|
||||
toRaw() {
|
||||
return this.toWriter(new StaticWriter(8)).render();
|
||||
return this.toWriter(bio.write(8)).render();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2210,7 +2209,7 @@ class FeeFilterPacket extends Packet {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
return this.fromReader(new BufferReader(data));
|
||||
return this.fromReader(bio.read(data));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2288,7 +2287,7 @@ class SendCmpctPacket extends Packet {
|
||||
*/
|
||||
|
||||
toRaw() {
|
||||
return this.toWriter(new StaticWriter(9)).render();
|
||||
return this.toWriter(bio.write(9)).render();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2310,7 +2309,7 @@ class SendCmpctPacket extends Packet {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
return this.fromReader(new BufferReader(data));
|
||||
return this.fromReader(bio.read(data));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2701,7 +2700,7 @@ class EncinitPacket extends Packet {
|
||||
*/
|
||||
|
||||
toRaw() {
|
||||
return this.toWriter(new StaticWriter(34)).render();
|
||||
return this.toWriter(bio.write(34)).render();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2723,7 +2722,7 @@ class EncinitPacket extends Packet {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
return this.fromReader(new BufferReader(data));
|
||||
return this.fromReader(bio.read(data));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2818,7 +2817,7 @@ class EncackPacket extends Packet {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
return this.fromReader(new BufferReader(data));
|
||||
return this.fromReader(bio.read(data));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2913,7 +2912,7 @@ class AuthChallengePacket extends Packet {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
return this.fromReader(new BufferReader(data));
|
||||
return this.fromReader(bio.read(data));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3008,7 +3007,7 @@ class AuthReplyPacket extends Packet {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
return this.fromReader(new BufferReader(data));
|
||||
return this.fromReader(bio.read(data));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3103,7 +3102,7 @@ class AuthProposePacket extends Packet {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
return this.fromReader(new BufferReader(data));
|
||||
return this.fromReader(bio.read(data));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -13,7 +13,7 @@ const {Lock} = require('bmutex');
|
||||
const {format} = require('util');
|
||||
const tcp = require('btcp');
|
||||
const Logger = require('blgr');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const {encoding} = require('bufio');
|
||||
const RollingFilter = require('bfilter/lib/rolling');
|
||||
const Parser = require('./parser');
|
||||
const Framer = require('./framer');
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
|
||||
const assert = require('assert');
|
||||
const EventEmitter = require('events');
|
||||
const {encoding} = require('bufio');
|
||||
const {Lock} = require('bmutex');
|
||||
const IP = require('binet');
|
||||
const dns = require('bdns');
|
||||
@ -18,7 +19,6 @@ const socks = require('bsocks');
|
||||
const BloomFilter = require('bfilter/lib/bloom');
|
||||
const RollingFilter = require('bfilter/lib/rolling');
|
||||
const secp256k1 = require('bcrypto/lib/secp256k1');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const util = require('../utils/util');
|
||||
const common = require('./common');
|
||||
const chainCommon = require('../blockchain/common');
|
||||
|
||||
@ -12,10 +12,10 @@ const path = require('path');
|
||||
const {Server} = require('bweb');
|
||||
const Validator = require('bval');
|
||||
const {base58} = require('bstring');
|
||||
const {encoding} = require('bufio');
|
||||
const sha256 = require('bcrypto/lib/sha256');
|
||||
const random = require('bcrypto/lib/random');
|
||||
const ccmp = require('bcrypto/lib/ccmp');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const BloomFilter = require('bfilter/lib/bloom');
|
||||
const util = require('../utils/util');
|
||||
const TX = require('../primitives/tx');
|
||||
|
||||
@ -11,11 +11,11 @@ const bweb = require('bweb');
|
||||
const {Lock} = require('bmutex');
|
||||
const IP = require('binet');
|
||||
const Validator = require('bval');
|
||||
const {encoding} = require('bufio');
|
||||
const hash160 = require('bcrypto/lib/hash160');
|
||||
const hash256 = require('bcrypto/lib/hash256');
|
||||
const ccmp = require('bcrypto/lib/ccmp');
|
||||
const secp256k1 = require('bcrypto/lib/secp256k1');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const util = require('../utils/util');
|
||||
const common = require('../blockchain/common');
|
||||
const Amount = require('../btc/amount');
|
||||
|
||||
@ -9,11 +9,10 @@
|
||||
|
||||
const assert = require('assert');
|
||||
const hash256 = require('bcrypto/lib/hash256');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const bio = require('bufio');
|
||||
const InvItem = require('./invitem');
|
||||
const consensus = require('../protocol/consensus');
|
||||
const {encoding} = bio;
|
||||
|
||||
/**
|
||||
* Abstract Block
|
||||
@ -163,7 +162,7 @@ class AbstractBlock {
|
||||
*/
|
||||
|
||||
toHead() {
|
||||
return this.writeHead(new StaticWriter(80)).render();
|
||||
return this.writeHead(bio.write(80)).render();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -173,7 +172,7 @@ class AbstractBlock {
|
||||
*/
|
||||
|
||||
fromHead(data) {
|
||||
return this.readHead(new BufferReader(data));
|
||||
return this.readHead(bio.read(data));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -8,14 +8,13 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const bio = require('bufio');
|
||||
const {base58, bech32} = require('bstring');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const sha256 = require('bcrypto/lib/sha256');
|
||||
const hash160 = require('bcrypto/lib/hash160');
|
||||
const hash256 = require('bcrypto/lib/hash256');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const Network = require('../protocol/network');
|
||||
const {encoding} = bio;
|
||||
|
||||
/**
|
||||
* Address
|
||||
@ -176,7 +175,7 @@ class Address {
|
||||
|
||||
toRaw(network) {
|
||||
const size = this.getSize();
|
||||
const bw = new StaticWriter(size);
|
||||
const bw = bio.write(size);
|
||||
const prefix = this.getPrefix(network);
|
||||
|
||||
assert(prefix !== -1, 'Not a valid address prefix.');
|
||||
@ -296,7 +295,7 @@ class Address {
|
||||
*/
|
||||
|
||||
fromRaw(data, network) {
|
||||
const br = new BufferReader(data, true);
|
||||
const br = bio.read(data, true);
|
||||
const prefix = br.readU8();
|
||||
|
||||
network = Network.fromAddress(prefix, network);
|
||||
|
||||
@ -8,18 +8,17 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const bio = require('bufio');
|
||||
const util = require('../utils/util');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const hash256 = require('bcrypto/lib/hash256');
|
||||
const merkle = require('bcrypto/lib/merkle');
|
||||
const consensus = require('../protocol/consensus');
|
||||
const AbstractBlock = require('./abstractblock');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const TX = require('./tx');
|
||||
const MerkleBlock = require('./merkleblock');
|
||||
const Headers = require('./headers');
|
||||
const Network = require('../protocol/network');
|
||||
const {encoding} = bio;
|
||||
|
||||
/**
|
||||
* Block
|
||||
@ -659,7 +658,7 @@ class Block extends AbstractBlock {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
return this.fromReader(new BufferReader(data));
|
||||
return this.fromReader(bio.read(data));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -746,7 +745,7 @@ class Block extends AbstractBlock {
|
||||
|
||||
frameNormal() {
|
||||
const raw = this.getNormalSizes();
|
||||
const bw = new StaticWriter(raw.size);
|
||||
const bw = bio.write(raw.size);
|
||||
this.writeNormal(bw);
|
||||
raw.data = bw.render();
|
||||
return raw;
|
||||
@ -761,7 +760,7 @@ class Block extends AbstractBlock {
|
||||
|
||||
frameWitness() {
|
||||
const raw = this.getWitnessSizes();
|
||||
const bw = new StaticWriter(raw.size);
|
||||
const bw = bio.write(raw.size);
|
||||
this.writeWitness(bw);
|
||||
raw.data = bw.render();
|
||||
return raw;
|
||||
|
||||
@ -8,13 +8,12 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const bio = require('bufio');
|
||||
const Amount = require('../btc/amount');
|
||||
const Output = require('./output');
|
||||
const Script = require('../script/script');
|
||||
const Network = require('../protocol/network');
|
||||
const {encoding} = bio;
|
||||
|
||||
/**
|
||||
* Coin
|
||||
@ -335,7 +334,7 @@ class Coin extends Output {
|
||||
|
||||
toRaw() {
|
||||
const size = this.getSize();
|
||||
return this.toWriter(new StaticWriter(size)).render();
|
||||
return this.toWriter(bio.write(size)).render();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -364,7 +363,7 @@ class Coin extends Output {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
return this.fromReader(new BufferReader(data));
|
||||
return this.fromReader(bio.read(data));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -7,11 +7,10 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const bio = require('bufio');
|
||||
const util = require('../utils/util');
|
||||
const AbstractBlock = require('./abstractblock');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const {encoding} = bio;
|
||||
|
||||
/**
|
||||
* Headers
|
||||
@ -72,7 +71,7 @@ class Headers extends AbstractBlock {
|
||||
|
||||
toRaw() {
|
||||
const size = this.getSize();
|
||||
return this.toWriter(new StaticWriter(size)).render();
|
||||
return this.toWriter(bio.write(size)).render();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,7 +93,7 @@ class Headers extends AbstractBlock {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
return this.fromReader(new BufferReader(data));
|
||||
return this.fromReader(bio.read(data));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -8,12 +8,12 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const bio = require('bufio');
|
||||
const Network = require('../protocol/network');
|
||||
const Script = require('../script/script');
|
||||
const Witness = require('../script/witness');
|
||||
const Outpoint = require('./outpoint');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const {encoding} = bio;
|
||||
|
||||
/**
|
||||
* Input
|
||||
@ -372,7 +372,7 @@ class Input {
|
||||
|
||||
toRaw() {
|
||||
const size = this.getSize();
|
||||
return this.toWriter(new StaticWriter(size)).render();
|
||||
return this.toWriter(bio.write(size)).render();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -406,7 +406,7 @@ class Input {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
return this.fromReader(new BufferReader(data));
|
||||
return this.fromReader(bio.read(data));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -7,9 +7,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const bio = require('bufio');
|
||||
const {encoding} = bio;
|
||||
|
||||
/**
|
||||
* Inv Item
|
||||
@ -58,7 +57,7 @@ class InvItem {
|
||||
*/
|
||||
|
||||
toRaw() {
|
||||
return this.toWriter(new StaticWriter(36)).render();
|
||||
return this.toWriter(bio.write(36)).render();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -79,7 +78,7 @@ class InvItem {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
return this.fromReader(new BufferReader(data));
|
||||
return this.fromReader(bio.read(data));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -9,16 +9,15 @@
|
||||
|
||||
const assert = require('assert');
|
||||
const {base58} = require('bstring');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const bio = require('bufio');
|
||||
const hash160 = require('bcrypto/lib/hash160');
|
||||
const hash256 = require('bcrypto/lib/hash256');
|
||||
const Network = require('../protocol/network');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const Script = require('../script/script');
|
||||
const Address = require('./address');
|
||||
const Output = require('./output');
|
||||
const secp256k1 = require('bcrypto/lib/secp256k1');
|
||||
const {encoding} = bio;
|
||||
|
||||
/**
|
||||
* Key Ring
|
||||
@ -273,7 +272,7 @@ class KeyRing {
|
||||
|
||||
toSecret(network) {
|
||||
const size = this.getSecretSize();
|
||||
const bw = new StaticWriter(size);
|
||||
const bw = bio.write(size);
|
||||
|
||||
assert(this.privateKey, 'Cannot serialize without private key.');
|
||||
|
||||
@ -298,7 +297,7 @@ class KeyRing {
|
||||
*/
|
||||
|
||||
fromSecret(data, network) {
|
||||
const br = new BufferReader(base58.decode(data), true);
|
||||
const br = bio.read(base58.decode(data), true);
|
||||
|
||||
const version = br.readU8();
|
||||
|
||||
@ -835,7 +834,7 @@ class KeyRing {
|
||||
|
||||
toRaw() {
|
||||
const size = this.getSize();
|
||||
return this.toWriter(new StaticWriter(size)).render();
|
||||
return this.toWriter(bio.write(size)).render();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -876,7 +875,7 @@ class KeyRing {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
return this.fromReader(new BufferReader(data));
|
||||
return this.fromReader(bio.read(data));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -7,11 +7,11 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const bio = require('bufio');
|
||||
const AbstractBlock = require('./abstractblock');
|
||||
const Block = require('./block');
|
||||
const Headers = require('./headers');
|
||||
const Script = require('../script/script');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const DUMMY = Buffer.alloc(0);
|
||||
|
||||
/**
|
||||
@ -108,7 +108,7 @@ class MemBlock extends AbstractBlock {
|
||||
*/
|
||||
|
||||
parseCoinbaseHeight() {
|
||||
const br = new BufferReader(this._raw, true);
|
||||
const br = bio.read(this._raw, true);
|
||||
|
||||
br.seek(80);
|
||||
|
||||
@ -143,7 +143,7 @@ class MemBlock extends AbstractBlock {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
const br = new BufferReader(data, true);
|
||||
const br = bio.read(data, true);
|
||||
|
||||
this.readHead(br);
|
||||
|
||||
|
||||
@ -8,15 +8,14 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const bio = require('bufio');
|
||||
const util = require('../utils/util');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const hash256 = require('bcrypto/lib/hash256');
|
||||
const consensus = require('../protocol/consensus');
|
||||
const AbstractBlock = require('./abstractblock');
|
||||
const Headers = require('./headers');
|
||||
const DUMMY = Buffer.from([0]);
|
||||
const {encoding} = bio;
|
||||
|
||||
/**
|
||||
* Merkle Block
|
||||
@ -366,7 +365,7 @@ class MerkleBlock extends AbstractBlock {
|
||||
|
||||
toRaw() {
|
||||
const size = this.getSize();
|
||||
return this.toWriter(new StaticWriter(size)).render();
|
||||
return this.toWriter(bio.write(size)).render();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -397,7 +396,7 @@ class MerkleBlock extends AbstractBlock {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
return this.fromReader(new BufferReader(data));
|
||||
return this.fromReader(bio.read(data));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const {encoding} = require('bufio');
|
||||
const Script = require('../script/script');
|
||||
const TX = require('./tx');
|
||||
const Input = require('./input');
|
||||
@ -16,7 +17,6 @@ const Coin = require('./coin');
|
||||
const Outpoint = require('./outpoint');
|
||||
const CoinView = require('../coins/coinview');
|
||||
const Address = require('./address');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const consensus = require('../protocol/consensus');
|
||||
const policy = require('../protocol/policy');
|
||||
const Amount = require('../btc/amount');
|
||||
|
||||
@ -7,12 +7,11 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const bio = require('bufio');
|
||||
const IP = require('binet');
|
||||
const common = require('../net/common');
|
||||
const Network = require('../protocol/network');
|
||||
const util = require('../utils/util');
|
||||
const IP = require('binet');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
|
||||
/**
|
||||
* Net Address
|
||||
@ -344,7 +343,7 @@ class NetAddress {
|
||||
*/
|
||||
|
||||
fromRaw(data, full) {
|
||||
return this.fromReader(new BufferReader(data), full);
|
||||
return this.fromReader(bio.read(data), full);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -405,7 +404,7 @@ class NetAddress {
|
||||
|
||||
toRaw(full) {
|
||||
const size = this.getSize(full);
|
||||
return this.toWriter(new StaticWriter(size), full).render();
|
||||
return this.toWriter(bio.write(size), full).render();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -7,9 +7,8 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const bio = require('bufio');
|
||||
const {encoding} = bio;
|
||||
|
||||
/**
|
||||
* Outpoint
|
||||
@ -193,7 +192,7 @@ class Outpoint {
|
||||
*/
|
||||
|
||||
toRaw() {
|
||||
return this.toWriter(new StaticWriter(36)).render();
|
||||
return this.toWriter(bio.write(36)).render();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -215,7 +214,7 @@ class Outpoint {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
return this.fromReader(new BufferReader(data));
|
||||
return this.fromReader(bio.read(data));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -8,12 +8,11 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const bio = require('bufio');
|
||||
const Amount = require('../btc/amount');
|
||||
const Network = require('../protocol/network');
|
||||
const Address = require('../primitives/address');
|
||||
const Script = require('../script/script');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const consensus = require('../protocol/consensus');
|
||||
const policy = require('../protocol/policy');
|
||||
|
||||
@ -316,7 +315,7 @@ class Output {
|
||||
|
||||
toRaw() {
|
||||
const size = this.getSize();
|
||||
return this.toWriter(new StaticWriter(size)).render();
|
||||
return this.toWriter(bio.write(size)).render();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -338,7 +337,7 @@ class Output {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
return this.fromReader(new BufferReader(data));
|
||||
return this.fromReader(bio.read(data));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -8,15 +8,13 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const bio = require('bufio');
|
||||
const hash256 = require('bcrypto/lib/hash256');
|
||||
const secp256k1 = require('bcrypto/lib/secp256k1');
|
||||
const util = require('../utils/util');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const Amount = require('../btc/amount');
|
||||
const Network = require('../protocol/network');
|
||||
const Script = require('../script/script');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const Input = require('./input');
|
||||
const Output = require('./output');
|
||||
const Outpoint = require('./outpoint');
|
||||
@ -25,7 +23,8 @@ const BloomFilter = require('bfilter/lib/bloom');
|
||||
const consensus = require('../protocol/consensus');
|
||||
const policy = require('../protocol/policy');
|
||||
const ScriptError = require('../script/scripterror');
|
||||
const hashType = Script.hashType;
|
||||
const {encoding} = bio;
|
||||
const {hashType} = Script;
|
||||
|
||||
/**
|
||||
* TX
|
||||
@ -443,8 +442,11 @@ class TX {
|
||||
if ((type & 0x1f) === hashType.SINGLE) {
|
||||
// Bitcoind used to return 1 as an error code:
|
||||
// it ended up being treated like a hash.
|
||||
if (index >= this.outputs.length)
|
||||
return Buffer.from(encoding.ONE_HASH);
|
||||
if (index >= this.outputs.length) {
|
||||
const hash = Buffer.alloc(32, 0x00);
|
||||
hash[0] = 0x01;
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
// Remove all code separators.
|
||||
@ -452,7 +454,7 @@ class TX {
|
||||
|
||||
// Calculate buffer size.
|
||||
const size = this.hashSize(index, prev, type);
|
||||
const bw = StaticWriter.pool(size);
|
||||
const bw = bio.pool(size);
|
||||
|
||||
bw.writeU32(this.version);
|
||||
|
||||
@ -616,7 +618,7 @@ class TX {
|
||||
if (this._hashPrevouts) {
|
||||
prevouts = this._hashPrevouts;
|
||||
} else {
|
||||
const bw = StaticWriter.pool(this.inputs.length * 36);
|
||||
const bw = bio.pool(this.inputs.length * 36);
|
||||
|
||||
for (const input of this.inputs)
|
||||
input.prevout.toWriter(bw);
|
||||
@ -634,7 +636,7 @@ class TX {
|
||||
if (this._hashSequence) {
|
||||
sequences = this._hashSequence;
|
||||
} else {
|
||||
const bw = StaticWriter.pool(this.inputs.length * 4);
|
||||
const bw = bio.pool(this.inputs.length * 4);
|
||||
|
||||
for (const input of this.inputs)
|
||||
bw.writeU32(input.sequence);
|
||||
@ -656,7 +658,7 @@ class TX {
|
||||
for (const output of this.outputs)
|
||||
size += output.getSize();
|
||||
|
||||
const bw = StaticWriter.pool(size);
|
||||
const bw = bio.pool(size);
|
||||
|
||||
for (const output of this.outputs)
|
||||
output.toWriter(bw);
|
||||
@ -674,7 +676,7 @@ class TX {
|
||||
}
|
||||
|
||||
const size = 156 + prev.getVarSize();
|
||||
const bw = StaticWriter.pool(size);
|
||||
const bw = bio.pool(size);
|
||||
|
||||
bw.writeU32(this.version);
|
||||
bw.writeBytes(prevouts);
|
||||
@ -734,7 +736,7 @@ class TX {
|
||||
|
||||
const hash = this.signatureHash(index, prev, value, type, version);
|
||||
const sig = secp256k1.sign(hash, key);
|
||||
const bw = new StaticWriter(sig.length + 1);
|
||||
const bw = bio.write(sig.length + 1);
|
||||
|
||||
bw.writeBytes(sig);
|
||||
bw.writeU8(type);
|
||||
@ -2254,7 +2256,7 @@ class TX {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
return this.fromReader(new BufferReader(data));
|
||||
return this.fromReader(bio.read(data));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2369,7 +2371,7 @@ class TX {
|
||||
|
||||
frameNormal() {
|
||||
const raw = this.getNormalSizes();
|
||||
const bw = new StaticWriter(raw.size);
|
||||
const bw = bio.write(raw.size);
|
||||
this.writeNormal(bw);
|
||||
raw.data = bw.render();
|
||||
return raw;
|
||||
@ -2384,7 +2386,7 @@ class TX {
|
||||
|
||||
frameWitness() {
|
||||
const raw = this.getWitnessSizes();
|
||||
const bw = new StaticWriter(raw.size);
|
||||
const bw = bio.write(raw.size);
|
||||
this.writeWitness(bw);
|
||||
raw.data = bw.render();
|
||||
return raw;
|
||||
|
||||
@ -7,11 +7,10 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const bio = require('bufio');
|
||||
const util = require('../utils/util');
|
||||
const TX = require('./tx');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const {encoding} = bio;
|
||||
|
||||
/**
|
||||
* TXMeta
|
||||
@ -236,7 +235,7 @@ class TXMeta {
|
||||
|
||||
toRaw() {
|
||||
const size = this.getSize();
|
||||
const bw = new StaticWriter(size);
|
||||
const bw = bio.write(size);
|
||||
|
||||
this.tx.toWriter(bw);
|
||||
|
||||
@ -262,7 +261,7 @@ class TXMeta {
|
||||
*/
|
||||
|
||||
fromRaw(data) {
|
||||
const br = new BufferReader(data);
|
||||
const br = bio.read(data);
|
||||
|
||||
this.tx.fromReader(br);
|
||||
|
||||
|
||||
@ -8,10 +8,9 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const bio = require('bufio');
|
||||
const ScriptNum = require('./scriptnum');
|
||||
const common = require('./common');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const opcodes = common.opcodes;
|
||||
|
||||
const opCache = [];
|
||||
@ -340,7 +339,7 @@ Opcode.prototype.toWriter = function toWriter(bw) {
|
||||
|
||||
Opcode.prototype.toRaw = function toRaw() {
|
||||
const size = this.getSize();
|
||||
return this.toWriter(new StaticWriter(size)).render();
|
||||
return this.toWriter(bio.write(size)).render();
|
||||
};
|
||||
|
||||
/**
|
||||
@ -654,7 +653,7 @@ Opcode.fromReader = function fromReader(br) {
|
||||
*/
|
||||
|
||||
Opcode.fromRaw = function fromRaw(data) {
|
||||
return Opcode.fromReader(new BufferReader(data));
|
||||
return Opcode.fromReader(bio.read(data));
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const bio = require('bufio');
|
||||
const ripemd160 = require('bcrypto/lib/ripemd160');
|
||||
const sha1 = require('bcrypto/lib/sha1');
|
||||
const sha256 = require('bcrypto/lib/sha256');
|
||||
@ -17,21 +18,23 @@ const merkle = require('bcrypto/lib/merkle');
|
||||
const secp256k1 = require('bcrypto/lib/secp256k1');
|
||||
const consensus = require('../protocol/consensus');
|
||||
const policy = require('../protocol/policy');
|
||||
const BufferWriter = require('bufio/lib/writer');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const Program = require('./program');
|
||||
const Opcode = require('./opcode');
|
||||
const Stack = require('./stack');
|
||||
const ScriptError = require('./scripterror');
|
||||
const ScriptNum = require('./scriptnum');
|
||||
const common = require('./common');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const Address = require('../primitives/address');
|
||||
const opcodes = common.opcodes;
|
||||
const scriptTypes = common.types;
|
||||
const Hash160 = hash160;
|
||||
const Sha256 = sha256;
|
||||
const {encoding} = bio;
|
||||
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
|
||||
const EMPTY_BUFFER = Buffer.alloc(0);
|
||||
|
||||
/**
|
||||
@ -421,7 +424,7 @@ Script.prototype.compile = function compile() {
|
||||
for (const op of this.code)
|
||||
size += op.getSize();
|
||||
|
||||
const bw = new StaticWriter(size);
|
||||
const bw = bio.write(size);
|
||||
|
||||
for (const op of this.code)
|
||||
op.toWriter(bw);
|
||||
@ -1689,7 +1692,7 @@ Script.fromAddress = function fromAddress(address) {
|
||||
*/
|
||||
|
||||
Script.prototype.fromCommitment = function fromCommitment(hash, flags) {
|
||||
const bw = new StaticWriter(36);
|
||||
const bw = bio.write(36);
|
||||
|
||||
bw.writeU32BE(0xaa21a9ed);
|
||||
bw.writeHash(hash);
|
||||
@ -3082,7 +3085,7 @@ Script.prototype.fromString = function fromString(code) {
|
||||
return this;
|
||||
|
||||
const items = code.split(/\s+/);
|
||||
const bw = new BufferWriter();
|
||||
const bw = bio.write();
|
||||
|
||||
for (const item of items) {
|
||||
let symbol = item;
|
||||
@ -3350,7 +3353,7 @@ Script.verifyMast = function verifyMast(program, stack, output, flags, tx, index
|
||||
throw new ScriptError('INVALID_MAST_STACK');
|
||||
|
||||
let ops = subscripts;
|
||||
let scriptRoot = new BufferWriter();
|
||||
let scriptRoot = bio.write();
|
||||
scriptRoot.writeU8(subscripts);
|
||||
|
||||
if (metadata[metadata.length - 1] === 0x00)
|
||||
@ -3369,7 +3372,7 @@ Script.verifyMast = function verifyMast(program, stack, output, flags, tx, index
|
||||
throw new ScriptError('DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM');
|
||||
}
|
||||
|
||||
let mastRoot = new BufferWriter();
|
||||
let mastRoot = bio.write();
|
||||
mastRoot.writeU32(version);
|
||||
|
||||
const pathdata = stack.get(-2);
|
||||
@ -3415,7 +3418,7 @@ Script.verifyMast = function verifyMast(program, stack, output, flags, tx, index
|
||||
throw new ScriptError('INVALID_MAST_STACK');
|
||||
}
|
||||
|
||||
let scripts = new BufferWriter();
|
||||
let scripts = bio.write();
|
||||
scripts.writeBytes(output.raw);
|
||||
|
||||
for (let j = 0; j < subscripts; j++) {
|
||||
@ -3471,7 +3474,7 @@ Script.prototype.fromReader = function fromReader(br) {
|
||||
*/
|
||||
|
||||
Script.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data, true);
|
||||
const br = bio.read(data, true);
|
||||
|
||||
this.raw = data;
|
||||
|
||||
|
||||
@ -8,13 +8,12 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const bio = require('bufio');
|
||||
const Script = require('./script');
|
||||
const common = require('./common');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const Address = require('../primitives/address');
|
||||
const Stack = require('./stack');
|
||||
const {encoding} = bio;
|
||||
const scriptTypes = common.types;
|
||||
|
||||
/**
|
||||
@ -416,7 +415,7 @@ Witness.prototype.toWriter = function toWriter(bw) {
|
||||
|
||||
Witness.prototype.toRaw = function toRaw() {
|
||||
const size = this.getVarSize();
|
||||
return this.toWriter(new StaticWriter(size)).render();
|
||||
return this.toWriter(bio.write(size)).render();
|
||||
};
|
||||
|
||||
/**
|
||||
@ -471,7 +470,7 @@ Witness.prototype.fromReader = function fromReader(br) {
|
||||
*/
|
||||
|
||||
Witness.prototype.fromRaw = function fromRaw(data) {
|
||||
return this.fromReader(new BufferReader(data));
|
||||
return this.fromReader(bio.read(data));
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@ -7,15 +7,14 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const bio = require('bufio');
|
||||
const binary = require('../utils/binary');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const Path = require('./path');
|
||||
const common = require('./common');
|
||||
const Script = require('../script/script');
|
||||
const WalletKey = require('./walletkey');
|
||||
const HD = require('../hd/hd');
|
||||
const {encoding} = bio;
|
||||
|
||||
/**
|
||||
* Represents a BIP44 Account belonging to a {@link Wallet}.
|
||||
@ -893,7 +892,7 @@ Account.prototype.getSize = function getSize() {
|
||||
|
||||
Account.prototype.toRaw = function toRaw() {
|
||||
const size = this.getSize();
|
||||
const bw = new StaticWriter(size);
|
||||
const bw = bio.write(size);
|
||||
|
||||
bw.writeVarString(this.name, 'ascii');
|
||||
bw.writeU8(this.initialized ? 1 : 0);
|
||||
@ -923,7 +922,7 @@ Account.prototype.toRaw = function toRaw() {
|
||||
*/
|
||||
|
||||
Account.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data);
|
||||
const br = bio.read(data);
|
||||
|
||||
this.name = br.readVarString('ascii');
|
||||
this.initialized = br.readU8() === 1;
|
||||
|
||||
@ -8,10 +8,10 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const {encoding} = require('bufio');
|
||||
const {NodeClient} = require('bclient');
|
||||
const TX = require('../primitives/tx');
|
||||
const hash256 = require('bcrypto/lib/hash256');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
|
||||
const parsers = {
|
||||
'block connect': (entry, txs) => parseBlock(entry, txs),
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const bio = require('bufio');
|
||||
const {Lock} = require('bmutex');
|
||||
const random = require('bcrypto/lib/random');
|
||||
const cleanse = require('bcrypto/lib/cleanse');
|
||||
@ -14,13 +15,11 @@ const aes = require('bcrypto/lib/aes');
|
||||
const sha256 = require('bcrypto/lib/sha256');
|
||||
const pbkdf2 = require('bcrypto/lib/pbkdf2');
|
||||
const scrypt = require('bcrypto/lib/scrypt');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const Network = require('../protocol/network');
|
||||
const util = require('../utils/util');
|
||||
const HD = require('../hd/hd');
|
||||
const Mnemonic = HD.Mnemonic;
|
||||
const {encoding} = bio;
|
||||
const {Mnemonic} = HD;
|
||||
|
||||
/**
|
||||
* Master BIP32 key which can exist
|
||||
@ -480,7 +479,7 @@ MasterKey.prototype.keySize = function keySize() {
|
||||
*/
|
||||
|
||||
MasterKey.prototype.writeKey = function writeKey() {
|
||||
const bw = new StaticWriter(this.keySize());
|
||||
const bw = bio.write(this.keySize());
|
||||
|
||||
this.key.toWriter(bw, this.network);
|
||||
|
||||
@ -500,7 +499,7 @@ MasterKey.prototype.writeKey = function writeKey() {
|
||||
*/
|
||||
|
||||
MasterKey.prototype.readKey = function readKey(data) {
|
||||
const br = new BufferReader(data);
|
||||
const br = bio.read(data);
|
||||
|
||||
this.key = HD.PrivateKey.fromReader(br, this.network);
|
||||
|
||||
@ -539,7 +538,7 @@ MasterKey.prototype.getSize = function getSize() {
|
||||
*/
|
||||
|
||||
MasterKey.prototype.toRaw = function toRaw() {
|
||||
const bw = new StaticWriter(this.getSize());
|
||||
const bw = bio.write(this.getSize());
|
||||
|
||||
if (this.encrypted) {
|
||||
bw.writeU8(1);
|
||||
@ -579,7 +578,7 @@ MasterKey.prototype.toRaw = function toRaw() {
|
||||
*/
|
||||
|
||||
MasterKey.prototype.fromRaw = function fromRaw(raw, network) {
|
||||
const br = new BufferReader(raw);
|
||||
const br = bio.read(raw);
|
||||
|
||||
this.network = Network.get(network);
|
||||
this.encrypted = br.readU8() === 1;
|
||||
|
||||
@ -7,10 +7,9 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const bio = require('bufio');
|
||||
const Address = require('../primitives/address');
|
||||
const {encoding} = bio;
|
||||
|
||||
/**
|
||||
* Path
|
||||
@ -126,7 +125,7 @@ Path.prototype.clone = function clone() {
|
||||
*/
|
||||
|
||||
Path.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data);
|
||||
const br = bio.read(data);
|
||||
|
||||
this.account = br.readU32();
|
||||
this.keyType = br.readU8();
|
||||
@ -199,7 +198,7 @@ Path.prototype.getSize = function getSize() {
|
||||
|
||||
Path.prototype.toRaw = function toRaw() {
|
||||
const size = this.getSize();
|
||||
const bw = new StaticWriter(size);
|
||||
const bw = bio.write(size);
|
||||
|
||||
bw.writeU32(this.account);
|
||||
bw.writeU8(this.keyType);
|
||||
|
||||
@ -11,11 +11,10 @@
|
||||
*/
|
||||
|
||||
const assert = require('assert');
|
||||
const bio = require('bufio');
|
||||
const util = require('../utils/util');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const TX = require('../primitives/tx');
|
||||
const {encoding} = bio;
|
||||
|
||||
/**
|
||||
* Chain State
|
||||
@ -53,7 +52,7 @@ ChainState.prototype.clone = function clone() {
|
||||
*/
|
||||
|
||||
ChainState.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data);
|
||||
const br = bio.read(data);
|
||||
|
||||
this.startHeight = br.readU32();
|
||||
this.startHash = br.readHash('hex');
|
||||
@ -80,7 +79,7 @@ ChainState.fromRaw = function fromRaw(data) {
|
||||
*/
|
||||
|
||||
ChainState.prototype.toRaw = function toRaw() {
|
||||
const bw = new StaticWriter(41);
|
||||
const bw = bio.write(41);
|
||||
|
||||
bw.writeU32(this.startHeight);
|
||||
bw.writeHash(this.startHash);
|
||||
@ -158,7 +157,7 @@ BlockMeta.prototype.fromJSON = function fromJSON(json) {
|
||||
*/
|
||||
|
||||
BlockMeta.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data);
|
||||
const br = bio.read(data);
|
||||
this.hash = br.readHash('hex');
|
||||
this.height = br.readU32();
|
||||
this.time = br.readU32();
|
||||
@ -202,7 +201,7 @@ BlockMeta.fromRaw = function fromRaw(data) {
|
||||
*/
|
||||
|
||||
BlockMeta.prototype.toRaw = function toRaw() {
|
||||
const bw = new StaticWriter(42);
|
||||
const bw = bio.write(42);
|
||||
bw.writeHash(this.hash);
|
||||
bw.writeU32(this.height);
|
||||
bw.writeU32(this.time);
|
||||
@ -354,7 +353,7 @@ TXRecord.prototype.getSize = function getSize() {
|
||||
|
||||
TXRecord.prototype.toRaw = function toRaw() {
|
||||
const size = this.getSize();
|
||||
const bw = new StaticWriter(size);
|
||||
const bw = bio.write(size);
|
||||
|
||||
let index = this.index;
|
||||
|
||||
@ -385,7 +384,7 @@ TXRecord.prototype.toRaw = function toRaw() {
|
||||
*/
|
||||
|
||||
TXRecord.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data);
|
||||
const br = bio.read(data);
|
||||
|
||||
this.tx = new TX();
|
||||
this.tx.fromReader(br);
|
||||
@ -453,7 +452,7 @@ MapRecord.prototype.getSize = function getSize() {
|
||||
|
||||
MapRecord.prototype.toRaw = function toRaw() {
|
||||
const size = this.getSize();
|
||||
return this.toWriter(new StaticWriter(size)).render();
|
||||
return this.toWriter(bio.write(size)).render();
|
||||
};
|
||||
|
||||
MapRecord.prototype.fromReader = function fromReader(br) {
|
||||
@ -466,7 +465,7 @@ MapRecord.prototype.fromReader = function fromReader(br) {
|
||||
};
|
||||
|
||||
MapRecord.prototype.fromRaw = function fromRaw(data) {
|
||||
return this.fromReader(new BufferReader(data));
|
||||
return this.fromReader(bio.read(data));
|
||||
};
|
||||
|
||||
MapRecord.fromReader = function fromReader(br) {
|
||||
|
||||
@ -12,8 +12,8 @@ const bweb = require('bweb');
|
||||
const {Lock} = require('bmutex');
|
||||
const fs = require('bfile');
|
||||
const Validator = require('bval');
|
||||
const {encoding} = require('bufio');
|
||||
const hash256 = require('bcrypto/lib/hash256');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const util = require('../utils/util');
|
||||
const Amount = require('../btc/amount');
|
||||
const Script = require('../script/script');
|
||||
|
||||
@ -8,18 +8,17 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const bio = require('bufio');
|
||||
const util = require('../utils/util');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const Amount = require('../btc/amount');
|
||||
const CoinView = require('../coins/coinview');
|
||||
const Coin = require('../primitives/coin');
|
||||
const Outpoint = require('../primitives/outpoint');
|
||||
const records = require('./records');
|
||||
const layout = require('./layout').txdb;
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const policy = require('../protocol/policy');
|
||||
const TXRecord = records.TXRecord;
|
||||
const {encoding} = bio;
|
||||
const {TXRecord} = records;
|
||||
|
||||
/**
|
||||
* TXDB
|
||||
@ -2150,7 +2149,7 @@ Balance.prototype.applyTo = function applyTo(balance) {
|
||||
*/
|
||||
|
||||
Balance.prototype.toRaw = function toRaw() {
|
||||
const bw = new StaticWriter(32);
|
||||
const bw = bio.write(32);
|
||||
|
||||
bw.writeU64(this.tx);
|
||||
bw.writeU64(this.coin);
|
||||
@ -2168,7 +2167,7 @@ Balance.prototype.toRaw = function toRaw() {
|
||||
*/
|
||||
|
||||
Balance.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data);
|
||||
const br = bio.read(data);
|
||||
this.tx = br.readU64();
|
||||
this.coin = br.readU64();
|
||||
this.unconfirmed = br.readU64();
|
||||
@ -2293,7 +2292,7 @@ function Credit(coin, spent) {
|
||||
*/
|
||||
|
||||
Credit.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data);
|
||||
const br = bio.read(data);
|
||||
this.coin.fromReader(br);
|
||||
this.spent = br.readU8() === 1;
|
||||
this.own = br.readU8() === 1;
|
||||
@ -2326,7 +2325,7 @@ Credit.prototype.getSize = function getSize() {
|
||||
|
||||
Credit.prototype.toRaw = function toRaw() {
|
||||
const size = this.getSize();
|
||||
const bw = new StaticWriter(size);
|
||||
const bw = bio.write(size);
|
||||
this.coin.toWriter(bw);
|
||||
bw.writeU8(this.spent ? 1 : 0);
|
||||
bw.writeU8(this.own ? 1 : 0);
|
||||
@ -2627,7 +2626,7 @@ BlockRecord.prototype.remove = function remove(hash) {
|
||||
*/
|
||||
|
||||
BlockRecord.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data);
|
||||
const br = bio.read(data);
|
||||
|
||||
this.hash = br.readHash('hex');
|
||||
this.height = br.readU32();
|
||||
@ -2669,7 +2668,7 @@ BlockRecord.prototype.getSize = function getSize() {
|
||||
|
||||
BlockRecord.prototype.toRaw = function toRaw() {
|
||||
const size = this.getSize();
|
||||
const bw = new StaticWriter(size);
|
||||
const bw = bio.write(size);
|
||||
|
||||
bw.writeHash(this.hash);
|
||||
bw.writeU32(this.height);
|
||||
|
||||
@ -11,12 +11,10 @@ const assert = require('assert');
|
||||
const EventEmitter = require('events');
|
||||
const {Lock} = require('bmutex');
|
||||
const {base58} = require('bstring');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const bio = require('bufio');
|
||||
const hash160 = require('bcrypto/lib/hash160');
|
||||
const hash256 = require('bcrypto/lib/hash256');
|
||||
const cleanse = require('bcrypto/lib/cleanse');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const Network = require('../protocol/network');
|
||||
const TXDB = require('./txdb');
|
||||
const Path = require('./path');
|
||||
@ -31,7 +29,8 @@ const Account = require('./account');
|
||||
const MasterKey = require('./masterkey');
|
||||
const policy = require('../protocol/policy');
|
||||
const consensus = require('../protocol/consensus');
|
||||
const Mnemonic = HD.Mnemonic;
|
||||
const {encoding} = bio;
|
||||
const {Mnemonic} = HD;
|
||||
|
||||
/**
|
||||
* BIP44 Wallet
|
||||
@ -534,13 +533,13 @@ Wallet.prototype.getID = function getID() {
|
||||
|
||||
const key = this.master.key.derive(44);
|
||||
|
||||
const bw = new StaticWriter(37);
|
||||
const bw = bio.write(37);
|
||||
bw.writeBytes(key.publicKey);
|
||||
bw.writeU32(this.network.magic);
|
||||
|
||||
const hash = hash160.digest(bw.render());
|
||||
|
||||
const b58 = new StaticWriter(27);
|
||||
const b58 = bio.write(27);
|
||||
b58.writeU8(0x03);
|
||||
b58.writeU8(0xbe);
|
||||
b58.writeU8(0x04);
|
||||
@ -565,7 +564,7 @@ Wallet.prototype.getToken = function getToken(nonce) {
|
||||
|
||||
const key = this.master.key.derive(44, true);
|
||||
|
||||
const bw = new StaticWriter(36);
|
||||
const bw = bio.write(36);
|
||||
bw.writeBytes(key.privateKey);
|
||||
bw.writeU32(nonce);
|
||||
|
||||
@ -2303,7 +2302,7 @@ Wallet.prototype.getSize = function getSize() {
|
||||
|
||||
Wallet.prototype.toRaw = function toRaw() {
|
||||
const size = this.getSize();
|
||||
const bw = new StaticWriter(size);
|
||||
const bw = bio.write(size);
|
||||
|
||||
bw.writeU32(this.network.magic);
|
||||
bw.writeU32(this.wid);
|
||||
@ -2325,7 +2324,7 @@ Wallet.prototype.toRaw = function toRaw() {
|
||||
*/
|
||||
|
||||
Wallet.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data);
|
||||
const br = bio.read(data);
|
||||
const network = Network.fromMagic(br.readU32());
|
||||
|
||||
assert(network === this.network, 'Wallet network mismatch.');
|
||||
|
||||
@ -10,15 +10,14 @@
|
||||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
const EventEmitter = require('events');
|
||||
const bio = require('bufio');
|
||||
const Lock = require('bmutex/lib/lock');
|
||||
const MapLock = require('bmutex/lib/maplock');
|
||||
const BDB = require('bdb');
|
||||
const Logger = require('blgr');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const ccmp = require('bcrypto/lib/ccmp');
|
||||
const aes = require('bcrypto/lib/aes');
|
||||
const BloomFilter = require('bfilter/lib/bloom');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const Network = require('../protocol/network');
|
||||
const Path = require('./path');
|
||||
const common = require('./common');
|
||||
@ -28,12 +27,16 @@ const Outpoint = require('../primitives/outpoint');
|
||||
const layouts = require('./layout');
|
||||
const records = require('./records');
|
||||
const NullClient = require('./nullclient');
|
||||
const {encoding} = bio;
|
||||
const {u32} = encoding;
|
||||
const layout = layouts.walletdb;
|
||||
const ChainState = records.ChainState;
|
||||
const BlockMeta = records.BlockMeta;
|
||||
const TXRecord = records.TXRecord;
|
||||
const MapRecord = records.MapRecord;
|
||||
const u32 = encoding.u32;
|
||||
|
||||
const {
|
||||
ChainState,
|
||||
BlockMeta,
|
||||
TXRecord,
|
||||
MapRecord
|
||||
} = records;
|
||||
|
||||
/**
|
||||
* WalletDB
|
||||
@ -1434,7 +1437,7 @@ WalletDB.prototype.addMap = async function addMap(b, key, wid) {
|
||||
assert(data.length >= 4);
|
||||
|
||||
const len = data.readUInt32LE(0, true);
|
||||
const bw = new StaticWriter(data.length + 4);
|
||||
const bw = bio.write(data.length + 4);
|
||||
|
||||
bw.writeU32(len + 1);
|
||||
bw.copy(data, 4, data.length);
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const bio = require('bufio');
|
||||
|
||||
/**
|
||||
* Framer
|
||||
@ -22,7 +22,7 @@ function Framer() {
|
||||
|
||||
Framer.prototype.packet = function packet(payload) {
|
||||
const size = 10 + payload.getSize();
|
||||
const bw = new StaticWriter(size);
|
||||
const bw = bio.write(size);
|
||||
|
||||
bw.writeU32(payload.id);
|
||||
bw.writeU8(payload.cmd);
|
||||
|
||||
@ -11,8 +11,7 @@
|
||||
*/
|
||||
|
||||
const assert = require('assert');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const bio = require('bufio');
|
||||
const Script = require('../script/script');
|
||||
const Witness = require('../script/witness');
|
||||
const Output = require('../primitives/output');
|
||||
@ -21,6 +20,7 @@ const TX = require('../primitives/tx');
|
||||
const KeyRing = require('../primitives/keyring');
|
||||
const CoinView = require('../coins/coinview');
|
||||
const ScriptError = require('../script/scripterror');
|
||||
const {encoding} = bio;
|
||||
|
||||
/*
|
||||
* Constants
|
||||
@ -104,7 +104,7 @@ EnvPacket.prototype.toWriter = function toWriter(bw) {
|
||||
};
|
||||
|
||||
EnvPacket.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data, true);
|
||||
const br = bio.read(data, true);
|
||||
this.json = br.readVarString('utf8');
|
||||
this.env = JSON.parse(this.json);
|
||||
return this;
|
||||
@ -139,7 +139,7 @@ EventPacket.prototype.toWriter = function toWriter(bw) {
|
||||
};
|
||||
|
||||
EventPacket.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data, true);
|
||||
const br = bio.read(data, true);
|
||||
this.json = br.readVarString('utf8');
|
||||
this.items = JSON.parse(this.json);
|
||||
return this;
|
||||
@ -173,7 +173,7 @@ LogPacket.prototype.toWriter = function toWriter(bw) {
|
||||
};
|
||||
|
||||
LogPacket.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data, true);
|
||||
const br = bio.read(data, true);
|
||||
this.text = br.readVarString('utf8');
|
||||
return this;
|
||||
};
|
||||
@ -247,7 +247,7 @@ ErrorPacket.prototype.toWriter = function toWriter(bw) {
|
||||
};
|
||||
|
||||
ErrorPacket.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data, true);
|
||||
const br = bio.read(data, true);
|
||||
const err = this.error;
|
||||
|
||||
err.message = br.readVarString('utf8');
|
||||
@ -318,7 +318,7 @@ CheckPacket.prototype.toWriter = function toWriter(bw) {
|
||||
};
|
||||
|
||||
CheckPacket.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data, true);
|
||||
const br = bio.read(data, true);
|
||||
|
||||
this.tx = TX.fromReader(br);
|
||||
this.view = CoinView.fromReader(br, this.tx);
|
||||
@ -387,7 +387,7 @@ CheckResultPacket.prototype.toWriter = function toWriter(bw) {
|
||||
};
|
||||
|
||||
CheckResultPacket.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data, true);
|
||||
const br = bio.read(data, true);
|
||||
|
||||
if (br.readU8() === 0)
|
||||
return this;
|
||||
@ -461,7 +461,7 @@ SignPacket.prototype.toWriter = function toWriter(bw) {
|
||||
};
|
||||
|
||||
SignPacket.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data, true);
|
||||
const br = bio.read(data, true);
|
||||
|
||||
this.tx = MTX.fromReader(br);
|
||||
this.tx.view.fromReader(br, this.tx);
|
||||
@ -555,7 +555,7 @@ SignResultPacket.prototype.inject = function inject(tx) {
|
||||
};
|
||||
|
||||
SignResultPacket.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data, true);
|
||||
const br = bio.read(data, true);
|
||||
|
||||
this.total = br.readVarint();
|
||||
|
||||
@ -610,7 +610,7 @@ CheckInputPacket.prototype.toWriter = function toWriter(bw) {
|
||||
};
|
||||
|
||||
CheckInputPacket.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data, true);
|
||||
const br = bio.read(data, true);
|
||||
|
||||
this.tx = TX.fromReader(br);
|
||||
this.index = br.readVarint();
|
||||
@ -690,7 +690,7 @@ SignInputPacket.prototype.toWriter = function toWriter(bw) {
|
||||
};
|
||||
|
||||
SignInputPacket.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data, true);
|
||||
const br = bio.read(data, true);
|
||||
|
||||
this.tx = MTX.fromReader(br);
|
||||
this.index = br.readVarint();
|
||||
@ -760,7 +760,7 @@ SignInputResultPacket.prototype.inject = function inject(tx, i) {
|
||||
};
|
||||
|
||||
SignInputResultPacket.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data, true);
|
||||
const br = bio.read(data, true);
|
||||
this.value = br.readU8() === 1;
|
||||
this.script = Script.fromReader(br);
|
||||
this.witness = Witness.fromReader(br);
|
||||
@ -803,7 +803,7 @@ ECVerifyPacket.prototype.toWriter = function toWriter(bw) {
|
||||
};
|
||||
|
||||
ECVerifyPacket.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data, true);
|
||||
const br = bio.read(data, true);
|
||||
this.msg = br.readVarBytes();
|
||||
this.sig = br.readVarBytes();
|
||||
this.key = br.readVarBytes();
|
||||
@ -838,7 +838,7 @@ ECVerifyResultPacket.prototype.toWriter = function toWriter(bw) {
|
||||
};
|
||||
|
||||
ECVerifyResultPacket.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data, true);
|
||||
const br = bio.read(data, true);
|
||||
this.value = br.readU8() === 1;
|
||||
return this;
|
||||
};
|
||||
@ -876,7 +876,7 @@ ECSignPacket.prototype.toWriter = function toWriter(bw) {
|
||||
};
|
||||
|
||||
ECSignPacket.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data, true);
|
||||
const br = bio.read(data, true);
|
||||
this.msg = br.readVarBytes();
|
||||
this.key = br.readVarBytes();
|
||||
return this;
|
||||
@ -910,7 +910,7 @@ ECSignResultPacket.prototype.toWriter = function toWriter(bw) {
|
||||
};
|
||||
|
||||
ECSignResultPacket.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data, true);
|
||||
const br = bio.read(data, true);
|
||||
this.sig = br.readVarBytes();
|
||||
return this;
|
||||
};
|
||||
@ -949,7 +949,7 @@ MinePacket.prototype.toWriter = function toWriter(bw) {
|
||||
};
|
||||
|
||||
MinePacket.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data, true);
|
||||
const br = bio.read(data, true);
|
||||
this.data = br.readBytes(80);
|
||||
this.target = br.readBytes(32);
|
||||
this.min = br.readU32();
|
||||
@ -986,7 +986,7 @@ MineResultPacket.prototype.toWriter = function toWriter(bw) {
|
||||
};
|
||||
|
||||
MineResultPacket.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data, true);
|
||||
const br = bio.read(data, true);
|
||||
this.nonce = -1;
|
||||
if (br.readU8() === 1)
|
||||
this.nonce = br.readU32();
|
||||
@ -1035,7 +1035,7 @@ ScryptPacket.prototype.toWriter = function toWriter(bw) {
|
||||
};
|
||||
|
||||
ScryptPacket.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data, true);
|
||||
const br = bio.read(data, true);
|
||||
this.passwd = br.readVarBytes();
|
||||
this.salt = br.readVarBytes();
|
||||
this.N = br.readU32();
|
||||
@ -1073,7 +1073,7 @@ ScryptResultPacket.prototype.toWriter = function toWriter(bw) {
|
||||
};
|
||||
|
||||
ScryptResultPacket.prototype.fromRaw = function fromRaw(data) {
|
||||
const br = new BufferReader(data, true);
|
||||
const br = bio.read(data, true);
|
||||
this.key = br.readVarBytes();
|
||||
return this;
|
||||
};
|
||||
|
||||
@ -2,7 +2,8 @@
|
||||
|
||||
const bcoin = require('../');
|
||||
const assert = require('assert');
|
||||
const BufferWriter = require('bufio/lib/writer');
|
||||
const bio = require('bufio');
|
||||
|
||||
let file = process.argv[2];
|
||||
|
||||
assert(typeof file === 'string', 'Please pass in a database path.');
|
||||
@ -50,7 +51,7 @@ async function updateState() {
|
||||
|
||||
const hash = data.slice(0, 32);
|
||||
|
||||
let p = new BufferWriter();
|
||||
let p = bio.write();
|
||||
p.writeHash(hash);
|
||||
p.writeU64(0);
|
||||
p.writeU64(0);
|
||||
|
||||
@ -2,15 +2,14 @@
|
||||
|
||||
const assert = require('assert');
|
||||
const BDB = require('bdb');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const bio = require('bufio');
|
||||
const networks = require('../lib/protocol/networks');
|
||||
const BufferWriter = require('bufio/lib/writer');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const OldCoins = require('./coins-old');
|
||||
const Coins = require('../lib/coins/coins');
|
||||
const UndoCoins = require('../lib/coins/undocoins');
|
||||
const Coin = require('../lib/primitives/coin');
|
||||
const Output = require('../lib/primitives/output');
|
||||
const {encoding} = bio;
|
||||
|
||||
let file = process.argv[2];
|
||||
let batch;
|
||||
@ -172,7 +171,7 @@ async function reserializeUndo() {
|
||||
if (!item)
|
||||
break;
|
||||
|
||||
const br = new BufferReader(item.value);
|
||||
const br = bio.read(item.value);
|
||||
const undo = new UndoCoins();
|
||||
|
||||
while (br.left()) {
|
||||
@ -217,7 +216,7 @@ function injectCoin(undo, coin) {
|
||||
}
|
||||
|
||||
function defaultOptions() {
|
||||
const bw = new BufferWriter();
|
||||
const bw = bio.write();
|
||||
let flags = 0;
|
||||
|
||||
if (options.spv)
|
||||
@ -242,7 +241,7 @@ function defaultOptions() {
|
||||
}
|
||||
|
||||
function defaultDeployments() {
|
||||
const bw = new BufferWriter();
|
||||
const bw = bio.write();
|
||||
|
||||
bw.writeU8(options.network.deploys.length);
|
||||
|
||||
|
||||
@ -17,20 +17,20 @@ if (process.argv.indexOf('-h') !== -1
|
||||
|
||||
const assert = require('assert');
|
||||
const BDB = require('bdb');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const hash256 = require('bcrypto/lib/hash256');
|
||||
const BN = require('bcrypto/lib/bn');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const bio = require('bufio');
|
||||
const OldCoins = require('./coins/coins');
|
||||
const OldUndoCoins = require('./coins/undocoins');
|
||||
const CoinEntry = require('../lib/coins/coinentry');
|
||||
const UndoCoins = require('../lib/coins/undocoins');
|
||||
const Block = require('../lib/primitives/block');
|
||||
const LRU = require('../lib/utils/lru');
|
||||
const {encoding} = bio;
|
||||
|
||||
const file = process.argv[2].replace(/\.ldb\/?$/, '');
|
||||
const shouldPrune = process.argv.indexOf('--prune') !== -1;
|
||||
|
||||
let hasIndex = false;
|
||||
let hasPruned = false;
|
||||
let hasSPV = false;
|
||||
@ -524,7 +524,7 @@ async function getMeta(coin, prevout) {
|
||||
return [1, 1, false];
|
||||
}
|
||||
|
||||
const br = new BufferReader(coinsRaw);
|
||||
const br = bio.read(coinsRaw);
|
||||
const version = br.readVarint();
|
||||
const height = br.readU32();
|
||||
|
||||
@ -577,7 +577,7 @@ async function isMainChain(entry, tip) {
|
||||
}
|
||||
|
||||
function entryFromRaw(data) {
|
||||
const br = new BufferReader(data, true);
|
||||
const br = bio.read(data, true);
|
||||
const hash = hash256.digest(br.readBytes(80));
|
||||
|
||||
br.seek(-80);
|
||||
@ -597,7 +597,7 @@ function entryFromRaw(data) {
|
||||
}
|
||||
|
||||
function entryToRaw(entry, main) {
|
||||
const bw = new StaticWriter(116 + 1);
|
||||
const bw = bio.write(116 + 1);
|
||||
|
||||
bw.writeU32(entry.version);
|
||||
bw.writeHash(entry.prevBlock);
|
||||
|
||||
@ -9,13 +9,12 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const bio = require('bufio');
|
||||
const util = require('../lib/utils/util');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const Coin = require('../lib/primitives/coin');
|
||||
const Output = require('../lib/primitives/output');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const BufferWriter = require('bufio/lib/writer');
|
||||
const {compress, decompress} = require('./compress-old');
|
||||
const {encoding} = bio;
|
||||
|
||||
/**
|
||||
* Represents the outputs for a single transaction.
|
||||
@ -220,7 +219,7 @@ Coins.prototype.isEmpty = function isEmpty() {
|
||||
*/
|
||||
|
||||
Coins.prototype.toRaw = function toRaw() {
|
||||
const bw = new BufferWriter();
|
||||
const bw = bio.write();
|
||||
const length = this.size();
|
||||
const len = Math.ceil(length / 8);
|
||||
|
||||
@ -300,7 +299,7 @@ Coins.prototype.toRaw = function toRaw() {
|
||||
*/
|
||||
|
||||
Coins.prototype.fromRaw = function fromRaw(data, hash, index) {
|
||||
const br = new BufferReader(data);
|
||||
const br = bio.read(data);
|
||||
let pos = 0;
|
||||
|
||||
this.version = br.readVarint();
|
||||
@ -353,7 +352,7 @@ Coins.prototype.fromRaw = function fromRaw(data, hash, index) {
|
||||
*/
|
||||
|
||||
Coins.parseCoin = function parseCoin(data, hash, index) {
|
||||
const br = new BufferReader(data);
|
||||
const br = bio.read(data);
|
||||
const coin = new Coin();
|
||||
let pos = 0;
|
||||
|
||||
@ -500,7 +499,7 @@ CoinEntry.prototype.toCoin = function toCoin(coins, index) {
|
||||
return coin;
|
||||
}
|
||||
|
||||
const br = new BufferReader(this.raw);
|
||||
const br = bio.read(this.raw);
|
||||
|
||||
// Seek to the coin's offset.
|
||||
br.seek(this.offset);
|
||||
|
||||
@ -2,10 +2,11 @@
|
||||
|
||||
const assert = require('assert');
|
||||
const BDB = require('bdb');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const bio = require('bufio');
|
||||
const hash256 = require('bcrypto/lib/hash256');
|
||||
const BN = require('bcrypto/lib/bn');
|
||||
const {encoding} = bio;
|
||||
|
||||
const DUMMY = Buffer.from([0]);
|
||||
|
||||
let file = process.argv[2];
|
||||
@ -39,7 +40,7 @@ async function checkVersion() {
|
||||
}
|
||||
|
||||
function entryFromRaw(data) {
|
||||
const p = new BufferReader(data, true);
|
||||
const p = bio.read(data, true);
|
||||
const hash = hash256.digest(p.readBytes(80));
|
||||
const entry = {};
|
||||
|
||||
|
||||
@ -2,16 +2,16 @@
|
||||
|
||||
const assert = require('assert');
|
||||
const bcoin = require('../');
|
||||
const bio = require('bufio');
|
||||
const walletdb = require('../lib/wallet/walletdb');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const Path = require('../lib/wallet/path');
|
||||
const MasterKey = require('../lib/wallet/masterkey');
|
||||
const Account = require('../lib/wallet/account');
|
||||
const Wallet = require('../lib/wallet/wallet');
|
||||
const KeyRing = require('../lib/primitives/keyring');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const BufferWriter = require('bufio/lib/writer');
|
||||
const layout = walletdb.layout;
|
||||
const {encoding} = bio;
|
||||
|
||||
let file = process.argv[2];
|
||||
let batch;
|
||||
|
||||
@ -188,7 +188,7 @@ async function updateTXMap() {
|
||||
|
||||
function pathFromRaw(data) {
|
||||
const path = {};
|
||||
const p = new BufferReader(data);
|
||||
const p = bio.read(data);
|
||||
|
||||
path.wid = p.readU32();
|
||||
path.name = p.readVarString('utf8');
|
||||
@ -221,7 +221,7 @@ function pathFromRaw(data) {
|
||||
}
|
||||
|
||||
function parsePaths(data, hash) {
|
||||
const p = new BufferReader(data);
|
||||
const p = bio.read(data);
|
||||
const out = {};
|
||||
|
||||
while (p.left()) {
|
||||
@ -235,7 +235,7 @@ function parsePaths(data, hash) {
|
||||
}
|
||||
|
||||
function parseWallets(data) {
|
||||
const p = new BufferReader(data);
|
||||
const p = bio.read(data);
|
||||
const wallets = [];
|
||||
while (p.left())
|
||||
wallets.push(p.readU32());
|
||||
@ -243,7 +243,7 @@ function parseWallets(data) {
|
||||
}
|
||||
|
||||
function serializeWallets(wallets) {
|
||||
const p = new BufferWriter();
|
||||
const p = bio.write();
|
||||
|
||||
for (let i = 0; i < wallets.length; i++) {
|
||||
const wid = wallets[i];
|
||||
@ -262,7 +262,7 @@ function readAccountKey(key) {
|
||||
|
||||
function accountFromRaw(data, dbkey) {
|
||||
const account = {};
|
||||
const p = new BufferReader(data);
|
||||
const p = bio.read(data);
|
||||
|
||||
dbkey = readAccountKey(dbkey);
|
||||
account.wid = dbkey.wid;
|
||||
@ -302,7 +302,7 @@ function accountFromRaw(data, dbkey) {
|
||||
|
||||
function walletFromRaw(data) {
|
||||
const wallet = {};
|
||||
const p = new BufferReader(data);
|
||||
const p = bio.read(data);
|
||||
|
||||
wallet.network = bcoin.network.fromMagic(p.readU32());
|
||||
wallet.wid = p.readU32();
|
||||
@ -327,7 +327,7 @@ function walletFromRaw(data) {
|
||||
|
||||
function keyFromRaw(data, network) {
|
||||
const ring = {};
|
||||
const p = new BufferReader(data);
|
||||
const p = bio.read(data);
|
||||
|
||||
ring.witness = p.readU8() === 1;
|
||||
|
||||
|
||||
@ -2,11 +2,12 @@
|
||||
|
||||
const assert = require('assert');
|
||||
const bcoin = require('../');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const bio = require('bufio');
|
||||
const WalletDB = require('../lib/wallet/walletdb');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const TX = require('../lib/primitives/tx');
|
||||
const Coin = require('../lib/primitives/coin');
|
||||
const {encoding} = bio;
|
||||
|
||||
let file = process.argv[2];
|
||||
let batch;
|
||||
|
||||
|
||||
@ -2,9 +2,9 @@
|
||||
|
||||
const assert = require('assert');
|
||||
const bcoin = require('../');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const BufferWriter = require('bufio/lib/writer');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const bio = require('bufio');
|
||||
const {encoding} = bio;
|
||||
|
||||
let file = process.argv[2];
|
||||
let batch;
|
||||
|
||||
@ -121,7 +121,7 @@ async function patchPathMaps() {
|
||||
}
|
||||
|
||||
function parseWallets(data) {
|
||||
const p = new BufferReader(data);
|
||||
const p = bio.read(data);
|
||||
const wids = [];
|
||||
|
||||
while (p.left())
|
||||
@ -131,7 +131,7 @@ function parseWallets(data) {
|
||||
}
|
||||
|
||||
function serializeWallets(wids) {
|
||||
const p = new BufferWriter();
|
||||
const p = bio.write();
|
||||
|
||||
p.writeU32(wids.length);
|
||||
|
||||
@ -144,7 +144,7 @@ function serializeWallets(wids) {
|
||||
}
|
||||
|
||||
function accountToRaw(account) {
|
||||
const p = new BufferWriter();
|
||||
const p = bio.write();
|
||||
|
||||
p.writeVarString(account.name, 'ascii');
|
||||
p.writeU8(account.initialized ? 1 : 0);
|
||||
@ -170,7 +170,7 @@ function accountToRaw(account) {
|
||||
|
||||
function accountFromRaw(data) {
|
||||
const account = {};
|
||||
const p = new BufferReader(data);
|
||||
const p = bio.read(data);
|
||||
|
||||
account.name = p.readVarString('ascii');
|
||||
account.initialized = p.readU8() === 1;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const consensus = require('../lib/protocol/consensus');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const {encoding} = require('bufio');
|
||||
const TX = require('../lib/primitives/tx');
|
||||
const Block = require('../lib/primitives/block');
|
||||
const Script = require('../lib/script/script');
|
||||
|
||||
@ -10,7 +10,7 @@ const Block = require('../lib/primitives/block');
|
||||
const MerkleBlock = require('../lib/primitives/merkleblock');
|
||||
const consensus = require('../lib/protocol/consensus');
|
||||
const Script = require('../lib/script/script');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const {encoding} = require('bufio');
|
||||
const bip152 = require('../lib/net/bip152');
|
||||
const CompactBlock = bip152.CompactBlock;
|
||||
const TXRequest = bip152.TXRequest;
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
|
||||
const assert = require('./util/assert');
|
||||
const consensus = require('../lib/protocol/consensus');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const {encoding} = require('bufio');
|
||||
const Coin = require('../lib/primitives/coin');
|
||||
const Script = require('../lib/script/script');
|
||||
const Chain = require('../lib/blockchain/chain');
|
||||
@ -19,6 +19,9 @@ const common = require('../lib/blockchain/common');
|
||||
const Opcode = require('../lib/script/opcode');
|
||||
const opcodes = Script.opcodes;
|
||||
|
||||
const ONE_HASH = Buffer.alloc(32, 0x00);
|
||||
ONE_HASH[0] = 0x01;
|
||||
|
||||
const network = Network.get('regtest');
|
||||
|
||||
const workers = new WorkerPool({
|
||||
@ -555,7 +558,7 @@ describe('Chain', function() {
|
||||
const block = await cpu.mineBlock();
|
||||
const tx = block.txs[0];
|
||||
const input = tx.inputs[0];
|
||||
input.witness.set(0, encoding.ONE_HASH);
|
||||
input.witness.set(0, ONE_HASH);
|
||||
block.refresh(true);
|
||||
assert.strictEqual(await addBlock(block), 'bad-witness-merkle-match');
|
||||
});
|
||||
|
||||
@ -3,14 +3,13 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const bio = require('bufio');
|
||||
const assert = require('./util/assert');
|
||||
const Output = require('../lib/primitives/output');
|
||||
const Input = require('../lib/primitives/input');
|
||||
const Outpoint = require('../lib/primitives/outpoint');
|
||||
const CoinView = require('../lib/coins/coinview');
|
||||
const CoinEntry = require('../lib/coins/coinentry');
|
||||
const StaticWriter = require('bufio/lib/staticwriter');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const common = require('./util/common');
|
||||
|
||||
const tx1 = common.readTX('tx1');
|
||||
@ -88,9 +87,9 @@ describe('Coins', function() {
|
||||
const [tx, view] = tx1.getTX();
|
||||
|
||||
const size = view.getSize(tx);
|
||||
const bw = new StaticWriter(size);
|
||||
const bw = bio.write(size);
|
||||
const raw = view.toWriter(bw, tx).render();
|
||||
const br = new BufferReader(raw);
|
||||
const br = bio.read(raw);
|
||||
const res = CoinView.fromReader(br, tx);
|
||||
|
||||
const prev = tx.inputs[0].prevout;
|
||||
|
||||
@ -3,9 +3,9 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const {encoding} = require('bufio');
|
||||
const assert = require('./util/assert');
|
||||
const consensus = require('../lib/protocol/consensus');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const Address = require('../lib/primitives/address');
|
||||
const Script = require('../lib/script/script');
|
||||
const Outpoint = require('../lib/primitives/outpoint');
|
||||
|
||||
@ -3,11 +3,11 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const bio = require('bufio');
|
||||
const Input = require('../lib/primitives/input');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const assert = require('./util/assert');
|
||||
const common = require('./util/common');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const {encoding} = bio;
|
||||
|
||||
// Take input rawbytes from the raw data format
|
||||
// p2pkh
|
||||
@ -37,7 +37,7 @@ describe('Input', function() {
|
||||
it('should return same raw on fromReader', () => {
|
||||
[input1, input2, input3].forEach((rawinput) => {
|
||||
const raw = rawinput.slice();
|
||||
const input = Input.fromReader(new BufferReader(raw));
|
||||
const input = Input.fromReader(bio.read(raw));
|
||||
|
||||
assert.bufferEqual(raw, input.toRaw());
|
||||
});
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('./util/assert');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const {encoding} = require('bufio');
|
||||
const random = require('bcrypto/lib/random');
|
||||
const MempoolEntry = require('../lib/mempool/mempoolentry');
|
||||
const Mempool = require('../lib/mempool/mempool');
|
||||
@ -20,6 +20,9 @@ const Witness = require('../lib/script/witness');
|
||||
const MemWallet = require('./util/memwallet');
|
||||
const ALL = Script.hashType.ALL;
|
||||
|
||||
const ONE_HASH = Buffer.alloc(32, 0x00);
|
||||
ONE_HASH[0] = 0x01;
|
||||
|
||||
const workers = new WorkerPool({
|
||||
enabled: true
|
||||
});
|
||||
@ -79,7 +82,7 @@ describe('Mempool', function() {
|
||||
|
||||
const script = Script.fromPubkey(key.publicKey);
|
||||
|
||||
t1.addCoin(dummyInput(script, encoding.ONE_HASH.toString('hex')));
|
||||
t1.addCoin(dummyInput(script, ONE_HASH.toString('hex')));
|
||||
|
||||
const sig = t1.signature(0, script, 70000, key.privateKey, ALL, 0);
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ const Witness = require('../lib/script/witness');
|
||||
const Stack = require('../lib/script/stack');
|
||||
const Opcode = require('../lib/script/opcode');
|
||||
const TX = require('../lib/primitives/tx');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const {encoding} = require('bufio');
|
||||
const {fromFloat} = require('../lib/utils/fixed');
|
||||
|
||||
const scripts = require('./data/script-tests.json');
|
||||
|
||||
@ -4,8 +4,8 @@
|
||||
'use strict';
|
||||
|
||||
const {inspect} = require('util');
|
||||
const {encoding} = require('bufio');
|
||||
const assert = require('./util/assert');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const random = require('bcrypto/lib/random');
|
||||
const consensus = require('../lib/protocol/consensus');
|
||||
const TX = require('../lib/primitives/tx');
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
const assert = require('assert');
|
||||
const path = require('path');
|
||||
const fs = require('bfile');
|
||||
const bio = require('bufio');
|
||||
const Block = require('../../lib/primitives/block');
|
||||
const MerkleBlock = require('../../lib/primitives/merkleblock');
|
||||
const Headers = require('../../lib/primitives/headers');
|
||||
@ -10,8 +11,6 @@ const {CompactBlock} = require('../../lib/net/bip152');
|
||||
const TX = require('../../lib/primitives/tx');
|
||||
const Output = require('../../lib/primitives/output');
|
||||
const CoinView = require('../../lib/coins/coinview');
|
||||
const BufferReader = require('bufio/lib/reader');
|
||||
const BufferWriter = require('bufio/lib/writer');
|
||||
|
||||
const common = exports;
|
||||
|
||||
@ -87,7 +86,7 @@ common.writeTX = function writeTX(name, tx, view) {
|
||||
};
|
||||
|
||||
function parseUndo(data) {
|
||||
const br = new BufferReader(data);
|
||||
const br = bio.read(data);
|
||||
const items = [];
|
||||
|
||||
while (br.left()) {
|
||||
@ -99,7 +98,7 @@ function parseUndo(data) {
|
||||
}
|
||||
|
||||
function serializeUndo(items) {
|
||||
const bw = new BufferWriter();
|
||||
const bw = bio.write();
|
||||
|
||||
for (const item of items) {
|
||||
bw.writeI64(item.value);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
const {U64, I64} = require('n64');
|
||||
const Validator = require('bval');
|
||||
const {base58} = require('bstring');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const {encoding} = require('bufio');
|
||||
const assert = require('./util/assert');
|
||||
const Amount = require('../lib/btc/amount');
|
||||
const fixed = require('../lib/utils/fixed');
|
||||
|
||||
@ -3,10 +3,10 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const {encoding} = require('bufio');
|
||||
const assert = require('./util/assert');
|
||||
const consensus = require('../lib/protocol/consensus');
|
||||
const util = require('../lib/utils/util');
|
||||
const encoding = require('bufio/lib/encoding');
|
||||
const hash256 = require('bcrypto/lib/hash256');
|
||||
const random = require('bcrypto/lib/random');
|
||||
const WalletDB = require('../lib/wallet/walletdb');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user