From: Matt Corallo Date: Thu, 6 Sep 2018 21:13:41 +0000 (-0400) Subject: Document Channel::get_funding_redeemscript precondition X-Git-Tag: v0.0.12~319^2~4 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=beee00636563430075769b1dca5d0e629e1fcbf0;p=rust-lightning Document Channel::get_funding_redeemscript precondition --- diff --git a/src/ln/channel.rs b/src/ln/channel.rs index ab8b3bcdf..d620ff4f8 100644 --- a/src/ln/channel.rs +++ b/src/ln/channel.rs @@ -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)