Flesh out signInput interface
This commit is contained in:
parent
2ed89cdc68
commit
6ed635d7b4
3 changed files with 32 additions and 0 deletions
12
src/psbt.js
12
src/psbt.js
|
@ -5,5 +5,17 @@ class Psbt extends bip174_1.Psbt {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
signInput(inputIndex, keyPair) {
|
||||||
|
// TODO: Implement BIP174 pre-sign checks:
|
||||||
|
// https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki#signer
|
||||||
|
// TODO: Get hash to sign
|
||||||
|
const hash = Buffer.alloc(32);
|
||||||
|
const partialSig = {
|
||||||
|
pubkey: keyPair.publicKey,
|
||||||
|
signature: keyPair.sign(hash),
|
||||||
|
};
|
||||||
|
this.addPartialSigToInput(inputIndex, partialSig);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
exports.Psbt = Psbt;
|
exports.Psbt = Psbt;
|
||||||
|
|
|
@ -1,7 +1,25 @@
|
||||||
import { Psbt as PsbtBase } from 'bip174';
|
import { Psbt as PsbtBase } from 'bip174';
|
||||||
|
import { Signer } from './ecpair';
|
||||||
|
|
||||||
export class Psbt extends PsbtBase {
|
export class Psbt extends PsbtBase {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
signInput(inputIndex: number, keyPair: Signer): Psbt {
|
||||||
|
// TODO: Implement BIP174 pre-sign checks:
|
||||||
|
// https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki#signer
|
||||||
|
|
||||||
|
// TODO: Get hash to sign
|
||||||
|
const hash = Buffer.alloc(32);
|
||||||
|
|
||||||
|
const partialSig = {
|
||||||
|
pubkey: keyPair.publicKey,
|
||||||
|
signature: keyPair.sign(hash),
|
||||||
|
};
|
||||||
|
|
||||||
|
this.addPartialSigToInput(inputIndex, partialSig);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
2
types/psbt.d.ts
vendored
2
types/psbt.d.ts
vendored
|
@ -1,4 +1,6 @@
|
||||||
import { Psbt as PsbtBase } from 'bip174';
|
import { Psbt as PsbtBase } from 'bip174';
|
||||||
|
import { Signer } from './ecpair';
|
||||||
export declare class Psbt extends PsbtBase {
|
export declare class Psbt extends PsbtBase {
|
||||||
constructor();
|
constructor();
|
||||||
|
signInput(inputIndex: number, keyPair: Signer): Psbt;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue