Skip to content

Commit 2156611

Browse files
authored
Merge pull request #391 from tnull/2024-10-cut-0.4.2
Cut v0.4.2
2 parents bcea1c2 + 8a7a591 commit 2156611

File tree

7 files changed

+65
-17
lines changed

7 files changed

+65
-17
lines changed

CHANGELOG.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
1+
# 0.4.2 - Oct 28, 2024
2+
3+
This patch release fixes an issue that prohibited the node from using available confirmed on-chain funds to spend/bump Anchor outputs (#387).
4+
5+
In total, this release features 1 files changed, 40 insertions, 4 deletions in 3 commits from 3 authors, in alphabetical order:
6+
7+
- Fuyin
8+
- Elias Rohrer
9+
10+
111
# 0.4.1 - Oct 18, 2024
212

3-
Fixes a wallet syncing issue where full syncs were used instead of incremental syncs, and vice versa (#383).
13+
This patch release fixes a wallet syncing issue where full syncs were used instead of incremental syncs, and vice versa (#383).
14+
15+
In total, this release features 3 files changed, 13 insertions, 9 deletions in 6 commits from 3 authors, in alphabetical order:
16+
17+
- Jeffrey Czyz
18+
- Elias Rohrer
19+
- Tommy Volk
420

521
# 0.4.0 - Oct 17, 2024
622

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ldk-node"
3-
version = "0.4.1"
3+
version = "0.4.2"
44
authors = ["Elias Rohrer <[email protected]>"]
55
homepage = "https://lightningdevkit.org/"
66
license = "MIT OR Apache-2.0"

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
import PackageDescription
55

6-
let tag = "v0.4.0"
7-
let checksum = "5dcdfdd6e3331062d649786fa6e758487227f6037d9881353fe0c293a3a4c7e0"
6+
let tag = "v0.4.2"
7+
let checksum = "95ea5307eb3a99203e39cfa21d962bfe3e879e62429e8c7cdf5292cae5dc35cc"
88
let url = "https://github.com/lightningdevkit/ldk-node/releases/download/\(tag)/LDKNodeFFI.xcframework.zip"
99

1010
let package = Package(

bindings/kotlin/ldk-node-android/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ org.gradle.jvmargs=-Xmx1536m
22
android.useAndroidX=true
33
android.enableJetifier=true
44
kotlin.code.style=official
5-
libraryVersion=0.4.0
5+
libraryVersion=0.4.2
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
org.gradle.jvmargs=-Xmx1536m
22
kotlin.code.style=official
3-
libraryVersion=0.4.0
3+
libraryVersion=0.4.2

bindings/python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "ldk_node"
3-
version = "0.4.0"
3+
version = "0.4.2"
44
authors = [
55
{ name="Elias Rohrer", email="[email protected]" },
66
]

src/wallet/mod.rs

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,16 @@ where
205205
) -> Result<(u64, u64), Error> {
206206
let balance = self.inner.lock().unwrap().balance();
207207

208+
// Make sure `list_confirmed_utxos` returns at least one `Utxo` we could use to spend/bump
209+
// Anchors if we have any confirmed amounts.
210+
#[cfg(debug_assertions)]
211+
if balance.confirmed != Amount::ZERO {
212+
debug_assert!(
213+
self.list_confirmed_utxos().map_or(false, |v| !v.is_empty()),
214+
"Confirmed amounts should always be available for Anchor spending"
215+
);
216+
}
217+
208218
let (total, spendable) = (
209219
balance.total().to_sat(),
210220
balance.trusted_spendable().to_sat().saturating_sub(total_anchor_channels_reserve_sats),
@@ -387,12 +397,23 @@ where
387397
let script_pubkey = u.txout.script_pubkey;
388398
match script_pubkey.witness_version() {
389399
Some(version @ WitnessVersion::V0) => {
400+
// According to the SegWit rules of [BIP 141] a witness program is defined as:
401+
// > A scriptPubKey (or redeemScript as defined in BIP16/P2SH) that consists of
402+
// > a 1-byte push opcode (one of OP_0,OP_1,OP_2,.. .,OP_16) followed by a direct
403+
// > data push between 2 and 40 bytes gets a new special meaning. The value of
404+
// > the first push is called the "version byte". The following byte vector
405+
// > pushed is called the "witness program"."
406+
//
407+
// We therefore skip the first byte we just read via `witness_version` and use
408+
// the rest (i.e., the data push) as the raw bytes to construct the
409+
// `WitnessProgram` below.
410+
//
411+
// [BIP 141]: https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#witness-program
412+
let witness_bytes = &script_pubkey.as_bytes()[2..];
390413
let witness_program =
391-
WitnessProgram::new(version, &script_pubkey.as_bytes()[2..]).map_err(
392-
|e| {
393-
log_error!(self.logger, "Failed to retrieve script payload: {}", e);
394-
},
395-
)?;
414+
WitnessProgram::new(version, witness_bytes).map_err(|e| {
415+
log_error!(self.logger, "Failed to retrieve script payload: {}", e);
416+
})?;
396417

397418
let wpkh = WPubkeyHash::from_slice(&witness_program.program().as_bytes())
398419
.map_err(|e| {
@@ -402,12 +423,23 @@ where
402423
utxos.push(utxo);
403424
},
404425
Some(version @ WitnessVersion::V1) => {
426+
// According to the SegWit rules of [BIP 141] a witness program is defined as:
427+
// > A scriptPubKey (or redeemScript as defined in BIP16/P2SH) that consists of
428+
// > a 1-byte push opcode (one of OP_0,OP_1,OP_2,.. .,OP_16) followed by a direct
429+
// > data push between 2 and 40 bytes gets a new special meaning. The value of
430+
// > the first push is called the "version byte". The following byte vector
431+
// > pushed is called the "witness program"."
432+
//
433+
// We therefore skip the first byte we just read via `witness_version` and use
434+
// the rest (i.e., the data push) as the raw bytes to construct the
435+
// `WitnessProgram` below.
436+
//
437+
// [BIP 141]: https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#witness-program
438+
let witness_bytes = &script_pubkey.as_bytes()[2..];
405439
let witness_program =
406-
WitnessProgram::new(version, &script_pubkey.as_bytes()[2..]).map_err(
407-
|e| {
408-
log_error!(self.logger, "Failed to retrieve script payload: {}", e);
409-
},
410-
)?;
440+
WitnessProgram::new(version, witness_bytes).map_err(|e| {
441+
log_error!(self.logger, "Failed to retrieve script payload: {}", e);
442+
})?;
411443

412444
XOnlyPublicKey::from_slice(&witness_program.program().as_bytes()).map_err(
413445
|e| {

0 commit comments

Comments
 (0)