- let utxo_value = match &chain_access {
- &None => {
- // Tentatively accept, potentially exposing us to DoS attacks
- None
- },
- &Some(ref chain_access) => {
- match chain_access.get_utxo(&msg.chain_hash, msg.short_channel_id) {
- Ok(TxOut { value, script_pubkey }) => {
- let expected_script =
- make_funding_redeemscript(&msg.bitcoin_key_1, &msg.bitcoin_key_2).to_v0_p2wsh();
- if script_pubkey != expected_script {
- 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});
- }
- //TODO: Check if value is worth storing, use it to inform routing, and compare it
- //to the new HTLC max field in channel_update
- Some(value)
- },
- Err(chain::AccessError::UnknownChain) => {
- return Err(LightningError{err: format!("Channel announced on an unknown chain ({})", msg.chain_hash.encode().to_hex()), action: ErrorAction::IgnoreError});
- },
- Err(chain::AccessError::UnknownTx) => {
- return Err(LightningError{err: "Channel announced without corresponding UTXO entry".to_owned(), action: ErrorAction::IgnoreError});
- },
- }
- },
- };
+ let utxo_value = self.pending_checks.check_channel_announcement(
+ utxo_lookup, msg, full_msg)?;