Commit 4dae08ea authored by kenshin-samourai's avatar kenshin-samourai
Browse files

rewrite require directives

parent bb682ec6
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const bitcoinjs = require('bitcoinjs-lib'); const { networks, payments } = require('bitcoinjs-lib');
const bip32 = require('bip32'); const { p2pkh } = payments;
const bs58check = require('bs58check'); const { fromPublicKey } = require('bip32');
const p2pkh = bitcoinjs.payments.p2pkh; const { encode, decode } = require('bs58check');
const networks = bitcoinjs.networks;
const PC_VERSION = 0x47; const PC_VERSION = 0x47;
...@@ -23,7 +22,7 @@ class PaymentCode { ...@@ -23,7 +22,7 @@ class PaymentCode {
this.buf = buf; this.buf = buf;
this.network = network; this.network = network;
this.root = bip32.fromPublicKey(this.pubKey, this.chainCode, this.network); this.root = fromPublicKey(this.pubKey, this.chainCode, this.network);
} }
get features() { get features() {
...@@ -45,7 +44,7 @@ class PaymentCode { ...@@ -45,7 +44,7 @@ class PaymentCode {
toBase58() { toBase58() {
const version = Buffer.from([PC_VERSION]); const version = Buffer.from([PC_VERSION]);
const buf = Buffer.concat([version, this.buf]); const buf = Buffer.concat([version, this.buf]);
return bs58check.encode(buf); return encode(buf);
} }
derive(index) { derive(index) {
...@@ -67,7 +66,7 @@ class PaymentCode { ...@@ -67,7 +66,7 @@ class PaymentCode {
function fromBase58(inString, network) { function fromBase58(inString, network) {
const buf = bs58check.decode(inString); const buf = decode(inString);
const version = buf.slice(0, 1); const version = buf.slice(0, 1);
if (version[0] !== PC_VERSION) if (version[0] !== PC_VERSION)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment