Avoid claiming remote received HTLCs with preimage

In case of duplicate HTLCs with same hash going in opposite
directions we may learn preimage of offered one, but we shouldn't
claim received one to avoid invalidation of combined claim.
The received HTLC is going to be claimed by a timeout tx at
timelock expiration.

Fix #337
This commit is contained in:
Antoine Riard 2019-11-12 19:27:55 -05:00
parent 2afd53148f
commit 543b0983f6

View file

@ -1643,6 +1643,7 @@ impl ChannelMonitor {
return (txn_to_broadcast, (commitment_txid, watch_outputs), spendable_outputs); // Corrupted per_commitment_data, fuck this user return (txn_to_broadcast, (commitment_txid, watch_outputs), spendable_outputs); // Corrupted per_commitment_data, fuck this user
} }
if let Some(payment_preimage) = self.payment_preimages.get(&htlc.payment_hash) { if let Some(payment_preimage) = self.payment_preimages.get(&htlc.payment_hash) {
if htlc.offered {
let input = TxIn { let input = TxIn {
previous_output: BitcoinOutPoint { previous_output: BitcoinOutPoint {
txid: commitment_txid, txid: commitment_txid,
@ -1686,6 +1687,7 @@ impl ChannelMonitor {
} }
} }
} }
}
if !htlc.offered { if !htlc.offered {
// TODO: If the HTLC has already expired, potentially merge it with the // TODO: If the HTLC has already expired, potentially merge it with the
// rest of the claim transaction, as above. // rest of the claim transaction, as above.