File tree 1 file changed +11
-1
lines changed 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ use secp256k1::{Secp256k1,Message};
3
3
use secp256k1;
4
4
5
5
use bitcoin:: util:: hash:: Sha256dHash ;
6
+ use bitcoin:: blockdata:: script:: Builder ;
7
+ use bitcoin:: blockdata:: opcodes;
6
8
7
9
use chain:: chaininterface:: { ChainError , ChainWatchInterface } ;
8
10
use ln:: channelmanager;
@@ -209,7 +211,15 @@ impl RoutingMessageHandler for Router {
209
211
210
212
match self . chain_monitor . get_chain_utxo ( msg. contents . chain_hash , msg. contents . short_channel_id ) {
211
213
Ok ( ( script_pubkey, _value) ) => {
212
- //TODO: Check if script_pubkey matches bitcoin_key_1 and bitcoin_key_2
214
+ let expected_script = Builder :: new ( ) . push_opcode ( opcodes:: All :: OP_PUSHNUM_2 )
215
+ . push_slice ( & msg. contents . bitcoin_key_1 . serialize ( ) )
216
+ . push_slice ( & msg. contents . bitcoin_key_2 . serialize ( ) )
217
+ . push_opcode ( opcodes:: All :: OP_PUSHNUM_2 ) . push_opcode ( opcodes:: All :: OP_CHECKMULTISIG ) . into_script ( ) . to_v0_p2wsh ( ) ;
218
+ if script_pubkey != expected_script {
219
+ return Err ( HandleError { err : "Channel announcement keys didn't match on-chain script" , action : Some ( ErrorAction :: IgnoreError ) } ) ;
220
+ }
221
+ //TODO: Check if value is worth storing, use it to inform routing, and compare it
222
+ //to the new HTLC max field in channel_update
213
223
} ,
214
224
Err ( ChainError :: NotSupported ) => {
215
225
// Tenatively accept, potentially exposing us to DoS attacks
You can’t perform that action at this time.
0 commit comments