diff --git a/CHANGELOG.md b/CHANGELOG.md index 168c769..f8b923c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # Changelog -# 0.3.0 +# 0.3.2 + +- Migrate to PSBT for transaction creation +- Update bitcoinjs-lib to 5.2.0 +- Update bip174 to 2.0.1 + +# 0.3.1 - Remove Axios in favour of fetch for api calls. - Fix Metrix Signed Message length prefix \ No newline at end of file diff --git a/lib/Insight.d.ts b/lib/Insight.d.ts index 44260c1..eeebc2a 100644 --- a/lib/Insight.d.ts +++ b/lib/Insight.d.ts @@ -10,6 +10,7 @@ export declare class Insight { listUTXOs(address: string): Promise; getInfo(address: string): Promise; sendRawTx(rawtx: string): Promise; + GetRawTx(tx: string): Promise; contractCall(address: string, encodedData: string): Promise; /** * Estimate the fee per KB of txdata, in satoshi. Returns -1 if no estimate is @@ -42,6 +43,9 @@ export declare namespace Insight { interface ISendRawTxResult { txid: string; } + interface IGetRawTxResult { + rawtx: string; + } interface IUTXO { address: string; txid: string; @@ -55,6 +59,7 @@ export declare namespace Insight { isStake: boolean; height: number; confirmations: number; + rawtx: string; } interface IExecutionResult { gasUsed: number; diff --git a/lib/Insight.js b/lib/Insight.js index 39182d1..3e4ef64 100644 --- a/lib/Insight.js +++ b/lib/Insight.js @@ -72,6 +72,7 @@ class Insight { isStake: utxo.isStake, height: utxo.blockHeight, confirmations: utxo.confirmations, + rawtx: utxo.rawtx }); }); return result; @@ -124,6 +125,20 @@ class Insight { return res; }); } + GetRawTx(tx) { + return __awaiter(this, void 0, void 0, function* () { + const response = yield this.fetchApi(`/raw-tx/${tx}`, { + method: 'get', + headers: { "Content-Type": "application/json" } + }); + const res = yield response.json(); + console.log(res); + if (res.status === 0) { + return { rawtx: res.id }; + } + return res; + }); + } contractCall(address, encodedData) { return __awaiter(this, void 0, void 0, function* () { // FIXME wow, what a weird API design... maybe we should just host the RPC diff --git a/lib/Insight.js.map b/lib/Insight.js.map index 5e36cad..6ef947e 100644 --- a/lib/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AAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM;4BACnC,EAAE,EAAE,WAAW;4BACf,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO;4BACvC,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI;4BAChC,eAAe,EAAE,GAAG,CAAC,IAAI;4BACzB,gBAAgB,EAAE,GAAG,CAAC,WAAW;yBAClC,CAAC,CAAC;qBACF;oBAGH,MAAM,CAAC,IAAI,CAAC;wBACV,IAAI,EAAE,GAAG,CAAC,EAAE;wBACZ,OAAO,EAAE,GAAG,CAAC,OAAO;wBACpB,QAAQ,EAAE,GAAG,CAAC,QAAQ;wBACtB,OAAO,EAAE,SAAS;wBAClB,GAAG,EAAE,KAAK;wBACV,IAAI,EAAE,MAAM;wBACZ,aAAa,EAAE,GAAG,CAAC,aAAa;wBAChC,IAAI,EAAE,GAAG,CAAC,SAAS;wBACnB,QAAQ,EAAE,GAAG,CAAC,WAAW;wBACzB,OAAO,EAAE,GAAG,CAAC,UAAU;wBACvB,IAAI,EAAE,GAAG;wBACT,SAAS,EAAE,GAAG,CAAC,SAAS;wBACxB,WAAW,EAAE,GAAG,CAAC,WAAW;wBAC5B,eAAe,EAAE,OAAO;qBACzB,CAAC,CAAA;iBACH;aACF;YAED,OAAO,EAAC,UAAU,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,GAAG,MAAM,CAAC,EAA6B,CAAA;QAC1E,CAAC;KAAA;CACF;AArXD,0BAqXC"} \ No newline at end of file diff --git a/lib/Wallet.d.ts b/lib/Wallet.d.ts index dc724dd..713da02 100644 --- a/lib/Wallet.d.ts +++ b/lib/Wallet.d.ts @@ -1,15 +1,15 @@ -import * as bitcoin from "bitcoinjs-lib"; +import { ECPairInterface } from 'bitcoinjs-lib'; import { BIP32Interface } from "bip32"; import { INetworkInfo } from "./Network"; import { Insight } from "./Insight"; import { IUTXO, IContractSendTXOptions, ISendTxOptions, IContractCreateTXOptions } from "./tx"; import { IScryptParams } from "./scrypt"; export declare class Wallet { - keyPair: bitcoin.ECPair; + keyPair: ECPairInterface; network: INetworkInfo; address: string; private insight; - constructor(keyPair: bitcoin.ECPair, network: INetworkInfo); + constructor(keyPair: ECPairInterface, network: INetworkInfo); toWIF(): string; /** * Get basic information about the wallet address. diff --git a/lib/Wallet.js.map b/lib/Wallet.js.map index 4ec0217..4b36d22 100644 --- a/lib/Wallet.js.map +++ b/lib/Wallet.js.map @@ -1 +1 @@ -{"version":3,"file":"Wallet.js","sourceRoot":"","sources":["../src/Wallet.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA8B;AAC9B,yCAA0B;AAC1B,6DAA+C;AAC/C,uDAAwC;AAExC,kDAAgC;AAIhC,uCAAmC;AACnC,6BAUa;AAEb,qCAAgD;AAEhD;;;;GAIG;AACH,MAAM,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,CAAA;AAExD,MAAM,KAAK,GAAG,eAAY,CAAC,GAAG,CAAC,CAAA;AAE/B,MAAa,MAAM;IAIjB,YAAmB,OAAuB,EAAS,OAAqB;QAArD,YAAO,GAAP,OAAO,CAAgB;QAAS,YAAO,GAAP,OAAO,CAAc;QACtE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAC,MAAM,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,EAAC,CAAC,CAAC,OAAO,CAAA;QAC5F,IAAI,CAAC,OAAO,GAAG,iBAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;IAC5C,CAAC;IAEM,KAAK;QACV,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAA;IAC7B,CAAC;IAED;;OAEG;IACU,OAAO;;YAClB,OAAO,IAAI,C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AGG;IACI,iBAAiB,CAAC,CAAC,GAAG,CAAC;QAC5B,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAA;QAC3D,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;IACtE,CAAC;IAEY,cAAc,CACzB,IAAY,EACZ,OAAiC,EAAE;;YAEnC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,wBAAwB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;YAC7D,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;QAC9B,CAAC;KAAA;IAEY,wBAAwB,CACnC,IAAY,EACZ,OAAiC,EAAE;;YAEnC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAA;YAE5C,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAA;YAExE,sCAAsC;YAEtC,OAAO,mCAA8B,CACnC,KAAK,EACL,IAAI,CAAC,OAAO,EACZ,IAAI,EACJ,OAAO,EACP,IAAI,CACL,CAAA;QACH,CAAC;KAAA;CAKF;AA9SD,wBA8SC"} \ No newline at end of file diff --git a/lib/tx.d.ts b/lib/tx.d.ts index 2d1a9ef..428b0d3 100644 --- a/lib/tx.d.ts +++ b/lib/tx.d.ts @@ -1,4 +1,4 @@ -import { ECPair } from "bitcoinjs-lib"; +import { ECPairInterface } from "bitcoinjs-lib"; /** * Options for a payment transaction */ @@ -65,7 +65,7 @@ export declare function estimatePubKeyHashTransactionMaxSend(utxos: IUTXO[], to: * @param feeRate * @param utxoList */ -export declare function buildPubKeyHashTransaction(utxos: IUTXO[], keyPair: ECPair, to: string, amount: number, feeRate: number): string; +export declare function buildPubKeyHashTransaction(utxos: IUTXO[], keyPair: ECPairInterface, to: string, amount: number, feeRate: number): string; /** * Build a create-contract transaction * @@ -75,8 +75,8 @@ export declare function buildPubKeyHashTransaction(utxos: IUTXO[], keyPair: ECPa * @param utxoList * @returns the built tx */ -export declare function buildCreateContractTransaction(utxos: IUTXO[], keyPair: ECPair, code: string, feeRate: number, opts?: IContractCreateTXOptions): string; -export declare function estimateSendToContractTransactionMaxValue(utxos: IUTXO[], keyPair: ECPair, contractAddress: string, encodedData: string, feeRate: number, opts?: IContractSendTXOptions): number; +export declare function buildCreateContractTransaction(utxos: IUTXO[], keyPair: ECPairInterface, code: string, feeRate: number, opts?: IContractCreateTXOptions): string; +export declare function estimateSendToContractTransactionMaxValue(utxos: IUTXO[], keyPair: ECPairInterface, contractAddress: string, encodedData: string, feeRate: number, opts?: IContractSendTXOptions): number; /** * Build a send-to-contract transaction * @@ -87,4 +87,4 @@ export declare function estimateSendToContractTransactionMaxValue(utxos: IUTXO[] * @param utxoList * @returns the built tx */ -export declare function buildSendToContractTransaction(utxos: IUTXO[], keyPair: ECPair, contractAddress: string, encodedData: string, feeRate: number, opts?: IContractSendTXOptions): string; +export declare function buildSendToContractTransaction(utxos: IUTXO[], keyPair: ECPairInterface, contractAddress: string, encodedData: string, feeRate: number, opts?: IContractSendTXOptions): string; diff --git a/lib/tx.js b/lib/tx.js index e2758e8..49bcaae 100644 --- a/lib/tx.js +++ b/lib/tx.js @@ -21,6 +21,7 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); exports.buildSendToContractTransaction = exports.estimateSendToContractTransactionMaxValue = exports.buildCreateContractTransaction = exports.buildPubKeyHashTransaction = exports.estimatePubKeyHashTransactionMaxSend = void 0; const bitcoinjs_lib_1 = require("bitcoinjs-lib"); +const bitcoinjs_lib_2 = require("bitcoinjs-lib"); const script_number_1 = require("bitcoinjs-lib/src/script_number"); const bignumber_js_1 = require("bignumber.js"); const buffer_1 = require("buffer"); @@ -104,27 +105,33 @@ function buildPubKeyHashTransaction(utxos, keyPair, to, amount, feeRate) { if (inputs == null) { throw new Error("could not find UTXOs to build transaction"); } - const txb = new bitcoinjs_lib_1.TransactionBuilder(keyPair.network); + const txb = new bitcoinjs_lib_2.Psbt({ network: keyPair.network }); let vinSum = new bignumber_js_1.BigNumber(0); for (const input of inputs) { - txb.addInput(input.hash, input.pos); + txb.addInput({ + hash: input.hash, + index: input.pos, + nonWitnessUtxo: buffer_1.Buffer.from(input.rawtx, 'hex') + }); vinSum = vinSum.plus(input.value); } if (vinSum.isEqualTo(new bignumber_js_1.BigNumber(amount))) { amount = new bignumber_js_1.BigNumber(amount).minus(txfee).toNumber(); } - txb.addOutput(to, amount); + txb.addOutput({ address: to, value: amount }); const change = vinSum .minus(txfee) .minus(amount) .toNumber(); if (change > 0) { - txb.addOutput(senderAddress, change); + txb.addOutput({ address: senderAddress, value: change }); } for (let i = 0; i < inputs.length; i++) { - txb.sign(i, keyPair); + txb.signInput(i, keyPair); + txb.validateSignaturesOfInput(i); } - return txb.build().toHex(); + txb.finalizeAllInputs(); + return txb.extractTransaction(true).toHex(); } exports.buildPubKeyHashTransaction = buildPubKeyHashTransaction; /** @@ -154,25 +161,31 @@ function buildCreateContractTransaction(utxos, keyPair, code, feeRate, opts = {} if (inputs == null) { throw new Error("could not find UTXOs to build transaction"); } - const txb = new bitcoinjs_lib_1.TransactionBuilder(keyPair.network); + const txb = new bitcoinjs_lib_2.Psbt({ network: keyPair.network }); let totalValue = new bignumber_js_1.BigNumber(0); for (const input of inputs) { - txb.addInput(input.hash, input.pos); + txb.addInput({ + hash: input.hash, + index: input.pos, + nonWitnessUtxo: buffer_1.Buffer.from(input.rawtx, 'hex') + }); totalValue = totalValue.plus(input.value); } // create-contract output - txb.addOutput(createContractScript, 0); + txb.addOutput({ script: createContractScript, value: 0 }); const change = totalValue .minus(txfee) .minus(gasLimitFee) .toNumber(); if (change > 0) { - txb.addOutput(fromAddress, change); + txb.addOutput({ address: fromAddress, value: change }); } for (let i = 0; i < inputs.length; i++) { - txb.sign(i, keyPair); + txb.signInput(i, keyPair); + txb.validateSignaturesOfInput(i); } - return txb.build().toHex(); + txb.finalizeAllInputs(); + return txb.extractTransaction(true).toHex(); } exports.buildCreateContractTransaction = buildCreateContractTransaction; const defaultContractSendTxOptions = { @@ -230,7 +243,7 @@ function buildSendToContractTransaction(utxos, keyPair, contractAddress, encoded const gasPrice = opts.gasPrice || defaultContractSendTxOptions.gasPrice; const amount = opts.amount || defaultContractSendTxOptions.amount; ensureAmountInteger(amount); - const senderAddress = bitcoin.payments.p2pkh({ pubkey: keyPair.publicKey }).address; + const senderAddress = bitcoin.payments.p2pkh({ pubkey: keyPair.publicKey, network: keyPair.network }).address; // excess gas will refund in the coinstake tx of the mined block const gasLimitFee = new bignumber_js_1.BigNumber(gasLimit).times(gasPrice).toNumber(); const opcallScript = bitcoinjs_lib_1.script.compile([ @@ -246,15 +259,19 @@ function buildSendToContractTransaction(utxos, keyPair, contractAddress, encoded if (inputs == null) { throw new Error("could not find UTXOs to build transaction"); } - const txb = new bitcoinjs_lib_1.TransactionBuilder(keyPair.network); + const txb = new bitcoinjs_lib_2.Psbt({ network: keyPair.network }); // add inputs to txb let vinSum = new bignumber_js_1.BigNumber(0); for (const input of inputs) { - txb.addInput(input.hash, input.pos); + txb.addInput({ + hash: input.hash, + index: input.pos, + nonWitnessUtxo: buffer_1.Buffer.from(input.rawtx, 'hex') + }); vinSum = vinSum.plus(input.value); } // send-to-contract output - txb.addOutput(opcallScript, amount); + txb.addOutput({ script: opcallScript, value: amount }); // change output (in satoshi) const change = vinSum .minus(txfee) @@ -262,12 +279,14 @@ function buildSendToContractTransaction(utxos, keyPair, contractAddress, encoded .minus(amount) .toNumber(); if (change > 0) { - txb.addOutput(senderAddress, change); + txb.addOutput({ address: senderAddress, value: change }); } for (let i = 0; i < inputs.length; i++) { - txb.sign(i, keyPair); + txb.signInput(i, keyPair); + txb.validateSignaturesOfInput(i); } - return txb.build().toHex(); + txb.finalizeAllInputs(); + return txb.extractTransaction(true).toHex(); } exports.buildSendToContractTransaction = buildSendToContractTransaction; // The prevalent network fee is 10 per KB. If set to 100 times of norm, assume error. diff --git a/lib/tx.js.map b/lib/tx.js.map index 9214aa5..a1f40cb 100644 --- a/lib/tx.js.map +++ b/lib/tx.js.map @@ -1 +1 @@ -{"version":3,"file":"tx.js","sourceRoot":"","sources":["../src/tx.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,iDAA+E;AAE/E,mEAA4E;AAE5E,+CAAwC;AAExC,mCAA+B;AAE/B,uCAA+B;AAE/B,uDAAwC;AAwExC,SAAS,mBAAmB,CAAC,CAAS;IACpC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE;QACxB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,EAAE,CAAC,CAAA;KAChE;AACH,CAAC;AAED,SAAgB,oCAAoC,CAClD,KAAc,EACd,EAAU,EACV,OAAe;IAEf,IAAI,SAAS,GAAG,CAAC,CAAA;IACjB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,SAAS,IAAI,IAAI,CAAC,KAAK,CAAA;KACxB;IAED,OAAO,SAAS,GAAG,CAAC,EAAE;QACpB,IAAI,MAAM,GAAG,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QAElD,IAAI,MAAM,IAAI,IAAI,EAAE;YAClB,OAAO,SAAS,CAAA;SACjB;QAED,2BAA2B;QAC3B,SAAS,GAAG,SAAS,GAAG,OAAO,CAAA;KAChC;IAED,OAAO,CAAC,CAAA;AACV,CAAC;AAtBD,oFAsBC;AAED;;;;;;;;GAQG;AACF,SAAS,SAAS,CAAC,mBAAwB,EAAE,MAAc,EAAE,GAAW;IACvE,eAAe;IACf,IAAI,UAAU,GAAG,EAAE,CAAA;IACnB,IAAI,YAAY,GAAG,EAAE,CAAA;IACrB,KAAI,IAAI,CAAC,GA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,GAAG,CAAC,SAAS,CAAC,EAAC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,EAAC,CAAC,CAAA;KACvD;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACtC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,OAAO,CAAC,CAAA;QACzB,GAAG,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAA;KACjC;IACD,GAAG,CAAC,iBAAiB,EAAE,CAAC;IACxB,OAAO,GAAG,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC;AAC9C,CAAC;AArED,wEAqEC;AAED,qFAAqF;AACrF,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,CAAA;AAEvD,SAAS,YAAY,CAAC,OAAe;IACnC,IAAI,OAAO,GAAG,YAAY,EAAE;QAC1B,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAA;KACnE;AACH,CAAC"} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index d95585f..7f6ba89 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,14 +11,14 @@ "dependencies": { "@bitcoinerlab/secp256k1": "^1.1.1", "@types/bip38": "^2.0.1", - "@types/bitcoinjs-lib": "^4.0.1", "@types/secp256k1": "^4.0.2", "big.js": "^6.1.1", "bignumber.js": "^9.0.1", + "bip174": "^2.0.1", "bip32": "^4.0.0", "bip38": "^3.1.1", "bip39": "^3.0.3", - "bitcoinjs-lib": "^4.0.5", + "bitcoinjs-lib": "^5.2.0", "bs58check": "^2.1.2", "buffer": "^6.0.3", "coinselect": "^3.1.11", @@ -135,14 +135,6 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-9.4.6.tgz", "integrity": "sha512-CTUtLb6WqCCgp6P59QintjHWqzf4VL1uPA27bipLAPxFqrtK1gEYllePzTICGqQ8rYsCbpnsNypXjjDzGAAjEQ==" }, - "node_modules/@types/bitcoinjs-lib": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@types/bitcoinjs-lib/-/bitcoinjs-lib-4.0.1.tgz", - "integrity": "sha512-w5BzfIwdHhEB1kM4pA9AGYbS1U+YfA3DUJ6CSUZgp2DySECA47FH9J1wngLjkQaJHnRfLXoSAZrlPTK8rKmwXw==", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/chai": { "version": "4.2.16", "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.2.16.tgz", @@ -158,7 +150,8 @@ "node_modules/@types/node": { "version": "14.14.41", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.41.tgz", - "integrity": "sha512-dueRKfaJL4RTtSa7bWeTK1M+VH+Gns73oCgzvYfHZywRCoPSd8EkXBL0mZ9unPTveBn+D9phZBaxuzpwjWkW0g==" + "integrity": "sha512-dueRKfaJL4RTtSa7bWeTK1M+VH+Gns73oCgzvYfHZywRCoPSd8EkXBL0mZ9unPTveBn+D9phZBaxuzpwjWkW0g==", + "dev": true }, "node_modules/@types/node-fetch": { "version": "2.6.2", @@ -357,6 +350,14 @@ "file-uri-to-path": "1.0.0" } }, + "node_modules/bip174": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/bip174/-/bip174-2.0.1.tgz", + "integrity": "sha512-i3X26uKJOkDTAalYAp0Er+qGMDhrbbh2o93/xiPyAN2s25KrClSpe3VXo/7mNJoqA5qfko8rLS2l3RWZgYmjKQ==", + "engines": { + "node": ">=8.0.0" + } + }, "node_modules/bip32": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/bip32/-/bip32-4.0.0.tgz", @@ -435,12 +436,13 @@ "integrity": "sha512-pef6gxZFztEhaE9RY9HmWVmiIHqCb2OyS4HPKkpc6CIiiOa3Qmuoylxc5P2EkU3w+5eTSifI9SEZC88idAIGow==" }, "node_modules/bitcoinjs-lib": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/bitcoinjs-lib/-/bitcoinjs-lib-4.0.5.tgz", - "integrity": "sha512-gYs7K2hiY4Xb96J8AIF+Rx+hqbwjVlp5Zt6L6AnHOdzfe/2tODdmDxsEytnaxVCdhOUg0JnsGpl+KowBpGLxtA==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/bitcoinjs-lib/-/bitcoinjs-lib-5.2.0.tgz", + "integrity": "sha512-5DcLxGUDejgNBYcieMIUfjORtUeNWl828VWLHJGVKZCb4zIS1oOySTUr0LGmcqJBQgTBz3bGbRQla4FgrdQEIQ==", "dependencies": { "bech32": "^1.1.2", - "bip32": "^1.0.4", + "bip174": "^2.0.1", + "bip32": "^2.0.4", "bip66": "^1.1.0", "bitcoin-ops": "^1.4.0", "bs58check": "^2.0.0", @@ -449,8 +451,7 @@ "merkle-lib": "^2.0.10", "pushdata-bitcoin": "^1.0.1", "randombytes": "^2.0.1", - "safe-buffer": "^5.1.1", - "tiny-secp256k1": "^1.0.0", + "tiny-secp256k1": "^1.1.1", "typeforce": "^1.11.3", "varuint-bitcoin": "^1.0.4", "wif": "^2.0.1" @@ -459,15 +460,21 @@ "node": ">=8.0.0" } }, + "node_modules/bitcoinjs-lib/node_modules/@types/node": { + "version": "10.12.18", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz", + "integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==" + }, "node_modules/bitcoinjs-lib/node_modules/bip32": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/bip32/-/bip32-1.0.4.tgz", - "integrity": "sha512-8T21eLWylZETolyqCPgia+MNp+kY37zFr7PTFDTPObHeNi9JlfG4qGIh8WzerIJidtwoK+NsWq2I5i66YfHoIw==", + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/bip32/-/bip32-2.0.6.tgz", + "integrity": "sha512-HpV5OMLLGTjSVblmrtYRfFFKuQB+GArM0+XP8HGWfJ5vxYBqo+DesvJwOdC2WJ3bCkZShGf0QIfoIpeomVzVdA==", "dependencies": { + "@types/node": "10.12.18", "bs58check": "^2.1.1", "create-hash": "^1.2.0", "create-hmac": "^1.1.7", - "tiny-secp256k1": "^1.0.0", + "tiny-secp256k1": "^1.1.3", "typeforce": "^1.11.5", "wif": "^2.0.6" }, @@ -475,16 +482,6 @@ "node": ">=6.0.0" } }, - "node_modules/bitcoinjs-lib/node_modules/bs58check": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/bs58check/-/bs58check-2.1.2.tgz", - "integrity": "sha512-0TS1jicxdU09dwJMNZtVAfzPi6Q6QeN0pM1Fkzrjn+XYHvzMKPU3pHVpva+769iNVSfIYWf7LJ6WR+BuuMf8cA==", - "dependencies": { - "bs58": "^4.0.0", - "create-hash": "^1.1.0", - "safe-buffer": "^5.1.2" - } - }, "node_modules/bitcoinjs-lib/node_modules/tiny-secp256k1": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/tiny-secp256k1/-/tiny-secp256k1-1.1.6.tgz", @@ -2488,14 +2485,6 @@ } } }, - "@types/bitcoinjs-lib": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@types/bitcoinjs-lib/-/bitcoinjs-lib-4.0.1.tgz", - "integrity": "sha512-w5BzfIwdHhEB1kM4pA9AGYbS1U+YfA3DUJ6CSUZgp2DySECA47FH9J1wngLjkQaJHnRfLXoSAZrlPTK8rKmwXw==", - "requires": { - "@types/node": "*" - } - }, "@types/chai": { "version": "4.2.16", "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.2.16.tgz", @@ -2511,7 +2500,8 @@ "@types/node": { "version": "14.14.41", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.41.tgz", - "integrity": "sha512-dueRKfaJL4RTtSa7bWeTK1M+VH+Gns73oCgzvYfHZywRCoPSd8EkXBL0mZ9unPTveBn+D9phZBaxuzpwjWkW0g==" + "integrity": "sha512-dueRKfaJL4RTtSa7bWeTK1M+VH+Gns73oCgzvYfHZywRCoPSd8EkXBL0mZ9unPTveBn+D9phZBaxuzpwjWkW0g==", + "dev": true }, "@types/node-fetch": { "version": "2.6.2", @@ -2665,6 +2655,11 @@ "file-uri-to-path": "1.0.0" } }, + "bip174": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/bip174/-/bip174-2.0.1.tgz", + "integrity": "sha512-i3X26uKJOkDTAalYAp0Er+qGMDhrbbh2o93/xiPyAN2s25KrClSpe3VXo/7mNJoqA5qfko8rLS2l3RWZgYmjKQ==" + }, "bip32": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/bip32/-/bip32-4.0.0.tgz", @@ -2744,12 +2739,13 @@ "integrity": "sha512-pef6gxZFztEhaE9RY9HmWVmiIHqCb2OyS4HPKkpc6CIiiOa3Qmuoylxc5P2EkU3w+5eTSifI9SEZC88idAIGow==" }, "bitcoinjs-lib": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/bitcoinjs-lib/-/bitcoinjs-lib-4.0.5.tgz", - "integrity": "sha512-gYs7K2hiY4Xb96J8AIF+Rx+hqbwjVlp5Zt6L6AnHOdzfe/2tODdmDxsEytnaxVCdhOUg0JnsGpl+KowBpGLxtA==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/bitcoinjs-lib/-/bitcoinjs-lib-5.2.0.tgz", + "integrity": "sha512-5DcLxGUDejgNBYcieMIUfjORtUeNWl828VWLHJGVKZCb4zIS1oOySTUr0LGmcqJBQgTBz3bGbRQla4FgrdQEIQ==", "requires": { "bech32": "^1.1.2", - "bip32": "^1.0.4", + "bip174": "^2.0.1", + "bip32": "^2.0.4", "bip66": "^1.1.0", "bitcoin-ops": "^1.4.0", "bs58check": "^2.0.0", @@ -2758,36 +2754,31 @@ "merkle-lib": "^2.0.10", "pushdata-bitcoin": "^1.0.1", "randombytes": "^2.0.1", - "safe-buffer": "^5.1.1", - "tiny-secp256k1": "^1.0.0", + "tiny-secp256k1": "^1.1.1", "typeforce": "^1.11.3", "varuint-bitcoin": "^1.0.4", "wif": "^2.0.1" }, "dependencies": { + "@types/node": { + "version": "10.12.18", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz", + "integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==" + }, "bip32": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/bip32/-/bip32-1.0.4.tgz", - "integrity": "sha512-8T21eLWylZETolyqCPgia+MNp+kY37zFr7PTFDTPObHeNi9JlfG4qGIh8WzerIJidtwoK+NsWq2I5i66YfHoIw==", + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/bip32/-/bip32-2.0.6.tgz", + "integrity": "sha512-HpV5OMLLGTjSVblmrtYRfFFKuQB+GArM0+XP8HGWfJ5vxYBqo+DesvJwOdC2WJ3bCkZShGf0QIfoIpeomVzVdA==", "requires": { + "@types/node": "10.12.18", "bs58check": "^2.1.1", "create-hash": "^1.2.0", "create-hmac": "^1.1.7", - "tiny-secp256k1": "^1.0.0", + "tiny-secp256k1": "^1.1.3", "typeforce": "^1.11.5", "wif": "^2.0.6" } }, - "bs58check": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/bs58check/-/bs58check-2.1.2.tgz", - "integrity": "sha512-0TS1jicxdU09dwJMNZtVAfzPi6Q6QeN0pM1Fkzrjn+XYHvzMKPU3pHVpva+769iNVSfIYWf7LJ6WR+BuuMf8cA==", - "requires": { - "bs58": "^4.0.0", - "create-hash": "^1.1.0", - "safe-buffer": "^5.1.2" - } - }, "tiny-secp256k1": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/tiny-secp256k1/-/tiny-secp256k1-1.1.6.tgz", diff --git a/package.json b/package.json index f8ea4a7..a134440 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "metrixjs-wallet", - "version": "0.3.1", + "version": "0.3.2", "description": "A toolkit for building metrix light wallets", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -34,14 +34,14 @@ "dependencies": { "@bitcoinerlab/secp256k1": "^1.1.1", "@types/bip38": "^2.0.1", - "@types/bitcoinjs-lib": "^4.0.1", "@types/secp256k1": "^4.0.2", "big.js": "^6.1.1", "bignumber.js": "^9.0.1", + "bip174": "^2.0.1", "bip32": "^4.0.0", "bip38": "^3.1.1", "bip39": "^3.0.3", - "bitcoinjs-lib": "^4.0.5", + "bitcoinjs-lib": "^5.2.0", "bs58check": "^2.1.2", "buffer": "^6.0.3", "coinselect": "^3.1.11", diff --git a/src/Insight.ts b/src/Insight.ts index e25d80c..198af43 100644 --- a/src/Insight.ts +++ b/src/Insight.ts @@ -57,7 +57,7 @@ export class Insight { const res = await response.json(); let result: Insight.IUTXO[] = []; if(res.length > 0) { - res.forEach((utxo: {transactionId: string; outputIndex: number; scriptPubKey: string; value: string; isStake: boolean; blockHeight: number; confirmations: number }) => { + res.forEach((utxo: {transactionId: string; outputIndex: number; scriptPubKey: string; value: string; isStake: boolean; blockHeight: number; confirmations: number, rawtx: string }) => { result.push({ address: address, txid: utxo.transactionId, @@ -74,6 +74,7 @@ export class Insight { isStake: utxo.isStake, height: utxo.blockHeight, confirmations: utxo.confirmations, + rawtx: utxo.rawtx }) }); return result; @@ -128,6 +129,19 @@ export class Insight { return res } + public async GetRawTx(tx: string): Promise { + const response = await this.fetchApi(`/raw-tx/${tx}`, { + method: 'get', + headers: { "Content-Type": "application/json" } + }); + const res = await response.json(); + console.log(res); + if (res.status === 0) { + return {rawtx: res.id} + } + return res + } + public async contractCall( address: string, encodedData: string, @@ -380,6 +394,9 @@ export namespace Insight { txid: string } + export interface IGetRawTxResult { + rawtx: string + } export interface IUTXO { address: string txid: string @@ -396,6 +413,7 @@ export namespace Insight { isStake: boolean height: number confirmations: number + rawtx: string } export interface IExecutionResult { diff --git a/src/Wallet.ts b/src/Wallet.ts index eb6a7a9..43b3166 100644 --- a/src/Wallet.ts +++ b/src/Wallet.ts @@ -3,6 +3,8 @@ import * as wif from "wif" import * as ecc from '@bitcoinerlab/secp256k1'; import * as bitcoin from "bitcoinjs-lib" +import { ECPairInterface } from 'bitcoinjs-lib' + import BIP32Factory from 'bip32' import { BIP32Interface } from "bip32" @@ -35,8 +37,8 @@ export class Wallet { public address: string private insight: Insight - constructor(public keyPair: bitcoin.ECPair, public network: INetworkInfo) { - this.address = bitcoin.payments.p2pkh({pubkey: keyPair.publicKey, network: network}).address + constructor(public keyPair: ECPairInterface, public network: INetworkInfo) { + this.address = bitcoin.payments.p2pkh({pubkey: keyPair.publicKey, network: network}).address as string this.insight = Insight.forNetwork(network) } diff --git a/src/tx.ts b/src/tx.ts index 92caa9b..4e69284 100644 --- a/src/tx.ts +++ b/src/tx.ts @@ -1,4 +1,6 @@ -import { ECPair, TransactionBuilder, script as BTCScript } from "bitcoinjs-lib" +import { TransactionBuilder, script as BTCScript } from "bitcoinjs-lib" + +import { bip32, ECPair, ECPairInterface, networks, payments, Psbt, Signer, SignerAsync } from "bitcoinjs-lib" import { encode as encodeCScriptInt } from "bitcoinjs-lib/src/script_number" @@ -163,14 +165,14 @@ export function estimatePubKeyHashTransactionMaxSend( */ export function buildPubKeyHashTransaction( utxos: IUTXO[], - keyPair: ECPair, + keyPair: ECPairInterface, to: string, amount: number, feeRate: number, ) { ensureAmountInteger(amount) - const senderAddress = bitcoin.payments.p2pkh({pubkey: keyPair.publicKey, network: keyPair.network}).address + const senderAddress = bitcoin.payments.p2pkh({pubkey: keyPair.publicKey, network: keyPair.network}).address as string let {inputs, feeTotal: txfee} = selectTxs(utxos, amount, feeRate) @@ -178,11 +180,15 @@ export function buildPubKeyHashTransaction( throw new Error("could not find UTXOs to build transaction") } - const txb = new TransactionBuilder(keyPair.network) + const txb = new Psbt({network: keyPair.network}) let vinSum = new BigNumber(0) for (const input of inputs) { - txb.addInput(input.hash, input.pos) + txb.addInput({ + hash: input.hash, + index: input.pos, + nonWitnessUtxo: Buffer.from(input.rawtx, 'hex') + }) vinSum = vinSum.plus(input.value) } @@ -190,20 +196,22 @@ export function buildPubKeyHashTransaction( amount = new BigNumber(amount).minus(txfee).toNumber(); } - txb.addOutput(to, amount) + txb.addOutput({address: to, value: amount}) const change = vinSum .minus(txfee) .minus(amount) .toNumber() if (change > 0) { - txb.addOutput(senderAddress, change) + txb.addOutput({address: senderAddress, value: change}) } for (let i = 0; i < inputs.length; i++) { - txb.sign(i, keyPair) + txb.signInput(i, keyPair) + txb.validateSignaturesOfInput(i) } - return txb.build().toHex() + txb.finalizeAllInputs(); + return txb.extractTransaction(true).toHex() } /** @@ -217,7 +225,7 @@ export function buildPubKeyHashTransaction( */ export function buildCreateContractTransaction( utxos: IUTXO[], - keyPair: ECPair, + keyPair: ECPairInterface, code: string, feeRate: number, opts: IContractCreateTXOptions = {}, @@ -234,7 +242,7 @@ export function buildCreateContractTransaction( OPS.OP_CREATE, ]) - const fromAddress = bitcoin.payments.p2pkh({pubkey: keyPair.publicKey}).address + const fromAddress = bitcoin.payments.p2pkh({pubkey: keyPair.publicKey}).address as string const amount = 0 const amountTotal = new BigNumber(amount).plus(gasLimitFee).toNumber(); @@ -244,16 +252,20 @@ export function buildCreateContractTransaction( throw new Error("could not find UTXOs to build transaction") } - const txb = new TransactionBuilder(keyPair.network) + const txb = new Psbt({network: keyPair.network}) let totalValue = new BigNumber(0) for (const input of inputs) { - txb.addInput(input.hash, input.pos) + txb.addInput({ + hash: input.hash, + index: input.pos, + nonWitnessUtxo: Buffer.from(input.rawtx, 'hex') + }) totalValue = totalValue.plus(input.value) } // create-contract output - txb.addOutput(createContractScript, 0) + txb.addOutput({script: createContractScript, value: 0}) const change = totalValue .minus(txfee) @@ -261,14 +273,15 @@ export function buildCreateContractTransaction( .toNumber() if (change > 0) { - txb.addOutput(fromAddress, change) + txb.addOutput({address: fromAddress, value: change}) } for (let i = 0; i < inputs.length; i++) { - txb.sign(i, keyPair) + txb.signInput(i, keyPair) + txb.validateSignaturesOfInput(i) } - - return txb.build().toHex() + txb.finalizeAllInputs(); + return txb.extractTransaction(true).toHex(); } const defaultContractSendTxOptions = { @@ -282,7 +295,7 @@ const defaultContractSendTxOptions = { export function estimateSendToContractTransactionMaxValue( utxos: IUTXO[], - keyPair: ECPair, + keyPair: ECPairInterface, contractAddress: string, encodedData: string, feeRate: number, @@ -301,7 +314,7 @@ export function estimateSendToContractTransactionMaxValue( amount -= gasLimit * gasPrice ensureAmountInteger(amount) - const senderAddress = bitcoin.payments.p2pkh({pubkey: keyPair.publicKey}).address + const senderAddress = bitcoin.payments.p2pkh({pubkey: keyPair.publicKey}).address as string // excess gas will refund in the coinstake tx of the mined block const gasLimitFee = new BigNumber(gasLimit).times(gasPrice).toNumber() @@ -339,7 +352,7 @@ export function estimateSendToContractTransactionMaxValue( */ export function buildSendToContractTransaction( utxos: IUTXO[], - keyPair: ECPair, + keyPair: ECPairInterface, contractAddress: string, encodedData: string, feeRate: number, @@ -354,7 +367,7 @@ export function buildSendToContractTransaction( ensureAmountInteger(amount) - const senderAddress = bitcoin.payments.p2pkh({pubkey: keyPair.publicKey}).address + const senderAddress = bitcoin.payments.p2pkh({pubkey: keyPair.publicKey, network: keyPair.network}).address as string // excess gas will refund in the coinstake tx of the mined block const gasLimitFee = new BigNumber(gasLimit).times(gasPrice).toNumber() @@ -374,17 +387,21 @@ export function buildSendToContractTransaction( throw new Error("could not find UTXOs to build transaction") } - const txb = new TransactionBuilder(keyPair.network) + const txb = new Psbt({network: keyPair.network}) // add inputs to txb let vinSum = new BigNumber(0) for (const input of inputs) { - txb.addInput(input.hash, input.pos) + txb.addInput({ + hash: input.hash, + index: input.pos, + nonWitnessUtxo: Buffer.from(input.rawtx, 'hex') + }); vinSum = vinSum.plus(input.value) } // send-to-contract output - txb.addOutput(opcallScript, amount) + txb.addOutput({script: opcallScript, value: amount}) // change output (in satoshi) const change = vinSum @@ -393,14 +410,15 @@ export function buildSendToContractTransaction( .minus(amount) .toNumber() if (change > 0) { - txb.addOutput(senderAddress, change) + txb.addOutput({address: senderAddress, value: change}) } for (let i = 0; i < inputs.length; i++) { - txb.sign(i, keyPair) + txb.signInput(i, keyPair) + txb.validateSignaturesOfInput(i) } - - return txb.build().toHex() + txb.finalizeAllInputs(); + return txb.extractTransaction(true).toHex(); } // The prevalent network fee is 10 per KB. If set to 100 times of norm, assume error. diff --git a/yarn.lock b/yarn.lock index defd58f..b02f2f0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -59,13 +59,6 @@ dependencies: "@types/node" "*" -"@types/bitcoinjs-lib@^4.0.1": - "integrity" "sha512-w5BzfIwdHhEB1kM4pA9AGYbS1U+YfA3DUJ6CSUZgp2DySECA47FH9J1wngLjkQaJHnRfLXoSAZrlPTK8rKmwXw==" - "resolved" "https://registry.npmjs.org/@types/bitcoinjs-lib/-/bitcoinjs-lib-4.0.1.tgz" - "version" "4.0.1" - dependencies: - "@types/node" "*" - "@types/chai@^4.2.16": "integrity" "sha512-vI5iOAsez9+roLS3M3+Xx7w+WRuDtSmF8bQkrbcIJ2sC1PcDgVoA0WGpa+bIrJ+y8zqY2oi//fUctkxtIcXJCw==" "resolved" "https://registry.npmjs.org/@types/chai/-/chai-4.2.16.tgz" @@ -84,11 +77,21 @@ "@types/node" "*" "form-data" "^3.0.0" -"@types/node@*", "@types/node@^14.14.41": +"@types/node@*": + "integrity" "sha512-CTUtLb6WqCCgp6P59QintjHWqzf4VL1uPA27bipLAPxFqrtK1gEYllePzTICGqQ8rYsCbpnsNypXjjDzGAAjEQ==" + "resolved" "https://registry.npmjs.org/@types/node/-/node-9.4.6.tgz" + "version" "9.4.6" + +"@types/node@^14.14.41": "integrity" "sha512-dueRKfaJL4RTtSa7bWeTK1M+VH+Gns73oCgzvYfHZywRCoPSd8EkXBL0mZ9unPTveBn+D9phZBaxuzpwjWkW0g==" "resolved" "https://registry.npmjs.org/@types/node/-/node-14.14.41.tgz" "version" "14.14.41" +"@types/node@10.12.18": + "integrity" "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==" + "resolved" "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz" + "version" "10.12.18" + "@types/node@11.11.6": "integrity" "sha512-Exw4yUWMBXM3X+8oqzJNRqZSwUAaS4+7NdvHqQuFi/d+synz++xmX3QIf+BFqneW8N31R8Ky+sikfZUXq07ggQ==" "resolved" "https://registry.npmjs.org/@types/node/-/node-11.11.6.tgz" @@ -214,15 +217,21 @@ dependencies: "file-uri-to-path" "1.0.0" -"bip32@^1.0.4": - "integrity" "sha512-8T21eLWylZETolyqCPgia+MNp+kY37zFr7PTFDTPObHeNi9JlfG4qGIh8WzerIJidtwoK+NsWq2I5i66YfHoIw==" - "resolved" "https://registry.npmjs.org/bip32/-/bip32-1.0.4.tgz" - "version" "1.0.4" +"bip174@^2.0.1": + "integrity" "sha512-i3X26uKJOkDTAalYAp0Er+qGMDhrbbh2o93/xiPyAN2s25KrClSpe3VXo/7mNJoqA5qfko8rLS2l3RWZgYmjKQ==" + "resolved" "https://registry.npmjs.org/bip174/-/bip174-2.0.1.tgz" + "version" "2.0.1" + +"bip32@^2.0.4": + "integrity" "sha512-HpV5OMLLGTjSVblmrtYRfFFKuQB+GArM0+XP8HGWfJ5vxYBqo+DesvJwOdC2WJ3bCkZShGf0QIfoIpeomVzVdA==" + "resolved" "https://registry.npmjs.org/bip32/-/bip32-2.0.6.tgz" + "version" "2.0.6" dependencies: + "@types/node" "10.12.18" "bs58check" "^2.1.1" "create-hash" "^1.2.0" "create-hmac" "^1.1.7" - "tiny-secp256k1" "^1.0.0" + "tiny-secp256k1" "^1.1.3" "typeforce" "^1.11.5" "wif" "^2.0.6" @@ -272,13 +281,14 @@ "resolved" "https://registry.npmjs.org/bitcoin-ops/-/bitcoin-ops-1.4.1.tgz" "version" "1.4.1" -"bitcoinjs-lib@^4.0.5": - "integrity" "sha512-gYs7K2hiY4Xb96J8AIF+Rx+hqbwjVlp5Zt6L6AnHOdzfe/2tODdmDxsEytnaxVCdhOUg0JnsGpl+KowBpGLxtA==" - "resolved" "https://registry.npmjs.org/bitcoinjs-lib/-/bitcoinjs-lib-4.0.5.tgz" - "version" "4.0.5" +"bitcoinjs-lib@^5.2.0": + "integrity" "sha512-5DcLxGUDejgNBYcieMIUfjORtUeNWl828VWLHJGVKZCb4zIS1oOySTUr0LGmcqJBQgTBz3bGbRQla4FgrdQEIQ==" + "resolved" "https://registry.npmjs.org/bitcoinjs-lib/-/bitcoinjs-lib-5.2.0.tgz" + "version" "5.2.0" dependencies: "bech32" "^1.1.2" - "bip32" "^1.0.4" + "bip174" "^2.0.1" + "bip32" "^2.0.4" "bip66" "^1.1.0" "bitcoin-ops" "^1.4.0" "bs58check" "^2.0.0" @@ -287,8 +297,7 @@ "merkle-lib" "^2.0.10" "pushdata-bitcoin" "^1.0.1" "randombytes" "^2.0.1" - "safe-buffer" "^5.1.1" - "tiny-secp256k1" "^1.0.0" + "tiny-secp256k1" "^1.1.1" "typeforce" "^1.11.3" "varuint-bitcoin" "^1.0.4" "wif" "^2.0.1" @@ -342,16 +351,7 @@ dependencies: "base-x" "^3.0.2" -"bs58check@^2.0.0", "bs58check@^2.1.1": - "integrity" "sha512-0TS1jicxdU09dwJMNZtVAfzPi6Q6QeN0pM1Fkzrjn+XYHvzMKPU3pHVpva+769iNVSfIYWf7LJ6WR+BuuMf8cA==" - "resolved" "https://registry.npmjs.org/bs58check/-/bs58check-2.1.2.tgz" - "version" "2.1.2" - dependencies: - "bs58" "^4.0.0" - "create-hash" "^1.1.0" - "safe-buffer" "^5.1.2" - -"bs58check@^2.1.2": +"bs58check@^2.0.0", "bs58check@^2.1.1", "bs58check@^2.1.2": "integrity" "sha512-0TS1jicxdU09dwJMNZtVAfzPi6Q6QeN0pM1Fkzrjn+XYHvzMKPU3pHVpva+769iNVSfIYWf7LJ6WR+BuuMf8cA==" "resolved" "https://registry.npmjs.org/bs58check/-/bs58check-2.1.2.tgz" "version" "2.1.2" @@ -1280,7 +1280,7 @@ dependencies: "has-flag" "^4.0.0" -"tiny-secp256k1@^1.0.0": +"tiny-secp256k1@^1.1.1", "tiny-secp256k1@^1.1.3": "integrity" "sha512-FmqJZGduTyvsr2cF3375fqGHUovSwDi/QytexX1Se4BPuPZpTE5Ftp5fg+EFSuEf3lhZqgCRjEG3ydUQ/aNiwA==" "resolved" "https://registry.npmjs.org/tiny-secp256k1/-/tiny-secp256k1-1.1.6.tgz" "version" "1.1.6"