Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove wif #82

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
725 changes: 340 additions & 385 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
"dependencies": {
"@noble/hashes": "^1.2.0",
"@scure/base": "^1.1.1",
"typeforce": "^1.11.5",
"wif": "^2.0.6"
"typeforce": "^1.11.5"
},
"devDependencies": {
"@types/node": "18.x",
Expand Down
6 changes: 0 additions & 6 deletions src/bip32.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const testecc_1 = require("./testecc");
const base_1 = require("@scure/base");
const sha256_1 = require("@noble/hashes/sha256");
const typeforce = require('typeforce');
const wif = require('wif');
const _bs58check = (0, base_1.base58check)(sha256_1.sha256);
const bs58check = {
encode: (data) => _bs58check.encode(Uint8Array.from(data)),
Expand Down Expand Up @@ -162,11 +161,6 @@ function BIP32Factory(ecc) {
}
return bs58check.encode(buffer);
}
toWIF() {
if (!this.privateKey)
throw new TypeError('Missing private key');
return wif.encode(this.network.wif, this.privateKey, true);
}
// https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#child-key-derivation-ckd-functions
derive(index) {
typeforce(typeforce.UInt32, index);
Expand Down
2 changes: 0 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ function verify (t, hd, prv, f, network) {
t.equal(hd.publicKey.toString('hex'), f.pubKey)
if (prv) t.equal(hd.toBase58(), f.base58Priv)
if (prv) t.equal(hd.privateKey.toString('hex'), f.privKey)
if (prv) t.equal(hd.toWIF(), f.wif)
if (!prv) t.throws(() => hd.toWIF(), /Missing private key/)
if (!prv) t.equal(hd.privateKey, undefined)
t.equal(hd.neutered().toBase58(), f.base58)
t.equal(hd.isNeutered(), !prv)
Expand Down
7 changes: 0 additions & 7 deletions ts-src/bip32.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { testEcc } from './testecc';
import { base58check } from '@scure/base';
import { sha256 } from '@noble/hashes/sha256';
const typeforce = require('typeforce');
const wif = require('wif');
const _bs58check = base58check(sha256);
const bs58check = {
encode: (data: Buffer): string => _bs58check.encode(Uint8Array.from(data)),
Expand Down Expand Up @@ -41,7 +40,6 @@ export interface BIP32Interface extends Signer {
isNeutered(): boolean;
neutered(): BIP32Interface;
toBase58(): string;
toWIF(): string;
derive(index: number): BIP32Interface;
deriveHardened(index: number): BIP32Interface;
derivePath(path: string): BIP32Interface;
Expand Down Expand Up @@ -283,11 +281,6 @@ export function BIP32Factory(ecc: TinySecp256k1Interface): BIP32API {
return bs58check.encode(buffer);
}

toWIF(): string {
if (!this.privateKey) throw new TypeError('Missing private key');
return wif.encode(this.network.wif, this.privateKey, true);
}

// https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#child-key-derivation-ckd-functions
derive(index: number): BIP32Interface {
typeforce(typeforce.UInt32, index);
Expand Down
1 change: 0 additions & 1 deletion types/bip32.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export interface BIP32Interface extends Signer {
isNeutered(): boolean;
neutered(): BIP32Interface;
toBase58(): string;
toWIF(): string;
derive(index: number): BIP32Interface;
deriveHardened(index: number): BIP32Interface;
derivePath(path: string): BIP32Interface;
Expand Down
Loading