submarine_swaps: use prevout to determine if a txin is claiming a swap
This commit is contained in:
@@ -92,6 +92,7 @@ class SwapData(StoredObject):
|
|||||||
funding_txid = attr.ib(type=Optional[str])
|
funding_txid = attr.ib(type=Optional[str])
|
||||||
spending_txid = attr.ib(type=Optional[str])
|
spending_txid = attr.ib(type=Optional[str])
|
||||||
is_redeemed = attr.ib(type=bool)
|
is_redeemed = attr.ib(type=bool)
|
||||||
|
_funding_prevout = None # for RBF
|
||||||
|
|
||||||
|
|
||||||
def create_claim_tx(
|
def create_claim_tx(
|
||||||
@@ -171,6 +172,7 @@ class SwapManager(Logger):
|
|||||||
self.logger.info('amount too low, we should not reveal the preimage')
|
self.logger.info('amount too low, we should not reveal the preimage')
|
||||||
continue
|
continue
|
||||||
swap.funding_txid = txin.prevout.txid.hex()
|
swap.funding_txid = txin.prevout.txid.hex()
|
||||||
|
swap._funding_prevout = txin.prevout
|
||||||
spent_height = txin.spent_height
|
spent_height = txin.spent_height
|
||||||
if spent_height is not None:
|
if spent_height is not None:
|
||||||
swap.spending_txid = txin.spent_txid
|
swap.spending_txid = txin.spent_txid
|
||||||
@@ -542,7 +544,7 @@ class SwapManager(Logger):
|
|||||||
|
|
||||||
def get_swap_by_claim_txin(self, txin: TxInput) -> Optional[SwapData]:
|
def get_swap_by_claim_txin(self, txin: TxInput) -> Optional[SwapData]:
|
||||||
for key, swap in self.swaps.items():
|
for key, swap in self.swaps.items():
|
||||||
if txin.prevout.txid.hex() == swap.funding_txid:
|
if txin.prevout == swap._funding_prevout:
|
||||||
return swap
|
return swap
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user