Fix method names for PSBT
This commit is contained in:
parent
f75aebc6f9
commit
a3bfee75b0
6 changed files with 25 additions and 18 deletions
|
@ -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)
|
||||
|
|
|
@ -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'));
|
||||
|
|
|
@ -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();
|
||||
|
|
16
test/psbt.js
16
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'))
|
||||
}
|
||||
})
|
||||
|
|
|
@ -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<void> {
|
||||
|
@ -454,7 +454,7 @@ export class Psbt {
|
|||
return this;
|
||||
}
|
||||
|
||||
signAsync(
|
||||
signAllInputsAsync(
|
||||
keyPair: Signer | SignerAsync,
|
||||
sighashTypes: number[] = [Transaction.SIGHASH_ALL],
|
||||
): Promise<void> {
|
||||
|
|
6
types/psbt.d.ts
vendored
6
types/psbt.d.ts
vendored
|
@ -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<void>;
|
||||
signAllInputsHDAsync(hdKeyPair: HDSigner | HDSignerAsync, sighashTypes?: number[]): Promise<void>;
|
||||
signInputHD(inputIndex: number, hdKeyPair: HDSigner, sighashTypes?: number[]): this;
|
||||
signInputHDAsync(inputIndex: number, hdKeyPair: HDSigner | HDSignerAsync, sighashTypes?: number[]): Promise<void>;
|
||||
signAllInputs(keyPair: Signer, sighashTypes?: number[]): this;
|
||||
signAsync(keyPair: Signer | SignerAsync, sighashTypes?: number[]): Promise<void>;
|
||||
signAllInputsAsync(keyPair: Signer | SignerAsync, sighashTypes?: number[]): Promise<void>;
|
||||
signInput(inputIndex: number, keyPair: Signer, sighashTypes?: number[]): this;
|
||||
signInputAsync(inputIndex: number, keyPair: Signer | SignerAsync, sighashTypes?: number[]): Promise<void>;
|
||||
toBuffer(): Buffer;
|
||||
|
|
Loading…
Reference in a new issue