Skip to content

Commit

Permalink
make sure utxo doesn't exist if txn is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
jcramer committed Oct 14, 2019
1 parent e523660 commit 2a5ca70
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions slptokengraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -604,12 +604,16 @@ export class SlpTokenGraph implements TokenGraph {

let txout: GraphTxnOutput|undefined;
try {
txout = this._graphTxns.get(txid)!.outputs[vout-1]
txout = this._graphTxns.get(txid)!.outputs.find(o => vout === o.vout);
} catch(_) {
await this.updateTokenGraphFrom({ txid })
await this.updateTokenGraphFrom({ txid });
if(!this._tokenUtxos.has(utxo))
return
txout = this._graphTxns.get(txid)!.outputs[vout-1]
if(!this._graphTxns.has(txid)) {
this._tokenUtxos.delete(utxo);
return
}
txout = this._graphTxns.get(txid)!.outputs.find(o => vout === o.vout);
}

if(txout) {
Expand Down

0 comments on commit 2a5ca70

Please sign in to comment.