diff --git a/CHANGELOG.md b/CHANGELOG.md index 172d90c..d1191a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 5.1.1 +__changed__ +- Name inconsistencies for Psbt class. (Quick fix) + # 5.1.0 __added__ - A new `Psbt` class for creating, distributing, combining, signing, and compiling Transactions (#1425) diff --git a/package-lock.json b/package-lock.json index f699a72..2084591 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "bitcoinjs-lib", - "version": "5.1.0", + "version": "5.1.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 97fac83..63b33bf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bitcoinjs-lib", - "version": "5.1.0", + "version": "5.1.1", "description": "Client-side Bitcoin JavaScript library", "main": "./src/index.js", "types": "./types/index.d.ts", diff --git a/src/psbt.js b/src/psbt.js index e975faa..8fbb2bb 100644 --- a/src/psbt.js +++ b/src/psbt.js @@ -42,7 +42,7 @@ const DEFAULT_OPTS = { * data for updateOutput. * For a list of what attributes should be what types. Check the bip174 library. * Also, check the integration tests for some examples of usage. - * Signer: There are a few methods. signAllInputs and signAsync, which will search all input + * Signer: There are a few methods. signAllInputs and signAllInputsAsync, which will search all input * information for your pubkey or pubkeyhash, and only sign inputs where it finds * your info. Or you can explicitly sign a specific input with signInput and * signInputAsync. For the async methods you can create a SignerAsync object @@ -295,7 +295,7 @@ class Psbt { } return this; } - signHDAsync( + signAllInputsHDAsync( hdKeyPair, sighashTypes = [transaction_1.Transaction.SIGHASH_ALL], ) { @@ -380,7 +380,10 @@ class Psbt { } return this; } - signAsync(keyPair, sighashTypes = [transaction_1.Transaction.SIGHASH_ALL]) { + signAllInputsAsync( + keyPair, + sighashTypes = [transaction_1.Transaction.SIGHASH_ALL], + ) { return new Promise((resolve, reject) => { if (!keyPair || !keyPair.publicKey) return reject(new Error('Need Signer to sign input')); diff --git a/test/integration/transactions-psbt.js b/test/integration/transactions-psbt.js index 07035ab..7b9d9c5 100644 --- a/test/integration/transactions-psbt.js +++ b/test/integration/transactions-psbt.js @@ -132,7 +132,7 @@ describe('bitcoinjs-lib (transactions with psbt)', () => { signer2.signAllInputs(alice2.keys[0]); // If your signer object's sign method returns a promise, use the following - // await signer2.signAsync(alice2.keys[0]) + // await signer2.signAllInputsAsync(alice2.keys[0]) // encode to send back to combiner (signer 1 and 2 are not near each other) const s1text = signer1.toBase64(); diff --git a/test/psbt.js b/test/psbt.js index 2b630d7..b670a99 100644 --- a/test/psbt.js +++ b/test/psbt.js @@ -219,14 +219,14 @@ describe(`Psbt`, () => { }) }) - describe('signAsync', () => { + describe('signAllInputsAsync', () => { fixtures.signInput.checks.forEach(f => { if (f.description === 'checks the input exists') return it(f.description, async () => { if (f.shouldSign) { const psbtThatShouldsign = Psbt.fromBase64(f.shouldSign.psbt) assert.doesNotReject(async () => { - await psbtThatShouldsign.signAsync( + await psbtThatShouldsign.signAllInputsAsync( ECPair.fromWIF(f.shouldSign.WIF), f.shouldSign.sighashTypes || undefined, ) @@ -236,13 +236,13 @@ describe(`Psbt`, () => { if (f.shouldThrow) { const psbtThatShouldThrow = Psbt.fromBase64(f.shouldThrow.psbt) assert.rejects(async () => { - await psbtThatShouldThrow.signAsync( + await psbtThatShouldThrow.signAllInputsAsync( ECPair.fromWIF(f.shouldThrow.WIF), f.shouldThrow.sighashTypes || undefined, ) }, new RegExp('No inputs were signed')) assert.rejects(async () => { - await psbtThatShouldThrow.signAsync() + await psbtThatShouldThrow.signAllInputsAsync() }, new RegExp('Need Signer to sign input')) } }) @@ -345,13 +345,13 @@ describe(`Psbt`, () => { }) }) - describe('signHDAsync', () => { + describe('signAllInputsHDAsync', () => { fixtures.signInputHD.checks.forEach(f => { it(f.description, async () => { if (f.shouldSign) { const psbtThatShouldsign = Psbt.fromBase64(f.shouldSign.psbt) assert.doesNotReject(async () => { - await psbtThatShouldsign.signHDAsync( + await psbtThatShouldsign.signAllInputsHDAsync( bip32.fromBase58(f.shouldSign.xprv), f.shouldSign.sighashTypes || undefined, ) @@ -361,13 +361,13 @@ describe(`Psbt`, () => { if (f.shouldThrow) { const psbtThatShouldThrow = Psbt.fromBase64(f.shouldThrow.psbt) assert.rejects(async () => { - await psbtThatShouldThrow.signHDAsync( + await psbtThatShouldThrow.signAllInputsHDAsync( bip32.fromBase58(f.shouldThrow.xprv), f.shouldThrow.sighashTypes || undefined, ) }, new RegExp('No inputs were signed')) assert.rejects(async () => { - await psbtThatShouldThrow.signHDAsync() + await psbtThatShouldThrow.signAllInputsHDAsync() }, new RegExp('Need HDSigner to sign input')) } }) diff --git a/ts_src/psbt.ts b/ts_src/psbt.ts index 6efbc9d..83e9dee 100644 --- a/ts_src/psbt.ts +++ b/ts_src/psbt.ts @@ -58,7 +58,7 @@ const DEFAULT_OPTS: PsbtOpts = { * data for updateOutput. * For a list of what attributes should be what types. Check the bip174 library. * Also, check the integration tests for some examples of usage. - * Signer: There are a few methods. signAllInputs and signAsync, which will search all input + * Signer: There are a few methods. signAllInputs and signAllInputsAsync, which will search all input * information for your pubkey or pubkeyhash, and only sign inputs where it finds * your info. Or you can explicitly sign a specific input with signInput and * signInputAsync. For the async methods you can create a SignerAsync object @@ -351,7 +351,7 @@ export class Psbt { return this; } - signHDAsync( + signAllInputsHDAsync( hdKeyPair: HDSigner | HDSignerAsync, sighashTypes: number[] = [Transaction.SIGHASH_ALL], ): Promise { @@ -454,7 +454,7 @@ export class Psbt { return this; } - signAsync( + signAllInputsAsync( keyPair: Signer | SignerAsync, sighashTypes: number[] = [Transaction.SIGHASH_ALL], ): Promise { diff --git a/types/psbt.d.ts b/types/psbt.d.ts index a133feb..04a3cfd 100644 --- a/types/psbt.d.ts +++ b/types/psbt.d.ts @@ -19,7 +19,7 @@ import { Transaction } from './transaction'; * data for updateOutput. * For a list of what attributes should be what types. Check the bip174 library. * Also, check the integration tests for some examples of usage. - * Signer: There are a few methods. signAllInputs and signAsync, which will search all input + * Signer: There are a few methods. signAllInputs and signAllInputsAsync, which will search all input * information for your pubkey or pubkeyhash, and only sign inputs where it finds * your info. Or you can explicitly sign a specific input with signInput and * signInputAsync. For the async methods you can create a SignerAsync object @@ -62,11 +62,11 @@ export declare class Psbt { validateSignaturesOfAllInputs(): boolean; validateSignaturesOfInput(inputIndex: number, pubkey?: Buffer): boolean; signAllInputsHD(hdKeyPair: HDSigner, sighashTypes?: number[]): this; - signHDAsync(hdKeyPair: HDSigner | HDSignerAsync, sighashTypes?: number[]): Promise; + signAllInputsHDAsync(hdKeyPair: HDSigner | HDSignerAsync, sighashTypes?: number[]): Promise; signInputHD(inputIndex: number, hdKeyPair: HDSigner, sighashTypes?: number[]): this; signInputHDAsync(inputIndex: number, hdKeyPair: HDSigner | HDSignerAsync, sighashTypes?: number[]): Promise; signAllInputs(keyPair: Signer, sighashTypes?: number[]): this; - signAsync(keyPair: Signer | SignerAsync, sighashTypes?: number[]): Promise; + signAllInputsAsync(keyPair: Signer | SignerAsync, sighashTypes?: number[]): Promise; signInput(inputIndex: number, keyPair: Signer, sighashTypes?: number[]): this; signInputAsync(inputIndex: number, keyPair: Signer | SignerAsync, sighashTypes?: number[]): Promise; toBuffer(): Buffer;