@@ -16,13 +16,12 @@ use bitcoin::secp256k1;
16
16
17
17
use bitcoin:: hashes:: sha256d:: Hash as Sha256dHash ;
18
18
use bitcoin:: hashes:: Hash ;
19
- use bitcoin:: blockdata:: script:: Builder ;
20
19
use bitcoin:: blockdata:: transaction:: TxOut ;
21
- use bitcoin:: blockdata:: opcodes;
22
20
use bitcoin:: hash_types:: BlockHash ;
23
21
24
22
use chain;
25
23
use chain:: Access ;
24
+ use ln:: chan_utils:: make_funding_redeemscript;
26
25
use ln:: features:: { ChannelFeatures , NodeFeatures } ;
27
26
use ln:: msgs:: { DecodeError , ErrorAction , Init , LightningError , RoutingMessageHandler , NetAddress , MAX_VALUE_MSAT } ;
28
27
use ln:: msgs:: { ChannelAnnouncement , ChannelUpdate , NodeAnnouncement , GossipTimestampFilter } ;
@@ -1442,11 +1441,8 @@ impl<L: Deref> NetworkGraph<L> where L::Target: Logger {
1442
1441
& Some ( ref chain_access) => {
1443
1442
match chain_access. get_utxo ( & msg. chain_hash , msg. short_channel_id ) {
1444
1443
Ok ( TxOut { value, script_pubkey } ) => {
1445
- let expected_script = Builder :: new ( ) . push_opcode ( opcodes:: all:: OP_PUSHNUM_2 )
1446
- . push_slice ( & msg. bitcoin_key_1 . serialize ( ) )
1447
- . push_slice ( & msg. bitcoin_key_2 . serialize ( ) )
1448
- . push_opcode ( opcodes:: all:: OP_PUSHNUM_2 )
1449
- . push_opcode ( opcodes:: all:: OP_CHECKMULTISIG ) . into_script ( ) . to_v0_p2wsh ( ) ;
1444
+ let expected_script =
1445
+ make_funding_redeemscript ( & msg. bitcoin_key_1 , & msg. bitcoin_key_2 ) . to_v0_p2wsh ( ) ;
1450
1446
if script_pubkey != expected_script {
1451
1447
return Err ( LightningError { err : format ! ( "Channel announcement key ({}) didn't match on-chain script ({})" , script_pubkey. to_hex( ) , expected_script. to_hex( ) ) , action : ErrorAction :: IgnoreError } ) ;
1452
1448
}
@@ -1823,6 +1819,7 @@ impl ReadOnlyNetworkGraph<'_> {
1823
1819
#[ cfg( test) ]
1824
1820
mod tests {
1825
1821
use chain;
1822
+ use ln:: chan_utils:: make_funding_redeemscript;
1826
1823
use ln:: PaymentHash ;
1827
1824
use ln:: features:: { ChannelFeatures , InitFeatures , NodeFeatures } ;
1828
1825
use routing:: gossip:: { P2PGossipSync , NetworkGraph , NetworkUpdate , NodeAlias , MAX_EXCESS_BYTES_FOR_RELAY , NodeId , RoutingFees , ChannelUpdateInfo , ChannelInfo , NodeAnnouncementInfo , NodeInfo } ;
@@ -1840,9 +1837,8 @@ mod tests {
1840
1837
use bitcoin:: hashes:: Hash ;
1841
1838
use bitcoin:: network:: constants:: Network ;
1842
1839
use bitcoin:: blockdata:: constants:: genesis_block;
1843
- use bitcoin:: blockdata:: script:: { Builder , Script } ;
1840
+ use bitcoin:: blockdata:: script:: Script ;
1844
1841
use bitcoin:: blockdata:: transaction:: TxOut ;
1845
- use bitcoin:: blockdata:: opcodes;
1846
1842
1847
1843
use hex;
1848
1844
@@ -1932,14 +1928,10 @@ mod tests {
1932
1928
}
1933
1929
1934
1930
fn get_channel_script ( secp_ctx : & Secp256k1 < secp256k1:: All > ) -> Script {
1935
- let node_1_btckey = & SecretKey :: from_slice ( & [ 40 ; 32 ] ) . unwrap ( ) ;
1936
- let node_2_btckey = & SecretKey :: from_slice ( & [ 39 ; 32 ] ) . unwrap ( ) ;
1937
- Builder :: new ( ) . push_opcode ( opcodes:: all:: OP_PUSHNUM_2 )
1938
- . push_slice ( & PublicKey :: from_secret_key ( & secp_ctx, node_1_btckey) . serialize ( ) )
1939
- . push_slice ( & PublicKey :: from_secret_key ( & secp_ctx, node_2_btckey) . serialize ( ) )
1940
- . push_opcode ( opcodes:: all:: OP_PUSHNUM_2 )
1941
- . push_opcode ( opcodes:: all:: OP_CHECKMULTISIG ) . into_script ( )
1942
- . to_v0_p2wsh ( )
1931
+ let node_1_btckey = SecretKey :: from_slice ( & [ 40 ; 32 ] ) . unwrap ( ) ;
1932
+ let node_2_btckey = SecretKey :: from_slice ( & [ 39 ; 32 ] ) . unwrap ( ) ;
1933
+ make_funding_redeemscript ( & PublicKey :: from_secret_key ( secp_ctx, & node_1_btckey) ,
1934
+ & PublicKey :: from_secret_key ( secp_ctx, & node_2_btckey) ) . to_v0_p2wsh ( )
1943
1935
}
1944
1936
1945
1937
fn get_signed_channel_update < F : Fn ( & mut UnsignedChannelUpdate ) > ( f : F , node_key : & SecretKey , secp_ctx : & Secp256k1 < secp256k1:: All > ) -> ChannelUpdate {
0 commit comments