]> git.bitcoin.ninja Git - rust-lightning/commitdiff
TODO: FIXME! experimental upgrade to bitcoin 0.32.2
authorArik Sosman <git@arik.io>
Thu, 27 Jun 2024 14:13:47 +0000 (10:13 -0400)
committerArik Sosman <git@arik.io>
Thu, 18 Jul 2024 08:06:44 +0000 (01:06 -0700)
14 files changed:
fuzz/Cargo.toml
lightning-background-processor/Cargo.toml
lightning-block-sync/Cargo.toml
lightning-custom-message/Cargo.toml
lightning-invoice/Cargo.toml
lightning-net-tokio/Cargo.toml
lightning-persister/Cargo.toml
lightning-rapid-gossip-sync/Cargo.toml
lightning-transaction-sync/Cargo.toml
lightning/Cargo.toml
lightning/src/chain/channelmonitor.rs
lightning/src/ln/chan_utils.rs
lightning/src/offers/invoice.rs
lightning/src/util/ser.rs

index 4d9f7e0dea33697c8ec85cad904c737a2ffde4b0..8946384259164dc6e23e653dc7aa65777fa2f3f6 100644 (file)
@@ -22,7 +22,7 @@ lightning = { path = "../lightning", features = ["regex", "hashbrown", "_test_ut
 lightning-invoice = { path = "../lightning-invoice" }
 lightning-rapid-gossip-sync = { path = "../lightning-rapid-gossip-sync" }
 bech32 = "0.9.1"
-bitcoin = { version = "0.31.2", features = ["secp-lowmemory"] }
+bitcoin = { version = "0.32.2", features = ["secp-lowmemory"] }
 hex = { package = "hex-conservative", version = "0.1.1", default-features = false }
 
 afl = { version = "0.12", optional = true }
index df4b2c8278e718a56e8f430e4000b0aef4bbbe30..c780cc3d64b4f58bed6f251b3fe9615a0ef4e992 100644 (file)
@@ -16,12 +16,12 @@ rustdoc-args = ["--cfg", "docsrs"]
 [features]
 futures = [ ]
 std = ["bitcoin/std", "lightning/std", "lightning-rapid-gossip-sync/std"]
-no-std = ["bitcoin/no-std", "lightning/no-std", "lightning-rapid-gossip-sync/no-std"]
+no-std = ["lightning/no-std", "lightning-rapid-gossip-sync/no-std"]
 
 default = ["std"]
 
 [dependencies]
-bitcoin = { version = "0.31.2", default-features = false }
+bitcoin = { version = "0.32.2", default-features = false }
 lightning = { version = "0.0.123-beta", path = "../lightning", default-features = false }
 lightning-rapid-gossip-sync = { version = "0.0.123-beta", path = "../lightning-rapid-gossip-sync", default-features = false }
 
index 2e827000017a63844ae3a2320f07e6c66bdfc03d..c02084c16b42b1d51b7ecc0ad141aeafc79c4cec 100644 (file)
@@ -18,7 +18,7 @@ rest-client = [ "serde_json", "chunked_transfer" ]
 rpc-client = [ "serde_json", "chunked_transfer" ]
 
 [dependencies]
-bitcoin = "0.31.2"
+bitcoin = "0.32.2"
 hex = { package = "hex-conservative", version = "0.1.1", default-features = false }
 lightning = { version = "0.0.123-beta", path = "../lightning" }
 tokio = { version = "1.35", features = [ "io-util", "net", "time", "rt" ], optional = true }
index f74ead81c9702bab28e4a0b1a669a25ebd952ad0..d3c2e57085e35b96671f98e895bd8a0d423515b2 100644 (file)
@@ -14,7 +14,7 @@ all-features = true
 rustdoc-args = ["--cfg", "docsrs"]
 
 [dependencies]
-bitcoin = "0.31.2"
+bitcoin = "0.32.2"
 lightning = { version = "0.0.123-beta", path = "../lightning" }
 
 [lints]
index d89f8d08e4a72f00e87e6ed9521d8ba4b6296c73..e7b14d8766fa0cd89c603ba770d1d351e91bd3f3 100644 (file)
@@ -24,7 +24,7 @@ bech32 = { version = "0.9.1", default-features = false }
 lightning = { version = "0.0.123-beta", path = "../lightning", default-features = false }
 secp256k1 = { version = "0.28.0", default-features = false, features = ["recovery", "alloc"] }
 serde = { version = "1.0.118", optional = true }
-bitcoin = { version = "0.31.2", default-features = false }
+bitcoin = { version = "0.32.2", default-features = false }
 
 [dev-dependencies]
 lightning = { version = "0.0.123-beta", path = "../lightning", default-features = false, features = ["_test_utils"] }
index c56553711454b4f3aae3885651f0b3793acd9b25..ede8cc0a73a2caae6d7a0fca9bc3bf7b1dd161ad 100644 (file)
@@ -15,7 +15,7 @@ all-features = true
 rustdoc-args = ["--cfg", "docsrs"]
 
 [dependencies]
-bitcoin = "0.31.2"
+bitcoin = "0.32.2"
 lightning = { version = "0.0.123-beta", path = "../lightning" }
 tokio = { version = "1.35", features = [ "rt", "sync", "net", "time" ] }
 
index 5f1e2774064f670c624b8d906079701c30f811af..e315fb791b2bd0c3df37703708bf60dccf4b1c09 100644 (file)
@@ -14,7 +14,7 @@ all-features = true
 rustdoc-args = ["--cfg", "docsrs"]
 
 [dependencies]
-bitcoin = "0.31.2"
+bitcoin = "0.32.2"
 lightning = { version = "0.0.123-beta", path = "../lightning" }
 
 [target.'cfg(windows)'.dependencies]
@@ -25,7 +25,7 @@ criterion = { version = "0.4", optional = true, default-features = false }
 
 [dev-dependencies]
 lightning = { version = "0.0.123-beta", path = "../lightning", features = ["_test_utils"] }
-bitcoin = { version = "0.31.2", default-features = false }
+bitcoin = { version = "0.32.2", default-features = false }
 
 [lints]
 workspace = true
index 7ca67a38ec8d5faf2507fda441d4917632023a08..9d9f3d23eb0330843a18c32df106df63c6af0597 100644 (file)
@@ -16,7 +16,7 @@ std = ["lightning/std"]
 
 [dependencies]
 lightning = { version = "0.0.123-beta", path = "../lightning", default-features = false }
-bitcoin = { version = "0.31.2", default-features = false }
+bitcoin = { version = "0.32.2", default-features = false }
 
 [target.'cfg(ldk_bench)'.dependencies]
 criterion = { version = "0.4", optional = true, default-features = false }
index ab796749954dbf7c33bf1e35e94ea800cf13b669..0243d76040ba42ba789bc71aabe82db78d2a7f70 100644 (file)
@@ -24,7 +24,7 @@ async-interface = []
 
 [dependencies]
 lightning = { version = "0.0.123-beta", path = "../lightning", default-features = false, features = ["std"] }
-bitcoin = { version = "0.31.2", default-features = false }
+bitcoin = { version = "0.32.2", default-features = false }
 bdk-macros = "0.6"
 futures = { version = "0.3", optional = true }
 esplora-client = { version = "0.7", default-features = false, optional = true }
index cf4a5329476dd2c88e9c5de9cf9fceb7d71ac740..dfb17b957299a3e4ceb29f00260b94754aaa9ada 100644 (file)
@@ -31,7 +31,7 @@ unsafe_revoked_tx_signing = []
 # Override signing to not include randomness when generating signatures for test vectors.
 _test_vectors = []
 
-no-std = ["hashbrown", "possiblyrandom", "bitcoin/no-std", "core2/alloc", "libm"]
+no-std = ["hashbrown", "possiblyrandom", "core2/alloc", "libm"]
 std = ["bitcoin/std", "bech32/std"]
 
 # Generates low-r bitcoin signatures, which saves 1 byte in 50% of the cases
@@ -41,7 +41,7 @@ default = ["std", "grind_signatures"]
 
 [dependencies]
 bech32 = { version = "0.9.1", default-features = false }
-bitcoin = { version = "0.31.2", default-features = false, features = ["secp-recovery"] }
+bitcoin = { version = "0.32.2", default-features = false, features = ["secp-recovery"] }
 
 hashbrown = { version = "0.13", optional = true, default-features = false }
 possiblyrandom = { version = "0.2", optional = true, default-features = false }
@@ -56,7 +56,7 @@ libm = { version = "0.2", optional = true, default-features = false }
 regex = "1.5.6"
 
 [dev-dependencies.bitcoin]
-version = "0.31.2"
+version = "0.32.2"
 default-features = false
 features = ["bitcoinconsensus", "secp-recovery"]
 
@@ -64,7 +64,7 @@ features = ["bitcoinconsensus", "secp-recovery"]
 criterion = { version = "0.4", optional = true, default-features = false }
 
 [target.'cfg(taproot)'.dependencies]
-musig2 = { git = "https://github.com/arik-so/rust-musig2", rev = "739533fc" }
+musig2 = { git = "https://github.com/arik-so/rust-musig2", rev = "6f95a05718cbb44d8fe3fa6021aea8117aa38d50" }
 
 [lints]
 workspace = true
index 13f2ff044a2d412968bd7e48a5ae256fc70dda16..36bda0d82e6c08a13e03da19fa1d715748e7343f 100644 (file)
@@ -32,7 +32,7 @@ use bitcoin::hash_types::{Txid, BlockHash};
 use bitcoin::ecdsa::Signature as BitcoinSignature;
 use bitcoin::secp256k1::{Secp256k1, ecdsa::Signature};
 use bitcoin::secp256k1::{SecretKey, PublicKey};
-use bitcoin::secp256k1;
+use bitcoin::{CompressedPublicKey, secp256k1};
 
 use crate::ln::channel::INITIAL_COMMITMENT_NUMBER;
 use crate::ln::types::{PaymentHash, PaymentPreimage, ChannelId};
@@ -4077,7 +4077,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
 
                                                                assert_eq!(&bitcoin::Address::p2wsh(&ScriptBuf::from(input.witness.last().unwrap().to_vec()), bitcoin::Network::Bitcoin).script_pubkey(), _script_pubkey);
                                                        } else if _script_pubkey.is_p2wpkh() {
-                                                               assert_eq!(&bitcoin::Address::p2wpkh(&bitcoin::PublicKey::from_slice(&input.witness.last().unwrap()).unwrap(), bitcoin::Network::Bitcoin).unwrap().script_pubkey(), _script_pubkey);
+                                                               assert_eq!(&bitcoin::Address::p2wpkh(&CompressedPublicKey(bitcoin::PublicKey::from_slice(&input.witness.last().unwrap()).unwrap().inner), bitcoin::Network::Bitcoin).script_pubkey(), _script_pubkey);
                                                        } else { panic!(); }
                                                }
                                                return true;
index ffdbfe919a0c4ed243abfc4fd344827ba18e6e64..c3aa3e17ee37a56f4284710e5104b7d5479474fe 100644 (file)
@@ -1844,7 +1844,6 @@ mod tests {
        use bitcoin::hashes::Hash;
        use bitcoin::hashes::hex::FromHex;
        use crate::ln::types::PaymentHash;
-       use bitcoin::address::Payload;
        use bitcoin::PublicKey as BitcoinPublicKey;
        use crate::ln::features::ChannelTypeFeatures;
 
@@ -1917,7 +1916,7 @@ mod tests {
                // Generate broadcaster and counterparty outputs
                let tx = builder.build(1000, 2000);
                assert_eq!(tx.built.transaction.output.len(), 2);
-               assert_eq!(tx.built.transaction.output[1].script_pubkey, Payload::p2wpkh(&BitcoinPublicKey::new(builder.counterparty_pubkeys.payment_point)).unwrap().script_pubkey());
+               assert_eq!(tx.built.transaction.output[1].script_pubkey, BitcoinPublicKey::new(builder.counterparty_pubkeys.payment_point).p2wpkh_script_code().unwrap());
 
                // Generate broadcaster and counterparty outputs as well as two anchors
                builder.channel_parameters.channel_type_features = ChannelTypeFeatures::anchors_zero_htlc_fee_and_dependencies();
index 3f96e703b2a6dcae21bef4019070c4f792da24ce..c4f4e4a43e046d8f1f4b524c22371f91508e2b07 100644 (file)
 //!
 //! ```
 
-use bitcoin::{WitnessProgram, Network, WitnessVersion};
+use bitcoin::{Network, WitnessVersion};
 use bitcoin::blockdata::constants::ChainHash;
 use bitcoin::secp256k1::{Keypair, PublicKey, Secp256k1, self};
 use bitcoin::secp256k1::schnorr::Signature;
-use bitcoin::address::{Address, Payload};
+use bitcoin::address::Address;
+use bitcoin::blockdata::script::witness_program::WitnessProgram;
 use core::time::Duration;
 use core::hash::{Hash, Hasher};
 use crate::io;
@@ -1074,12 +1075,11 @@ pub(super) fn filter_fallbacks(
                        Err(_) => return None,
                };
 
-               let program = address.program.clone();
-               let witness_program = match WitnessProgram::new(version, program) {
+               let witness_program = match WitnessProgram::new(version, &address.program) {
                        Ok(witness_program) => witness_program,
                        Err(_) => return None,
                };
-               Some(Address::new(network, Payload::WitnessProgram(witness_program)))
+               Some(Address::from_witness_program(witness_program, network.into()))
        };
 
        fallbacks.iter().filter_map(to_valid_address).collect()
@@ -1398,13 +1398,13 @@ pub(super) fn check_invoice_signing_pubkey(
 mod tests {
        use super::{Bolt12Invoice, DEFAULT_RELATIVE_EXPIRY, FallbackAddress, FullInvoiceTlvStreamRef, InvoiceTlvStreamRef, SIGNATURE_TAG, UnsignedBolt12Invoice};
 
-       use bitcoin::{WitnessProgram, WitnessVersion};
+       use bitcoin::{CompressedPublicKey, WitnessProgram, WitnessVersion};
        use bitcoin::blockdata::constants::ChainHash;
        use bitcoin::blockdata::script::ScriptBuf;
        use bitcoin::hashes::Hash;
        use bitcoin::network::Network;
        use bitcoin::secp256k1::{Keypair, Message, Secp256k1, SecretKey, XOnlyPublicKey, self};
-       use bitcoin::address::{Address, Payload};
+       use bitcoin::address::Address;
        use bitcoin::key::TweakedPublicKey;
 
        use core::time::Duration;
@@ -2242,16 +2242,16 @@ mod tests {
 
                match Bolt12Invoice::try_from(buffer) {
                        Ok(invoice) => {
-                               let v1_witness_program = WitnessProgram::new(WitnessVersion::V1, vec![0u8; 33]).unwrap();
-                               let v2_witness_program = WitnessProgram::new(WitnessVersion::V2, vec![0u8; 40]).unwrap();
+                               let v1_witness_program = WitnessProgram::new(WitnessVersion::V1, &vec![0u8; 33]).unwrap();
+                               let v2_witness_program = WitnessProgram::new(WitnessVersion::V2, &vec![0u8; 40]).unwrap();
                                assert_eq!(
                                        invoice.fallbacks(),
                                        vec![
                                                Address::p2wsh(&script, Network::Bitcoin),
-                                               Address::p2wpkh(&pubkey, Network::Bitcoin).unwrap(),
+                                               Address::p2wpkh(&CompressedPublicKey(pubkey.inner), Network::Bitcoin).unwrap(),
                                                Address::p2tr_tweaked(tweaked_pubkey, Network::Bitcoin),
-                                               Address::new(Network::Bitcoin, Payload::WitnessProgram(v1_witness_program)),
-                                               Address::new(Network::Bitcoin, Payload::WitnessProgram(v2_witness_program)),
+                                               Address::from_witness_program(v1_witness_program, Network::Bitcoin.into()),
+                                               Address::from_witness_program(v2_witness_program, Network::Bitcoin.into()),
                                        ],
                                );
                        },
index 5f109e1a93c64529d09e462899fb539abf662c68..42efdc46d590200c3ce13368236b9f9dcefae3a5 100644 (file)
@@ -1245,9 +1245,35 @@ macro_rules! impl_consensus_ser {
                }
        }
 }
+
+impl Into<io::ErrorKind> for bitcoin::io::ErrorKind {
+       fn into(self) -> io::ErrorKind {
+               todo!()
+       }
+}
+
+impl Writeable for Witness {
+       fn write<W: Writer>(&self, writer: &mut W) -> Result<(), io::Error> {
+               match self.consensus_encode(&mut WriterWriteAdaptor(writer)) {
+                       Ok(_) => Ok(()),
+                       Err(e) => Err(e.into()),
+               }
+       }
+}
+impl Readable for Witness {
+       fn read<R: Read>(r: &mut R) -> Result<Self, DecodeError> {
+               match consensus::encode::Decodable::consensus_decode(r) {
+                       Ok(t) => Ok(t),
+                       Err(consensus::encode::Error::Io(ref e))   if e.kind() == bitcoin::io::ErrorKind::UnexpectedEof => Err(DecodeError::ShortRead),
+                       Err(consensus::encode::Error::Io(e)) => Err(DecodeError::Io(e.kind())),
+                       Err(_) => Err(DecodeError::InvalidValue),
+               }
+       }
+}
+
 impl_consensus_ser!(Transaction);
 impl_consensus_ser!(TxOut);
-impl_consensus_ser!(Witness);
+// impl_consensus_ser!(Witness);
 
 impl<T: Readable> Readable for Mutex<T> {
        fn read<R: Read>(r: &mut R) -> Result<Self, DecodeError> {