Skip to content

Commit 1e8553f

Browse files
committed
Clean up check_channel_announcement style
`check_channel_announcement` had long lines, a (very-)stale TODO and confusing variable assignment, which is all cleaned up here.
1 parent d3105d7 commit 1e8553f

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

lightning/src/routing/utxo.rs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,31 +47,39 @@ pub trait UtxoLookup {
4747
pub(crate) fn check_channel_announcement<U: Deref>(
4848
utxo_lookup: &Option<U>, msg: &msgs::UnsignedChannelAnnouncement
4949
) -> Result<Option<u64>, msgs::LightningError> where U::Target: UtxoLookup {
50-
let utxo_value = match utxo_lookup {
50+
match utxo_lookup {
5151
&None => {
5252
// Tentatively accept, potentially exposing us to DoS attacks
53-
None
53+
Ok(None)
5454
},
5555
&Some(ref utxo_lookup) => {
5656
match utxo_lookup.get_utxo(&msg.chain_hash, msg.short_channel_id) {
5757
Ok(TxOut { value, script_pubkey }) => {
5858
let expected_script =
5959
make_funding_redeemscript_from_slices(msg.bitcoin_key_1.as_slice(), msg.bitcoin_key_2.as_slice()).to_v0_p2wsh();
6060
if script_pubkey != expected_script {
61-
return Err(LightningError{err: format!("Channel announcement key ({}) didn't match on-chain script ({})", expected_script.to_hex(), script_pubkey.to_hex()), action: ErrorAction::IgnoreError});
61+
return Err(LightningError{
62+
err: format!("Channel announcement key ({}) didn't match on-chain script ({})",
63+
expected_script.to_hex(), script_pubkey.to_hex()),
64+
action: ErrorAction::IgnoreError
65+
});
6266
}
63-
//TODO: Check if value is worth storing, use it to inform routing, and compare it
64-
//to the new HTLC max field in channel_update
65-
Some(value)
67+
Ok(Some(value))
6668
},
6769
Err(UtxoLookupError::UnknownChain) => {
68-
return Err(LightningError{err: format!("Channel announced on an unknown chain ({})", msg.chain_hash.encode().to_hex()), action: ErrorAction::IgnoreError});
70+
Err(LightningError {
71+
err: format!("Channel announced on an unknown chain ({})",
72+
msg.chain_hash.encode().to_hex()),
73+
action: ErrorAction::IgnoreError
74+
})
6975
},
7076
Err(UtxoLookupError::UnknownTx) => {
71-
return Err(LightningError{err: "Channel announced without corresponding UTXO entry".to_owned(), action: ErrorAction::IgnoreError});
77+
Err(LightningError {
78+
err: "Channel announced without corresponding UTXO entry".to_owned(),
79+
action: ErrorAction::IgnoreError
80+
})
7281
},
7382
}
7483
}
75-
};
76-
Ok(utxo_value)
84+
}
7785
}

0 commit comments

Comments
 (0)