junderw
6 years ago
No known key found for this signature in database
GPG Key ID: B256185D3A971908
2 changed files with
37 additions and
29 deletions
-
src/psbt.js
-
ts_src/psbt.ts
|
|
@ -175,20 +175,23 @@ class Psbt extends bip174_1.Psbt { |
|
|
|
return this.addPartialSigToInput(inputIndex, partialSig); |
|
|
|
} |
|
|
|
signInputAsync(inputIndex, keyPair) { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
if (!keyPair || !keyPair.publicKey) |
|
|
|
throw new Error('Need Signer to sign input'); |
|
|
|
return reject(new Error('Need Signer to sign input')); |
|
|
|
const { hash, sighashType } = getHashAndSighashType( |
|
|
|
this.inputs, |
|
|
|
inputIndex, |
|
|
|
keyPair.publicKey, |
|
|
|
this.globalMap.unsignedTx, |
|
|
|
); |
|
|
|
return keyPair.sign(hash).then(signature => { |
|
|
|
Promise.resolve(keyPair.sign(hash)).then(signature => { |
|
|
|
const partialSig = { |
|
|
|
pubkey: keyPair.publicKey, |
|
|
|
signature: bscript.signature.encode(signature, sighashType), |
|
|
|
}; |
|
|
|
this.addPartialSigToInput(inputIndex, partialSig); |
|
|
|
resolve(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
@ -214,8 +214,10 @@ export class Psbt extends PsbtBase { |
|
|
|
} |
|
|
|
|
|
|
|
signInputAsync(inputIndex: number, keyPair: SignerAsync): Promise<void> { |
|
|
|
return new Promise( |
|
|
|
(resolve, reject): void => { |
|
|
|
if (!keyPair || !keyPair.publicKey) |
|
|
|
throw new Error('Need Signer to sign input'); |
|
|
|
return reject(new Error('Need Signer to sign input')); |
|
|
|
const { hash, sighashType } = getHashAndSighashType( |
|
|
|
this.inputs, |
|
|
|
inputIndex, |
|
|
@ -223,14 +225,17 @@ export class Psbt extends PsbtBase { |
|
|
|
this.globalMap.unsignedTx!, |
|
|
|
); |
|
|
|
|
|
|
|
return keyPair.sign(hash).then(signature => { |
|
|
|
Promise.resolve(keyPair.sign(hash)).then(signature => { |
|
|
|
const partialSig = { |
|
|
|
pubkey: keyPair.publicKey, |
|
|
|
signature: bscript.signature.encode(signature, sighashType), |
|
|
|
}; |
|
|
|
|
|
|
|
this.addPartialSigToInput(inputIndex, partialSig); |
|
|
|
resolve(); |
|
|
|
}); |
|
|
|
}, |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|