Skip to content

Proposal: implement custom TLV records for spontaneous payments #273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 113 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
fbb04e4
Pass custom TLVs with keysend requests.
rdmitr Feb 27, 2024
bd1459b
Add specific error code for invalid custom TLVs.
rdmitr Mar 1, 2024
9708a42
Add custom TLVs to the test.
rdmitr Mar 1, 2024
f545a42
Fix Display trait implementation for Error.
rdmitr Mar 1, 2024
7638cec
Add the new error code to UDL.
rdmitr Mar 1, 2024
02f0000
Add `fee_paid_msat` to `PaymentSuccessful` event (#271)
jbesraa Mar 7, 2024
9f68aee
Move `common` test module to `common/mod.rs`
tnull Mar 7, 2024
d79b8ae
Return payment hash directly from `expect_payment_received` macro
tnull Mar 7, 2024
1cf74c6
Merge pull request #274 from tnull/2024-03-271-followup
tnull Mar 7, 2024
84ecc24
Introduce `status` method allowing to query the `Node`'s status
tnull Mar 6, 2024
0396fc5
Allow to retrieve the `Node`'s `Config`
tnull Mar 6, 2024
b052f15
Use `is_listening` flag in `connection_restart_behavior` test
tnull Mar 6, 2024
cdeeb7f
Merge pull request #272 from tnull/2024-03-add-node-status
tnull Mar 8, 2024
059ff2d
Pin `reqwest` to fix MSRV builds in CI
tnull Mar 11, 2024
3ae80be
Merge pull request #275 from tnull/2024-03-pin-reqwest-for-msrv
tnull Mar 11, 2024
71b1d3c
Drop `reqwest` pin (#276)
tnull Mar 14, 2024
a624501
Upgrade to LDK v0.0.123-beta
tnull Feb 7, 2024
4564ec1
Migrate to the upstreamed `OutputSweeper`
tnull Apr 22, 2024
9be82cc
Merge pull request #243 from tnull/2024-02-upgrade-to-LDK-v0.0.122
tnull Apr 25, 2024
c49c3d7
Drop `KVStore` generic from `Node`
tnull Jan 30, 2024
ba28a8d
Drop unnecessary `LDKNode` type alias completely
tnull Feb 7, 2024
c566fd5
Expose `build_with_fs_store` in bindings
tnull Feb 7, 2024
0bf24c8
Merge pull request #244 from tnull/2024-02-switch-to-dyn-kvstore
tnull Apr 25, 2024
e3dc93a
Move connection logic to `connection.rs`
tnull Feb 21, 2024
872579f
Require `Clone + Sync + Send + 'static` for event and connection loggers
tnull Feb 21, 2024
9c8be40
Use `tokio::select` on `connection_closed_future`
tnull Mar 4, 2024
2d9fe95
Add test for concurrent connection handling
tnull Mar 4, 2024
77c538b
Add `ConnectionManager` handling pending connections
tnull Mar 4, 2024
640a1fd
Merge pull request #266 from tnull/2024-03-introduce-connection-manager
tnull Apr 25, 2024
be43848
Bump LDK to v0.0.123, lightning-liquidity to v0.1.0-alpha.4
tnull May 13, 2024
9f27fcb
Merge pull request #291 from tnull/2024-05-upgrade-to-LDK-v0.0.123
tnull May 13, 2024
4d7c9f3
Refactored necessary files to improve code quality
srikanth-iyengar Apr 30, 2024
e14b70e
Merge pull request #287 from srikanth-iyengar/improve-code-quality
tnull May 13, 2024
b784f0b
Move BOLT11 payments API to `Bolt11PaymentHandler`
tnull Mar 5, 2024
38eb21e
Move spontaneous payments API to `SpontaneousPaymentHandler`
tnull Mar 5, 2024
5e502e6
Move onchain payments API to `OnchainPaymentHandler`
tnull Mar 5, 2024
a78ed43
Move `payment_store` to `payment` submodule
tnull Mar 5, 2024
7cd8a72
Introduce `PaymentKind` to payment store, track by `PaymentId`
tnull Mar 8, 2024
51e2580
Add test ensuring de/ser compatibility with old format
tnull Mar 11, 2024
1fab656
Add `payment_id` to `Payment{Successful,Failed,Received}` events
tnull Mar 11, 2024
b7c4862
Merge pull request #270 from tnull/2024-03-payment-api-refactor
tnull May 15, 2024
c418c7d
Update `uniffi_bindgen_generate_swift.sh` to include patch
tnull May 20, 2024
6dec002
Fix Swift builds
tnull May 20, 2024
daf20e3
Merge pull request #294 from tnull/2024-05-fix-swift-builds
tnull May 21, 2024
d912a99
Update CHANGELOG for v0.2.2
tnull May 21, 2024
246775d
Merge pull request #297 from tnull/2024-05-add-0.2.2-release-notes
tnull May 21, 2024
278a849
Update `OffersMessageHandler` and `MessageRouter` types
tnull Mar 12, 2024
7c9216e
Handle `ConnectionNeeded` events
tnull Feb 21, 2024
2d70e65
Add `Bolt12` variant to `PaymentKind`
tnull Mar 8, 2024
9a3f169
Introduce `Bolt12Payment` API
tnull Mar 5, 2024
8a67d7e
Handle `InvoiceRequestFailed` event
tnull Mar 12, 2024
962476a
Update the payment store in event handling
tnull Mar 12, 2024
1e522d0
Shorten node ann. broadcast timer in tests
tnull Mar 12, 2024
5361d9f
Add simple BOLT12 send/receive test
tnull Mar 12, 2024
d57f67f
Implement and test `Refund` flow
tnull May 23, 2024
82b85c1
Check `PaymentKind` explicitly in `full_cycle` tests
tnull May 31, 2024
9990e51
Merge pull request #256 from tnull/2024-02-add-bolt12-support
tnull May 31, 2024
0285b55
Pin `url` to v2.5.0 in CI to fix MSRV breakage
tnull Jun 11, 2024
1eab306
Merge pull request #306 from tnull/2024-06-pin-url
tnull Jun 11, 2024
a2691e7
Introduce `AnchorChannelsConfig`
tnull Feb 6, 2024
db1b373
Implement Anchor channel event handling
tnull Jun 27, 2023
1952802
Maintain and expose anchor reserve
tnull Feb 19, 2024
5ba1b35
Use Anchor channels in CLN integration test
tnull Feb 20, 2024
1887af8
Add `force_close` method to allow channel force-closure
tnull Feb 26, 2024
0aaa8f1
Test force-closure 'happy' case
tnull May 17, 2024
436f2e4
Use internal addresses/`LastUnused` for change scripts
tnull May 17, 2024
2562f52
Merge pull request #141 from tnull/2023-07-add-anchor-support
tnull Jun 11, 2024
5418cc8
Rename `types::NetworkGraph` to `types::Graph`
tnull May 20, 2024
35e4968
Expose `NetworkGraph` accessors
tnull May 20, 2024
de73ddc
Periodically archive fully-resolved channel monitors
tnull Jun 11, 2024
a503eb5
f Rename the const to `RESOLVED_CHANNEL_MONITOR_ARCHIVAL_INTERVAL`
tnull Jun 11, 2024
9dba3ac
Also update `latest_sync_` timestamps in `sync_wallets`
tnull Jun 11, 2024
accd3c8
Also update the fee rate cache in `sync_wallets`
tnull Jun 11, 2024
9c44041
Merge pull request #293 from tnull/2024-05-expose-network-graph
tnull Jun 12, 2024
3a328d4
Merge pull request #307 from tnull/2024-06-archive-fully-resolved-mon…
tnull Jun 14, 2024
ddc6430
Consolidate setting `UserConfig` defaults
tnull May 30, 2024
dc5d00e
Bump `max_inbound_htlc_value_in_flight` for priv. outbound channels
tnull May 30, 2024
0e02969
Merge pull request #303 from tnull/2024-05-bump-max-inflight-for-outb…
tnull Jun 14, 2024
bc1fac3
Skip node ann. broadcast if the public channel isn't ready yet
tnull Jun 17, 2024
4201760
Merge pull request #314 from tnull/2024-06-only-broadcast-node-ann-wh…
tnull Jun 17, 2024
41a7955
Log node ID in `start`/`stop`
tnull Jun 17, 2024
07d020c
Merge pull request #311 from tnull/2024-06-log-node-id-on-startup
tnull Jun 18, 2024
018a5b6
Allow to generate invoices for custom payment hashes
tnull Jun 14, 2024
be6e8c2
Implement and yield `PaymentClaimable` events
tnull Jun 14, 2024
d5709b7
Test manual-claiming flow
tnull Jun 14, 2024
74943cd
Refuse circular payments
tnull Jun 14, 2024
a678c5e
Add a `latest_update_timestamp` field to `PaymentDetails`
tnull Jun 14, 2024
b180a65
Merge pull request #308 from tnull/2024-06-manual-payment-hash-regist…
tnull Jun 20, 2024
80d24c3
Introduce `balance_cache` to avoid blocking on retrieving balances
tnull Mar 18, 2024
e3279d7
Drop potentially dangerous `sync_lock` `Condvar` and use pub/sub model
tnull Apr 12, 2024
fd4b33f
Drop immediate-retry logic in `wallet`
tnull Apr 12, 2024
82ab9ac
Drop immediate-retry logic in `tx_broadcaster`
tnull Jun 18, 2024
f58f00f
Add timeout for on-chain syncing
tnull May 15, 2024
746014c
Add timeout for Lightning syncing
tnull May 15, 2024
02e4b3f
Add timeout for fee rate cache updates
tnull May 15, 2024
b0a1dfc
Add timeout for RGS updates
tnull May 15, 2024
d67a3af
Add timeout for broadcasting transactions
tnull Jun 18, 2024
de69c75
Log shutdowns of background tasks
tnull May 15, 2024
0a0ccb1
Shutdown: Wait for event processing to fully stop
tnull May 15, 2024
5095d42
Bump `tokio` version to 1.37
tnull May 15, 2024
f839015
Also apply a general 10 second socket timeout for the Esplora client
tnull Jun 18, 2024
ca44721
Merge pull request #281 from tnull/2024-04-improve-on-wallet-friction
tnull Jun 20, 2024
2b8ca85
Cut v0.3.0 release
tnull Jun 21, 2024
8680d07
Update Swift files
tnull Jun 21, 2024
bd9bd68
Merge pull request #316 from tnull/2024-06-cut-v0.3-release
tnull Jun 21, 2024
182bc21
Fix inbound capacity comment
elnosh Jun 21, 2024
66fec69
Merge pull request #317 from elnosh/fix-inbound-comment
tnull Jun 23, 2024
28d2d77
Pass custom TLVs with keysend requests.
rdmitr Feb 27, 2024
37db97d
Add specific error code for invalid custom TLVs.
rdmitr Mar 1, 2024
caa08d7
Fix Display trait implementation for Error.
rdmitr Mar 1, 2024
047b167
Add the new error code to UDL.
rdmitr Mar 1, 2024
f708737
Merge main and re-apply changes.
rdmitr Jun 25, 2024
1dda9c7
Merge remote-tracking branch 'refs/remotes/origin/keysend-custom-tlvs…
rdmitr Jun 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ jobs:
cargo update -p hashlink --precise "0.8.2" --verbose # hashlink 0.8.3 requires hashbrown 0.14, requiring 1.64.0
cargo update -p proptest --precise "1.2.0" --verbose # proptest 1.3.0 requires rustc 1.64.0
cargo update -p regex --precise "1.9.6" --verbose # regex 1.10.0 requires rustc 1.65.0
cargo update -p home --precise "0.5.5" --verbose # home v0.5.9, requires rustc 1.70 or newer
cargo update -p home --precise "0.5.5" --verbose # home v0.5.9 requires rustc 1.70 or newer
cargo update -p url --precise "2.5.0" --verbose # url v2.5.1 requires rustc 1.67 or newer
- name: Set RUSTFLAGS to deny warnings
if: "matrix.toolchain == 'stable'"
run: echo "RUSTFLAGS=-D warnings" >> "$GITHUB_ENV"
Expand Down
52 changes: 52 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,55 @@
# 0.3.0 - June 21, 2024

This third minor release notably adds support for BOLT12 payments, Anchor
channels, and sourcing inbound liquidity via LSPS2 just-in-time channels.

## Feature and API updates
- Support for creating and paying BOLT12 offers and refunds has been added (#265).
- Support for Anchor channels has been added (#141).
- Support for sourcing inbound liquidity via LSPS2 just-in-time (JIT) channels has been added (#223).
- The node's local view of the network graph can now be accessed via interface methods (#293).
- A new `next_event_async` method was added that allows polling the event queue asynchronously (#224).
- A `default_config` method was introduced that allows to retrieve sane default values, also in bindings (#242).
- The `PaymentFailed` and `ChannelClosed` events now include `reason` fields (#260).
- All available balances outside of channel balances are now exposed via a unified `list_balances` interface method (#250).
- The maximum in-flight HTLC value has been bumped to 100% of the channel capacity for private outbound channels (#303) and, if JIT channel support is enabled, for inbound channels (#262).
- The fee paid is now exposed via the `PaymentSuccessful` event (#271).
- A `status` method has been added allowing to retrieve information about the `Node`'s status (#272).
- `Node` no longer takes a `KVStore` type parameter, allowing to use the filesystem storage backend in bindings (#244).
- The payment APIs have been restructured to use per-type (`bolt11`, `onchain`, `bolt12`, ..) payment handlers which can be accessed via corresponding `Node::{type}_payment` methods (#270).
- Fully resolved channel monitors are now eventually moved to an archive location (#307).
- The ability to register and claim from custom payment hashes generated outside of LDK Node has been added (#308).

## Bug Fixes
- Node announcements are now correctly only broadcast if we have any public, sufficiently confirmed channels (#248, #314).
- Falling back to default fee values is now disallowed on mainnet, ensuring we won't startup without a successful fee cache update (#249).
- Persisted peers are now correctly reconnected after startup (#265).
- Concurrent connection attempts to the same peer are no longer overriding each other (#266).
- Several steps have been taken to reduce the risk of blocking node operation on wallet syncing in the face of unresponsive Esplora services (#281).

## Compatibility Notes
- LDK has been updated to version 0.0.123 (#291).

In total, this release features 54 files changed, 7282 insertions, 2410 deletions in 165 commits from 3 authors, in alphabetical order:

- Elias Rohrer
- jbesraa
- Srikanth Iyengar

# 0.2.2 - May 21, 2024

This is a bugfix release that reestablishes compatibility of Swift packages
with Xcode 15.3 and later.

## Bug Fixes

- Swift bindings can now be built using Xcode 15.3 and later again (#294)

In total, this release features 5 files changed, 66 insertions, 2 deletions
deletions in 2 commits from 1 author, in alphabetical order:

- Elias Rohrer

# 0.2.1 - Jan 26, 2024

This is a bugfix release bumping the used LDK and BDK dependencies to the
Expand Down
23 changes: 11 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ldk-node"
version = "0.2.1"
version = "0.3.0"
authors = ["Elias Rohrer <dev@tnull.de>"]
homepage = "https://lightningdevkit.org/"
license = "MIT OR Apache-2.0"
Expand Down Expand Up @@ -28,14 +28,14 @@ panic = 'abort' # Abort on panic
default = []

[dependencies]
lightning = { version = "0.0.121", features = ["std"] }
lightning-invoice = { version = "0.29.0" }
lightning-net-tokio = { version = "0.0.121" }
lightning-persister = { version = "0.0.121" }
lightning-background-processor = { version = "0.0.121", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.0.121" }
lightning-transaction-sync = { version = "0.0.121", features = ["esplora-async-https", "time"] }
lightning-liquidity = { version = "0.1.0-alpha.1", features = ["std"] }
lightning = { version = "0.0.123", features = ["std"] }
lightning-invoice = { version = "0.31.0" }
lightning-net-tokio = { version = "0.0.123" }
lightning-persister = { version = "0.0.123" }
lightning-background-processor = { version = "0.0.123", features = ["futures"] }
lightning-rapid-gossip-sync = { version = "0.0.123" }
lightning-transaction-sync = { version = "0.0.123", features = ["esplora-async-https", "time"] }
lightning-liquidity = { version = "0.1.0-alpha.4", features = ["std"] }

#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std"] }
#lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main" }
Expand Down Expand Up @@ -64,8 +64,7 @@ bip39 = "2.0.0"

rand = "0.8.5"
chrono = { version = "0.4", default-features = false, features = ["clock"] }
futures = "0.3"
tokio = { version = "1", default-features = false, features = [ "rt-multi-thread", "time", "sync" ] }
tokio = { version = "1.37", default-features = false, features = [ "rt-multi-thread", "time", "sync" ] }
esplora-client = { version = "0.6", default-features = false }
libc = "0.2"
uniffi = { version = "0.26.0", features = ["build"], optional = true }
Expand All @@ -78,7 +77,7 @@ prost = { version = "0.11.6", default-features = false}
winapi = { version = "0.3", features = ["winbase"] }

[dev-dependencies]
lightning = { version = "0.0.121", features = ["std", "_test_utils"] }
lightning = { version = "0.0.123", features = ["std", "_test_utils"] }
#lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch="main", features = ["std", "_test_utils"] }
electrum-client = { version = "0.15.1", default-features = true }
bitcoincore-rpc = { version = "0.17.0", default-features = false }
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import PackageDescription

let tag = "v0.2.1"
let checksum = "cca3d5f380c3c216c22ac892cb04a792f3982730e570df71d824462f14c1350e"
let tag = "v0.3.0"
let checksum = "07c8741768956bf1a51d1c25f751b5e29d1ae9ee2fd786c4282031c9a8a92f0c"
let url = "https://github.com/lightningdevkit/ldk-node/releases/download/\(tag)/LDKNodeFFI.xcframework.zip"

let package = Package(
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A ready-to-go Lightning node library built using [LDK][ldk] and [BDK][bdk].
LDK Node is a self-custodial Lightning node in library form. Its central goal is to provide a small, simple, and straightforward interface that enables users to easily set up and run a Lightning node with an integrated on-chain wallet. While minimalism is at its core, LDK Node aims to be sufficiently modular and configurable to be useful for a variety of use cases.

## Getting Started
The primary abstraction of the library is the [`Node`][api_docs_node], which can be retrieved by setting up and configuring a [`Builder`][api_docs_builder] to your liking and calling one of the `build` methods. `Node` can then be controlled via commands such as `start`, `stop`, `connect_open_channel`, `send_payment`, etc.
The primary abstraction of the library is the [`Node`][api_docs_node], which can be retrieved by setting up and configuring a [`Builder`][api_docs_builder] to your liking and calling one of the `build` methods. `Node` can then be controlled via commands such as `start`, `stop`, `connect_open_channel`, `send`, etc.

```rust
use ldk_node::Builder;
Expand All @@ -31,7 +31,7 @@ fn main() {

node.start().unwrap();

let funding_address = node.new_onchain_address();
let funding_address = node.onchain_payment().new_address();

// .. fund address ..

Expand All @@ -44,7 +44,7 @@ fn main() {
node.event_handled();

let invoice = Bolt11Invoice::from_str("INVOICE_STR").unwrap();
node.send_payment(&invoice).unwrap();
node.bolt11_payment().send(&invoice).unwrap();

node.stop().unwrap();
}
Expand Down
2 changes: 1 addition & 1 deletion bindings/kotlin/ldk-node-android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ org.gradle.jvmargs=-Xmx1536m
android.useAndroidX=true
android.enableJetifier=true
kotlin.code.style=official
libraryVersion=0.2.1
libraryVersion=0.3.0
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ class AndroidLibTest {
val nodeId2 = node2.nodeId()
println("Node Id 2: $nodeId2")

val address1 = node1.newOnchainAddress()
val address1 = node1.onchain_payment().newOnchainAddress()
println("Funding address 1: $address1")

val address2 = node2.newOnchainAddress()
val address2 = node2.onchain_payment().newOnchainAddress()
println("Funding address 2: $address2")

node1.stop()
Expand Down
2 changes: 1 addition & 1 deletion bindings/kotlin/ldk-node-jvm/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
org.gradle.jvmargs=-Xmx1536m
kotlin.code.style=official
libraryVersion=0.2.1
libraryVersion=0.3.0
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ class LibraryTest {
val nodeId2 = node2.nodeId()
println("Node Id 2: $nodeId2")

val address1 = node1.newOnchainAddress()
val address1 = node1.onchainPayment().newAddress()
println("Funding address 1: $address1")

val address2 = node2.newOnchainAddress()
val address2 = node2.onchainPayment().newAddress()
println("Funding address 2: $address2")

val txid1 = sendToAddress(address1, 100000u)
Expand Down Expand Up @@ -203,9 +203,9 @@ class LibraryTest {
val spendableBalance2AfterOpen = node2.listBalances().spendableOnchainBalanceSats
println("Spendable balance 1 after open: $spendableBalance1AfterOpen")
println("Spendable balance 2 after open: $spendableBalance2AfterOpen")
assert(spendableBalance1AfterOpen > 49000u)
assert(spendableBalance1AfterOpen < 50000u)
assertEquals(100000uL, spendableBalance2AfterOpen)
assert(spendableBalance1AfterOpen > 24000u)
assert(spendableBalance1AfterOpen < 25000u)
assertEquals(75000uL, spendableBalance2AfterOpen)

val channelReadyEvent1 = node1.waitNextEvent()
println("Got event: $channelReadyEvent1")
Expand All @@ -222,9 +222,9 @@ class LibraryTest {
else -> return
}

val invoice = node2.receivePayment(2500000u, "asdf", 9217u)
val invoice = node2.bolt11Payment().receive(2500000u, "asdf", 9217u)

node1.sendPayment(invoice)
node1.bolt11Payment().send(invoice)

val paymentSuccessfulEvent = node1.waitNextEvent()
println("Got event: $paymentSuccessfulEvent")
Expand Down
Loading
Loading