diff --git a/CHANGELOG.md b/CHANGELOG.md index 353d4744f..7cc63ec27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,22 @@ +# 0.4.2 - Oct 28, 2024 + +This patch release fixes an issue that prohibited the node from using available confirmed on-chain funds to spend/bump Anchor outputs (#387). + +In total, this release features 1 files changed, 40 insertions, 4 deletions in 3 commits from 3 authors, in alphabetical order: + +- Fuyin +- Elias Rohrer + + # 0.4.1 - Oct 18, 2024 -Fixes a wallet syncing issue where full syncs were used instead of incremental syncs, and vice versa (#383). +This patch release fixes a wallet syncing issue where full syncs were used instead of incremental syncs, and vice versa (#383). + +In total, this release features 3 files changed, 13 insertions, 9 deletions in 6 commits from 3 authors, in alphabetical order: + +- Jeffrey Czyz +- Elias Rohrer +- Tommy Volk # 0.4.0 - Oct 17, 2024 diff --git a/Cargo.toml b/Cargo.toml index 3a2b05369..e45e68464 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ldk-node" -version = "0.4.1" +version = "0.4.2" authors = ["Elias Rohrer "] homepage = "https://lightningdevkit.org/" license = "MIT OR Apache-2.0" diff --git a/Package.swift b/Package.swift index 253db6e68..059052492 100644 --- a/Package.swift +++ b/Package.swift @@ -3,8 +3,8 @@ import PackageDescription -let tag = "v0.4.0" -let checksum = "5dcdfdd6e3331062d649786fa6e758487227f6037d9881353fe0c293a3a4c7e0" +let tag = "v0.4.2" +let checksum = "95ea5307eb3a99203e39cfa21d962bfe3e879e62429e8c7cdf5292cae5dc35cc" let url = "https://github.com/lightningdevkit/ldk-node/releases/download/\(tag)/LDKNodeFFI.xcframework.zip" let package = Package( diff --git a/bindings/kotlin/ldk-node-android/gradle.properties b/bindings/kotlin/ldk-node-android/gradle.properties index c84f2c46c..44a51cfaf 100644 --- a/bindings/kotlin/ldk-node-android/gradle.properties +++ b/bindings/kotlin/ldk-node-android/gradle.properties @@ -2,4 +2,4 @@ org.gradle.jvmargs=-Xmx1536m android.useAndroidX=true android.enableJetifier=true kotlin.code.style=official -libraryVersion=0.4.0 +libraryVersion=0.4.2 diff --git a/bindings/kotlin/ldk-node-jvm/gradle.properties b/bindings/kotlin/ldk-node-jvm/gradle.properties index a84d6e412..338b60d96 100644 --- a/bindings/kotlin/ldk-node-jvm/gradle.properties +++ b/bindings/kotlin/ldk-node-jvm/gradle.properties @@ -1,3 +1,3 @@ org.gradle.jvmargs=-Xmx1536m kotlin.code.style=official -libraryVersion=0.4.0 +libraryVersion=0.4.2 diff --git a/bindings/python/pyproject.toml b/bindings/python/pyproject.toml index 7d24d7884..781542ec3 100644 --- a/bindings/python/pyproject.toml +++ b/bindings/python/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "ldk_node" -version = "0.4.0" +version = "0.4.2" authors = [ { name="Elias Rohrer", email="dev@tnull.de" }, ] diff --git a/src/wallet/mod.rs b/src/wallet/mod.rs index 494fcd768..d237e8c6a 100644 --- a/src/wallet/mod.rs +++ b/src/wallet/mod.rs @@ -205,6 +205,16 @@ where ) -> Result<(u64, u64), Error> { let balance = self.inner.lock().unwrap().balance(); + // Make sure `list_confirmed_utxos` returns at least one `Utxo` we could use to spend/bump + // Anchors if we have any confirmed amounts. + #[cfg(debug_assertions)] + if balance.confirmed != Amount::ZERO { + debug_assert!( + self.list_confirmed_utxos().map_or(false, |v| !v.is_empty()), + "Confirmed amounts should always be available for Anchor spending" + ); + } + let (total, spendable) = ( balance.total().to_sat(), balance.trusted_spendable().to_sat().saturating_sub(total_anchor_channels_reserve_sats), @@ -387,8 +397,21 @@ where let script_pubkey = u.txout.script_pubkey; match script_pubkey.witness_version() { Some(version @ WitnessVersion::V0) => { - let witness_program = WitnessProgram::new(version, script_pubkey.as_bytes()) - .map_err(|e| { + // According to the SegWit rules of [BIP 141] a witness program is defined as: + // > A scriptPubKey (or redeemScript as defined in BIP16/P2SH) that consists of + // > a 1-byte push opcode (one of OP_0,OP_1,OP_2,.. .,OP_16) followed by a direct + // > data push between 2 and 40 bytes gets a new special meaning. The value of + // > the first push is called the "version byte". The following byte vector + // > pushed is called the "witness program"." + // + // We therefore skip the first byte we just read via `witness_version` and use + // the rest (i.e., the data push) as the raw bytes to construct the + // `WitnessProgram` below. + // + // [BIP 141]: https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#witness-program + let witness_bytes = &script_pubkey.as_bytes()[2..]; + let witness_program = + WitnessProgram::new(version, witness_bytes).map_err(|e| { log_error!(self.logger, "Failed to retrieve script payload: {}", e); })?; @@ -400,8 +423,21 @@ where utxos.push(utxo); }, Some(version @ WitnessVersion::V1) => { - let witness_program = WitnessProgram::new(version, script_pubkey.as_bytes()) - .map_err(|e| { + // According to the SegWit rules of [BIP 141] a witness program is defined as: + // > A scriptPubKey (or redeemScript as defined in BIP16/P2SH) that consists of + // > a 1-byte push opcode (one of OP_0,OP_1,OP_2,.. .,OP_16) followed by a direct + // > data push between 2 and 40 bytes gets a new special meaning. The value of + // > the first push is called the "version byte". The following byte vector + // > pushed is called the "witness program"." + // + // We therefore skip the first byte we just read via `witness_version` and use + // the rest (i.e., the data push) as the raw bytes to construct the + // `WitnessProgram` below. + // + // [BIP 141]: https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#witness-program + let witness_bytes = &script_pubkey.as_bytes()[2..]; + let witness_program = + WitnessProgram::new(version, witness_bytes).map_err(|e| { log_error!(self.logger, "Failed to retrieve script payload: {}", e); })?;