|
|
@ -1,6 +1,7 @@ |
|
|
|
'use strict'; |
|
|
|
Object.defineProperty(exports, '__esModule', { value: true }); |
|
|
|
const bip174_1 = require('bip174'); |
|
|
|
const transaction_1 = require('./transaction'); |
|
|
|
class Psbt extends bip174_1.Psbt { |
|
|
|
constructor() { |
|
|
|
super(); |
|
|
@ -29,6 +30,24 @@ class Psbt extends bip174_1.Psbt { |
|
|
|
// sign_witness(witnessScript)
|
|
|
|
// else:
|
|
|
|
// assert False
|
|
|
|
const input = this.inputs[inputIndex]; |
|
|
|
if (input === undefined) throw new Error(`No input #${inputIndex}`); |
|
|
|
// If a non-witness UTXO is provided, its hash must match the hash specified in the prevout
|
|
|
|
if (input.nonWitnessUtxo) { |
|
|
|
const unsignedTx = transaction_1.Transaction.fromBuffer( |
|
|
|
this.globalMap.unsignedTx, |
|
|
|
); |
|
|
|
const nonWitnessUtxoTx = transaction_1.Transaction.fromBuffer( |
|
|
|
input.nonWitnessUtxo, |
|
|
|
); |
|
|
|
const inputHash = unsignedTx.ins[inputIndex].hash; |
|
|
|
const utxoHash = nonWitnessUtxoTx.getHash(); |
|
|
|
if (Buffer.compare(inputHash, utxoHash) !== 0) { |
|
|
|
throw new Error( |
|
|
|
`Non-witness UTXO hash for input #${inputIndex} doesn't match the hash specified in the prevout`, |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
// TODO: Get hash to sign
|
|
|
|
const hash = Buffer.alloc(32); |
|
|
|
const partialSig = { |
|
|
|