Skip to content

Commit ce60610

Browse files
committed
Charges a 1% fee to HTLC failures
1 parent 834fe63 commit ce60610

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lightning/src/ln/channel.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3277,6 +3277,9 @@ impl<Signer: Sign> Channel<Signer> {
32773277
log_trace!(logger, " ...removing inbound LocalRemoved {}", log_bytes!(htlc.payment_hash.0));
32783278
if let &InboundHTLCRemovalReason::Fulfill(_) = reason {
32793279
value_to_self_msat_diff += htlc.amount_msat as i64;
3280+
} else {
3281+
// FIXME: Just a test. We keep 1% of the HTLC if the receiver fails to deliver
3282+
value_to_self_msat_diff += htlc.amount_msat as i64 / 100;
32803283
}
32813284
false
32823285
} else { true }
@@ -3286,6 +3289,8 @@ impl<Signer: Sign> Channel<Signer> {
32863289
log_trace!(logger, " ...removing outbound AwaitingRemovedRemoteRevoke {}", log_bytes!(htlc.payment_hash.0));
32873290
if let OutboundHTLCOutcome::Failure(reason) = outcome.clone() { // We really want take() here, but, again, non-mut ref :(
32883291
revoked_htlcs.push((htlc.source.clone(), htlc.payment_hash, reason));
3292+
// FIXME: Just a test. The receiver keeps 1% of the forwarded HTLCs on failure
3293+
value_to_self_msat_diff -= htlc.amount_msat as i64 / 100;
32893294
} else {
32903295
finalized_claimed_htlcs.push(htlc.source.clone());
32913296
// They fulfilled, so we sent them money

0 commit comments

Comments
 (0)