]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Document Channel::get_funding_redeemscript precondition
authorMatt Corallo <git@bluematt.me>
Thu, 6 Sep 2018 21:13:41 +0000 (17:13 -0400)
committerMatt Corallo <git@bluematt.me>
Sat, 8 Sep 2018 14:30:10 +0000 (10:30 -0400)
src/ln/channel.rs

index ab8b3bcdf6cb0ca0bd8251ff8f474f939758df68..d620ff4f8b57b7f33b1490d2d7931dc777dec1b3 100644 (file)
@@ -893,10 +893,11 @@ impl Channel {
 
        /// Gets the redeemscript for the funding transaction output (ie the funding transaction output
        /// pays to get_funding_redeemscript().to_v0_p2wsh()).
+       /// Panics if called before accept_channel/new_from_req
        pub fn get_funding_redeemscript(&self) -> Script {
                let builder = Builder::new().push_opcode(opcodes::All::OP_PUSHNUM_2);
                let our_funding_key = PublicKey::from_secret_key(&self.secp_ctx, &self.local_keys.funding_key).serialize();
-               let their_funding_key = self.their_funding_pubkey.unwrap().serialize();
+               let their_funding_key = self.their_funding_pubkey.expect("get_funding_redeemscript only allowed after accept_channel").serialize();
                if our_funding_key[..] < their_funding_key[..] {
                        builder.push_slice(&our_funding_key)
                                .push_slice(&their_funding_key)