Skip to content

Commit c76590c

Browse files
committed
fix: check input of lock hashes
1 parent befe318 commit c76590c

2 files changed

Lines changed: 16 additions & 14 deletions

File tree

packages/neuron-wallet/src/services/sync/check-and-save/tx.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default class CheckTx {
1818

1919
public check = async (lockHashes: string[]): Promise<string[]> => {
2020
const outputs: Cell[] = this.filterOutputs(lockHashes)
21-
const inputAddresses = await this.filterInputs()
21+
const inputAddresses = await this.filterInputs(lockHashes)
2222

2323
const outputAddresses: string[] = outputs.map(output => {
2424
return LockUtils.lockScriptToAddress(output.lock)
@@ -48,24 +48,23 @@ export default class CheckTx {
4848

4949
/* eslint no-await-in-loop: "off" */
5050
/* eslint no-restricted-syntax: "warn" */
51-
public filterInputs = async (): Promise<string[]> => {
51+
public filterInputs = async (lockHashes: string[]): Promise<string[]> => {
5252
const inputs = this.tx.inputs!
5353

5454
const addresses: string[] = []
5555
for (const input of inputs) {
5656
const outPoint: OutPoint = input.previousOutput
5757
const { cell } = outPoint
58-
if (!cell) {
59-
break
60-
}
61-
const output = await getConnection()
62-
.getRepository(OutputEntity)
63-
.findOne({
64-
outPointTxHash: cell.txHash,
65-
outPointIndex: cell.index,
66-
})
67-
if (output) {
68-
addresses.push(LockUtils.lockScriptToAddress(output.lock))
58+
if (cell) {
59+
const output = await getConnection()
60+
.getRepository(OutputEntity)
61+
.findOne({
62+
outPointTxHash: cell.txHash,
63+
outPointIndex: cell.index,
64+
})
65+
if (output && lockHashes.includes(output.lockHash)) {
66+
addresses.push(LockUtils.lockScriptToAddress(output.lock))
67+
}
6968
}
7069
}
7170

packages/neuron-wallet/src/services/tx/transaction-persistor.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,10 @@ export class TransactionPersistor {
213213
}
214214

215215
public static saveFetchTx = async (transaction: Transaction): Promise<TransactionEntity> => {
216-
const txEntity: TransactionEntity = await TransactionPersistor.convertTransactionAndSave(transaction, TxSaveType.Fetch)
216+
const txEntity: TransactionEntity = await TransactionPersistor.convertTransactionAndSave(
217+
transaction,
218+
TxSaveType.Fetch
219+
)
217220
return txEntity
218221
}
219222

0 commit comments

Comments
 (0)