|
|
@ -1,7 +1,6 @@ |
|
|
|
'use strict'; |
|
|
|
Object.defineProperty(exports, '__esModule', { value: true }); |
|
|
|
const bitcoinjs_lib_1 = require('bitcoinjs-lib'); |
|
|
|
const bitcoinjs_lib_2 = require('bitcoinjs-lib'); |
|
|
|
async function requestPayjoinWithCustomRemoteCall(psbt, remoteCall) { |
|
|
|
const clonedPsbt = psbt.clone(); |
|
|
|
clonedPsbt.finalizeAllInputs(); |
|
|
@ -15,12 +14,6 @@ async function requestPayjoinWithCustomRemoteCall(psbt, remoteCall) { |
|
|
|
delete clonedPsbt.data.globalMap.globalXpub; |
|
|
|
const payjoinPsbt = await remoteCall(clonedPsbt); |
|
|
|
if (!payjoinPsbt) throw new Error("We did not get the receiver's PSBT"); |
|
|
|
// no inputs were added?
|
|
|
|
if (clonedPsbt.inputCount <= payjoinPsbt.inputCount) { |
|
|
|
throw new Error( |
|
|
|
"There were less inputs than before in the receiver's PSBT", |
|
|
|
); |
|
|
|
} |
|
|
|
if ( |
|
|
|
payjoinPsbt.data.globalMap.globalXpub && |
|
|
|
payjoinPsbt.data.globalMap.globalXpub.length > 0 |
|
|
@ -62,7 +55,7 @@ async function requestPayjoinWithCustomRemoteCall(psbt, remoteCall) { |
|
|
|
// Can we assume output will contain redeemScript and witnessScript?
|
|
|
|
// If so, we could decompile scriptPubkey, RS, and WS, and search for
|
|
|
|
// the pubkey and its hash160.
|
|
|
|
bitcoinjs_lib_2.payments.p2wpkh({ |
|
|
|
bitcoinjs_lib_1.payments.p2wpkh({ |
|
|
|
pubkey: originalOutput.bip32Derivation[0].pubkey, |
|
|
|
}).output, |
|
|
|
) |
|
|
@ -70,8 +63,18 @@ async function requestPayjoinWithCustomRemoteCall(psbt, remoteCall) { |
|
|
|
payjoinPsbt.updateOutput(index, originalOutput); |
|
|
|
}); |
|
|
|
} |
|
|
|
// TODO: check payjoinPsbt.version == psbt.version
|
|
|
|
// TODO: check payjoinPsbt.locktime == psbt.locktime
|
|
|
|
if ( |
|
|
|
getGlobalTransaction(payjoinPsbt).version !== |
|
|
|
getGlobalTransaction(psbt).version |
|
|
|
) { |
|
|
|
throw new Error('The version field of the transaction has been modified'); |
|
|
|
} |
|
|
|
if ( |
|
|
|
getGlobalTransaction(payjoinPsbt).locktime !== |
|
|
|
getGlobalTransaction(psbt).locktime |
|
|
|
) { |
|
|
|
throw new Error('The LockTime field of the transaction has been modified'); |
|
|
|
} |
|
|
|
// TODO: check payjoinPsbt.inputs where input belongs to us, that it is not finalized
|
|
|
|
// TODO: check payjoinPsbt.inputs where input belongs to us, that it is was included in psbt.inputs
|
|
|
|
// TODO: check payjoinPsbt.inputs where input belongs to us, that its sequence has not changed from that of psbt.inputs
|
|
|
|