Skip to content

Commit fb0f200

Browse files
fixup! feat(wallet): input resolver now searches TX history if input cant be found in current UTXO set
1 parent 3613014 commit fb0f200

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

packages/wallet/src/global.d.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export {}
2+
3+
declare global {
4+
interface Array<T> {
5+
findLastIndex(
6+
predicate: (value: T, index: number, obj: T[]) => unknown,
7+
thisArg?: any
8+
): number;
9+
10+
findLast(
11+
predicate: (value: T, index: number, obj: T[]) => unknown,
12+
thisArg?: any
13+
): T | undefined;
14+
}
15+
}

packages/wallet/src/services/WalletUtil.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,7 @@ export const createInputResolver = ({ utxo, transactions }: InputResolverContext
6666
}
6767
}
6868

69-
// Input resolver is also used to resolve inputs for historical view, so it is possible that client code is trying to resolve an input that
70-
// was already spent, we need to look at the tx history to find it. We search here as last resort since this is more expensive
71-
// that searching through the UTXO set for wallets with big TX History.
72-
const historyTx = txHistory.find((entry) => entry.id === input.txId);
69+
const historyTx = txHistory.findLast((entry) => entry.id === input.txId);
7370

7471
if (historyTx && historyTx.body.outputs.length > input.index) {
7572
return historyTx.body.outputs[input.index];

0 commit comments

Comments
 (0)