Commit a5077b76 authored by kenshin-samourai's avatar kenshin-samourai
Browse files

Merge branch 'develop' into 'master'

merge develop into master for v0.2.0

See merge request !2
parents 91a848a8 bb95a471
......@@ -18,9 +18,8 @@ const notifAddr = pcode.getNotificationAddress();
### Testnet
```
const bitcoinjs = require('bitcoinjs-lib');
const bip47 = require('bip47-js');
const networks = bitcoinjs.networks;
const networks = bip47.utils.networks;
const b58PCode = 'PM8TJTLJbPRGxSbc8EJi42Wrr6QbNSaSSVJ5Y3E4pbCYiTHUskHg13935Ubb7q8tx9GVbh2UuRnBc3WSyJHhUrw8KhprKnn9eDznYGieTzFcwQRya4GA';
......
{
"name": "bip47-js",
"version": "0.1.0",
"version": "0.2.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......@@ -60,14 +60,9 @@
"resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.8.tgz",
"integrity": "sha512-Rl/1AWP4J/zRrk54hhlxH4drNxPJXYUaKffODVI53/dAsV4t9fBxyxYKAVPU1XBHxYwOWP9h9H0hM2MVw4YfJA==",
"requires": {
"safe-buffer": "5.2.1"
"safe-buffer": "5.2.0"
}
},
"bech32": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/bech32/-/bech32-1.1.4.tgz",
"integrity": "sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ=="
},
"binary-extensions": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.1.0.tgz",
......@@ -82,11 +77,6 @@
"file-uri-to-path": "1.0.0"
}
},
"bip174": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/bip174/-/bip174-1.0.1.tgz",
"integrity": "sha512-Mq2aFs1TdMfxBpYPg7uzjhsiXbAtoVq44TNjEWtvuZBiBgc3m7+n55orYMtTAxdg7jWbL4DtH0MKocJER4xERQ=="
},
"bip32": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/bip32/-/bip32-2.0.6.tgz",
......@@ -101,42 +91,6 @@
"wif": "2.0.6"
}
},
"bip66": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/bip66/-/bip66-1.1.5.tgz",
"integrity": "sha1-AfqHSHhcpwlV1QESF9GzE5lpyiI=",
"requires": {
"safe-buffer": "5.2.1"
}
},
"bitcoin-ops": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/bitcoin-ops/-/bitcoin-ops-1.4.1.tgz",
"integrity": "sha512-pef6gxZFztEhaE9RY9HmWVmiIHqCb2OyS4HPKkpc6CIiiOa3Qmuoylxc5P2EkU3w+5eTSifI9SEZC88idAIGow=="
},
"bitcoinjs-lib": {
"version": "5.1.4",
"resolved": "https://registry.npmjs.org/bitcoinjs-lib/-/bitcoinjs-lib-5.1.4.tgz",
"integrity": "sha512-tSgxnXC3xEXw5DxKGIHNkzz+pxYzsSViT/XfQVIn8vM/b5kXtg3BJuFg6T1h2zhgG+iClzDf+5S/5wxFIddzWg==",
"requires": {
"@types/node": "10.12.18",
"bech32": "1.1.4",
"bip174": "1.0.1",
"bip32": "2.0.6",
"bip66": "1.1.5",
"bitcoin-ops": "1.4.1",
"bs58check": "2.1.2",
"create-hash": "1.2.0",
"create-hmac": "1.1.7",
"merkle-lib": "2.0.10",
"pushdata-bitcoin": "1.0.1",
"randombytes": "2.1.0",
"tiny-secp256k1": "1.1.6",
"typeforce": "1.18.0",
"varuint-bitcoin": "1.1.2",
"wif": "2.0.6"
}
},
"bn.js": {
"version": "4.11.9",
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.9.tgz",
......@@ -187,7 +141,7 @@
"requires": {
"bs58": "4.0.1",
"create-hash": "1.2.0",
"safe-buffer": "5.2.1"
"safe-buffer": "5.2.0"
}
},
"call-bind": {
......@@ -250,7 +204,7 @@
"integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==",
"requires": {
"inherits": "2.0.4",
"safe-buffer": "5.2.1"
"safe-buffer": "5.2.0"
}
},
"cliui": {
......@@ -334,7 +288,7 @@
"create-hash": "1.2.0",
"inherits": "2.0.4",
"ripemd160": "2.0.2",
"safe-buffer": "5.2.1",
"safe-buffer": "5.2.0",
"sha.js": "2.4.11"
}
},
......@@ -570,7 +524,7 @@
"requires": {
"inherits": "2.0.4",
"readable-stream": "3.6.0",
"safe-buffer": "5.2.1"
"safe-buffer": "5.2.0"
}
},
"hash.js": {
......@@ -739,14 +693,9 @@
"requires": {
"hash-base": "3.1.0",
"inherits": "2.0.4",
"safe-buffer": "5.2.1"
"safe-buffer": "5.2.0"
}
},
"merkle-lib": {
"version": "2.0.10",
"resolved": "https://registry.npmjs.org/merkle-lib/-/merkle-lib-2.0.10.tgz",
"integrity": "sha1-grjbrnXieneFOItz+ddyXQ9vMyY="
},
"minimalistic-assert": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz",
......@@ -926,22 +875,6 @@
"integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==",
"dev": true
},
"pushdata-bitcoin": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/pushdata-bitcoin/-/pushdata-bitcoin-1.0.1.tgz",
"integrity": "sha1-FZMdPNlnreUiBvUjqnMxrvfUOvc=",
"requires": {
"bitcoin-ops": "1.4.1"
}
},
"randombytes": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",
"integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==",
"requires": {
"safe-buffer": "5.2.1"
}
},
"readable-stream": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
......@@ -983,9 +916,9 @@
}
},
"safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.0.tgz",
"integrity": "sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg=="
},
"semver": {
"version": "5.7.1",
......@@ -1005,7 +938,7 @@
"integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==",
"requires": {
"inherits": "2.0.4",
"safe-buffer": "5.2.1"
"safe-buffer": "5.2.0"
}
},
"sprintf-js": {
......@@ -1049,7 +982,7 @@
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
"integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==",
"requires": {
"safe-buffer": "5.2.1"
"safe-buffer": "5.2.0"
}
},
"strip-ansi": {
......@@ -1107,14 +1040,6 @@
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
},
"varuint-bitcoin": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/varuint-bitcoin/-/varuint-bitcoin-1.1.2.tgz",
"integrity": "sha512-4EVb+w4rx+YfVM32HQX42AbbT7/1f5zwAYhIujKXKk8NQK+JfRVl3pqT3hjNn/L+RstigmGGKVwHA/P0wgITZw==",
"requires": {
"safe-buffer": "5.2.1"
}
},
"which": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
......
{
"name": "bip47-js",
"version": "0.1.0",
"version": "0.2.0",
"description": "A set of utilities for working with BIP47 and bitcoinjs-lib",
"main": "src/index.js",
"scripts": {
......@@ -14,9 +14,10 @@
"license": "AGPL-3.0-only",
"homepage": "https://code.samourai.io/dojo/bip47-js",
"dependencies": {
"bitcoinjs-lib": "5.1.4",
"bip32": "2.0.6",
"bs58check": "2.1.2"
"bs58check": "2.1.2",
"create-hash": "1.2.0",
"safe-buffer": "5.2.0"
},
"devDependencies": {
"mocha": "^7.1.1"
......
......@@ -3,3 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
var bip47 = require("./payment-code");
exports.fromBuffer = bip47.fromBuffer;
exports.fromBase58 = bip47.fromBase58;
exports.utils = require('./utils');
\ No newline at end of file
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const { networks, payments } = require('bitcoinjs-lib');
const { p2pkh } = payments;
const { networks, getP2pkhAddress } = require('./utils');
const { fromPublicKey } = require('bip32');
const { encode, decode } = require('bs58check');
......@@ -57,10 +56,7 @@ class PaymentCode {
getNotificationAddress() {
const child = this.derive(0);
return p2pkh({
pubkey: child.publicKey,
network: this.network
}).address;
return getP2pkhAddress(child.publicKey, this.network);
}
}
......
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Buffer = require('safe-buffer').Buffer;
const createHash = require('create-hash');
const bs58check = require('bs58check');
exports.networks = {};
exports.networks.bitcoin = {
messagePrefix: '\x18Bitcoin Signed Message:\n',
bech32: 'bc',
bip32: {
public: 0x0488b21e,
private: 0x0488ade4,
},
pubKeyHash: 0x00,
scriptHash: 0x05,
wif: 0x80,
};
exports.networks.regtest = {
messagePrefix: '\x18Bitcoin Signed Message:\n',
bech32: 'bcrt',
bip32: {
public: 0x043587cf,
private: 0x04358394,
},
pubKeyHash: 0x6f,
scriptHash: 0xc4,
wif: 0xef,
};
exports.networks.testnet = {
messagePrefix: '\x18Bitcoin Signed Message:\n',
bech32: 'tb',
bip32: {
public: 0x043587cf,
private: 0x04358394,
},
pubKeyHash: 0x6f,
scriptHash: 0xc4,
wif: 0xef,
};
function ripemd160(buffer) {
return createHash('rmd160').update(buffer).digest();
}
exports.ripemd160 = ripemd160;
function sha256(buffer) {
return createHash('sha256').update(buffer).digest();
}
exports.sha256 = sha256;
function hash160(buffer) {
return ripemd160(sha256(buffer));
}
exports.hash160 = hash160;
function toBase58Check(hash, version) {
const payload = Buffer.allocUnsafe(21);
payload.writeUInt8(version, 0);
hash.copy(payload, 1);
return bs58check.encode(payload);
}
exports.toBase58Check = toBase58Check;
function getP2pkhAddress(pubkey, network) {
return toBase58Check(hash160(pubkey), network.pubKeyHash)
}
exports.getP2pkhAddress = getP2pkhAddress;
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