Skip to content

Commit 3937747

Browse files
author
Antoine Riard
committed
Add fee estimation in check_spend_remote_htlc
1 parent 9f9e30f commit 3937747

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/ln/channelmonitor.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,7 +1499,7 @@ impl ChannelMonitor {
14991499
}
15001500

15011501
/// Attempts to claim a remote HTLC-Success/HTLC-Timeout's outputs using the revocation key
1502-
fn check_spend_remote_htlc(&self, tx: &Transaction, commitment_number: u64) -> (Option<Transaction>, Option<SpendableOutputDescriptor>) {
1502+
fn check_spend_remote_htlc(&self, tx: &Transaction, commitment_number: u64, fee_estimator: &FeeEstimator) -> (Option<Transaction>, Option<SpendableOutputDescriptor>) {
15031503
if tx.input.len() != 1 || tx.output.len() != 1 {
15041504
return (None, None)
15051505
}
@@ -1551,7 +1551,7 @@ impl ChannelMonitor {
15511551
if !inputs.is_empty() {
15521552
let outputs = vec!(TxOut {
15531553
script_pubkey: self.destination_script.clone(),
1554-
value: amount, //TODO: - fee
1554+
value: amount - fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::HighPriority) * Self::get_claim_tx_weight(vec![InputDescriptors::RevokedOutput], &self.destination_script) / 1000,
15551555
});
15561556

15571557
let mut spend_tx = Transaction {
@@ -1791,7 +1791,7 @@ impl ChannelMonitor {
17911791
}
17921792
} else {
17931793
if let Some(&(commitment_number, _)) = self.remote_commitment_txn_on_chain.get(&prevout.txid) {
1794-
let (tx, spendable_output) = self.check_spend_remote_htlc(tx, commitment_number);
1794+
let (tx, spendable_output) = self.check_spend_remote_htlc(tx, commitment_number, fee_estimator);
17951795
if let Some(tx) = tx {
17961796
txn.push(tx);
17971797
}

0 commit comments

Comments
 (0)