From 2d251b4449be710201f9747bcd54f4c116f84a81 Mon Sep 17 00:00:00 2001 From: Arik Sosman Date: Fri, 9 Aug 2024 08:39:53 -0700 Subject: [PATCH] Add documentation to overridden bitcoin types. --- lightning/src/lib.rs | 2 ++ lightning/src/ln/msgs.rs | 3 ++- lightning/src/onion_message/offers.rs | 3 ++- lightning/src/sign/mod.rs | 9 ++++----- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lightning/src/lib.rs b/lightning/src/lib.rs index ed8687f16..7cc540af3 100644 --- a/lightning/src/lib.rs +++ b/lightning/src/lib.rs @@ -86,6 +86,7 @@ pub mod events; pub(crate) mod crypto; +/// Extension of the bitcoin::io module pub mod io { pub use bitcoin::io::*; @@ -154,6 +155,7 @@ pub mod io { Current(i64), } + /// Emulation of std::io::Cursor #[derive(Clone, Debug, Default, Eq, PartialEq)] pub struct Cursor { inner: T, diff --git a/lightning/src/ln/msgs.rs b/lightning/src/ln/msgs.rs index e7b43ded1..d1fdb2e20 100644 --- a/lightning/src/ln/msgs.rs +++ b/lightning/src/ln/msgs.rs @@ -2736,7 +2736,8 @@ impl ReadableArgs<(Option, &NS)> for InboundOnionPayload w }, |msg_type: u64, msg_reader: &mut FixedLengthReader<_>| -> Result { if msg_type < 1 << 16 { return Ok(false) } let mut value = Vec::new(); - msg_reader.read_to_end(&mut value)?; + // msg_reader.read_to_end(&mut value)?; + msg_reader.read_to_limit(&mut value, u64::MAX)?; custom_tlvs.push((msg_type, value)); Ok(true) }); diff --git a/lightning/src/onion_message/offers.rs b/lightning/src/onion_message/offers.rs index a8f43c2d2..f1b7058c3 100644 --- a/lightning/src/onion_message/offers.rs +++ b/lightning/src/onion_message/offers.rs @@ -170,7 +170,8 @@ impl ReadableArgs<(u64, &L)> for OffersMessage { } let mut bytes = Vec::new(); - r.read_to_end(&mut bytes).unwrap(); + // r.read_to_end(&mut bytes).unwrap(); + r.read_to_limit(&mut bytes, u64::MAX).unwrap(); match Self::parse(tlv_type, bytes) { Ok(message) => Ok(message), diff --git a/lightning/src/sign/mod.rs b/lightning/src/sign/mod.rs index 200e3f5ac..57fd05eb2 100644 --- a/lightning/src/sign/mod.rs +++ b/lightning/src/sign/mod.rs @@ -1327,8 +1327,8 @@ impl InMemorySigner { .unwrap()[..] ); let local_delayedsig = EcdsaSignature { - sig: sign_with_aux_rand(secp_ctx, &sighash, &delayed_payment_key, &self), - hash_ty: EcdsaSighashType::All, + signature: sign_with_aux_rand(secp_ctx, &sighash, &delayed_payment_key, &self), + sighash_type: EcdsaSighashType::All, }; let payment_script = bitcoin::Address::p2wsh(&witness_script, Network::Bitcoin).script_pubkey(); @@ -2106,12 +2106,11 @@ impl KeysManager { }; let pubkey = Xpub::from_priv(&secp_ctx, &secret).to_pub(); if derivation_idx == 2 { - assert_eq!(pubkey.inner, self.shutdown_pubkey); + assert_eq!(pubkey.0, self.shutdown_pubkey); } let witness_script = bitcoin::Address::p2pkh(&pubkey, Network::Testnet).script_pubkey(); let payment_script = bitcoin::Address::p2wpkh(&pubkey, Network::Testnet) - .expect("uncompressed key found") .script_pubkey(); if payment_script != output.script_pubkey { @@ -2132,7 +2131,7 @@ impl KeysManager { let mut sig_ser = sig.serialize_der().to_vec(); sig_ser.push(EcdsaSighashType::All as u8); let witness = - Witness::from_slice(&[&sig_ser, &pubkey.inner.serialize().to_vec()]); + Witness::from_slice(&[&sig_ser, &pubkey.0.serialize().to_vec()]); psbt.inputs[input_idx].final_script_witness = Some(witness); }, } -- 2.39.5