+ f(&mut unsigned_announcement);
+ let msghash = hash_to_message!(&Sha256dHash::hash(&unsigned_announcement.encode()[..])[..]);
+ NodeAnnouncement {
+ signature: secp_ctx.sign(&msghash, node_key),
+ contents: unsigned_announcement
+ }
+ }
+
+ fn get_signed_channel_announcement<F: Fn(&mut UnsignedChannelAnnouncement)>(f: F, node_1_key: &SecretKey, node_2_key: &SecretKey, secp_ctx: &Secp256k1<secp256k1::All>) -> ChannelAnnouncement {
+ let node_id_1 = PublicKey::from_secret_key(&secp_ctx, node_1_key);
+ let node_id_2 = PublicKey::from_secret_key(&secp_ctx, node_2_key);
+ let node_1_btckey = &SecretKey::from_slice(&[40; 32]).unwrap();
+ let node_2_btckey = &SecretKey::from_slice(&[39; 32]).unwrap();
+
+ let mut unsigned_announcement = UnsignedChannelAnnouncement {
+ features: ChannelFeatures::known(),
+ chain_hash: genesis_block(Network::Testnet).header.block_hash(),
+ short_channel_id: 0,
+ node_id_1,
+ node_id_2,
+ bitcoin_key_1: PublicKey::from_secret_key(&secp_ctx, node_1_btckey),
+ bitcoin_key_2: PublicKey::from_secret_key(&secp_ctx, node_2_btckey),
+ excess_data: Vec::new(),
+ };
+ f(&mut unsigned_announcement);
+ let msghash = hash_to_message!(&Sha256dHash::hash(&unsigned_announcement.encode()[..])[..]);
+ ChannelAnnouncement {
+ node_signature_1: secp_ctx.sign(&msghash, node_1_key),
+ node_signature_2: secp_ctx.sign(&msghash, node_2_key),
+ bitcoin_signature_1: secp_ctx.sign(&msghash, node_1_btckey),
+ bitcoin_signature_2: secp_ctx.sign(&msghash, node_2_btckey),
+ contents: unsigned_announcement,
+ }
+ }
+
+ fn get_channel_script(secp_ctx: &Secp256k1<secp256k1::All>) -> Script {
+ let node_1_btckey = &SecretKey::from_slice(&[40; 32]).unwrap();
+ let node_2_btckey = &SecretKey::from_slice(&[39; 32]).unwrap();
+ Builder::new().push_opcode(opcodes::all::OP_PUSHNUM_2)
+ .push_slice(&PublicKey::from_secret_key(&secp_ctx, node_1_btckey).serialize())
+ .push_slice(&PublicKey::from_secret_key(&secp_ctx, node_2_btckey).serialize())
+ .push_opcode(opcodes::all::OP_PUSHNUM_2)
+ .push_opcode(opcodes::all::OP_CHECKMULTISIG).into_script()
+ .to_v0_p2wsh()
+ }
+
+ fn get_signed_channel_update<F: Fn(&mut UnsignedChannelUpdate)>(f: F, node_key: &SecretKey, secp_ctx: &Secp256k1<secp256k1::All>) -> ChannelUpdate {
+ let mut unsigned_channel_update = UnsignedChannelUpdate {
+ chain_hash: genesis_block(Network::Testnet).header.block_hash(),
+ short_channel_id: 0,
+ timestamp: 100,
+ flags: 0,
+ cltv_expiry_delta: 144,
+ htlc_minimum_msat: 1_000_000,
+ htlc_maximum_msat: OptionalField::Absent,
+ fee_base_msat: 10_000,
+ fee_proportional_millionths: 20,
+ excess_data: Vec::new()