Skip to content

Commit

Permalink
Fix input blinding data (#309)
Browse files Browse the repository at this point in the history
* fix error detecting if input is confidential

* fix error where two inputs from same tx (but different vout) would clash

* Update transaction.ts

Co-authored-by: Louis Singer <[email protected]>
  • Loading branch information
bordalix and louisinger authored Feb 11, 2022
1 parent 146e86d commit 401e76a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/application/utils/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
getAsset,
NetworkString,
IdentityInterface,
isConfidentialOutput,
} from 'ldk';
import { confidential, networks, payments, Psbt } from 'liquidjs-lib';
import { isConfidentialAddress } from './address';
Expand Down Expand Up @@ -62,12 +63,12 @@ function inputBlindingDataMap(
let index = -1;
for (const input of psetToUnsignedTx(pset).ins) {
index++;
const utxo = utxos.find((u) => txidToBuffer(u.txid).equals(input.hash));
const utxo = utxos.find(
(u) => txidToBuffer(u.txid).equals(input.hash) && u.vout === input.index
);

// if the input is confidential, unblindData will be defined
// in that case, we need to add it to the blinding data map
// this let to ignore unconfidential inputs
if (utxo?.unblindData) {
// only add unblind data if the prevout of the input is confidential
if (utxo && utxo.unblindData && isConfidentialOutput(utxo.prevout)) {
inputBlindingData.set(index, utxo.unblindData);
}
}
Expand Down

0 comments on commit 401e76a

Please sign in to comment.