]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Add documentation to overridden bitcoin types.
authorArik Sosman <git@arik.io>
Fri, 9 Aug 2024 15:39:53 +0000 (08:39 -0700)
committerArik Sosman <git@arik.io>
Fri, 9 Aug 2024 15:39:53 +0000 (08:39 -0700)
lightning/src/lib.rs
lightning/src/ln/msgs.rs
lightning/src/onion_message/offers.rs
lightning/src/sign/mod.rs

index ed8687f16e6fa280ed073e9be8294bcde366933d..7cc540af39516295f8d05b79167290327cb30933 100644 (file)
@@ -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<T> {
                inner: T,
index e7b43ded11d3ee5bb19b6014cfbc9aa5a1deaf6d..d1fdb2e20eb8348be502882eca3f80822a8ad622 100644 (file)
@@ -2736,7 +2736,8 @@ impl<NS: Deref> ReadableArgs<(Option<PublicKey>, &NS)> for InboundOnionPayload w
                }, |msg_type: u64, msg_reader: &mut FixedLengthReader<_>| -> Result<bool, DecodeError> {
                        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)
                });
index a8f43c2d213141cf09e453c3855f05f7085edd4b..f1b7058c37f08b7b4adbab153b7cd09ac4f6dc09 100644 (file)
@@ -170,7 +170,8 @@ impl<L: Logger + ?Sized> 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),
index 200e3f5ac8196c022049b8227d7260a905b7faef..57fd05eb284b44d1bbac89e7abc8c2e09d2d4455 100644 (file)
@@ -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);
                                },
                        }