Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 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
8 changes: 7 additions & 1 deletion bindings/ldk_node.udl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ interface LDKNode {
[Throws=NodeError]
PaymentHash send_payment_using_amount([ByRef]Bolt11Invoice invoice, u64 amount_msat);
[Throws=NodeError]
PaymentHash send_spontaneous_payment(u64 amount_msat, PublicKey node_id);
PaymentHash send_spontaneous_payment(u64 amount_msat, PublicKey node_id, sequence<TlvEntry> custom_tlvs);
[Throws=NodeError]
void send_payment_probes([ByRef]Bolt11Invoice invoice);
[Throws=NodeError]
Expand Down Expand Up @@ -131,6 +131,7 @@ enum NodeError {
"InvalidInvoice",
"InvalidChannelId",
"InvalidNetwork",
"InvalidCustomTlv",
"DuplicatePayment",
"InsufficientFunds",
"LiquiditySourceUnavailable",
Expand Down Expand Up @@ -312,6 +313,11 @@ enum LogLevel {
"Error",
};

dictionary TlvEntry {
u64 type;
sequence<u8> value;
};

[Custom]
typedef string Txid;

Expand Down
3 changes: 3 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ pub enum Error {
InvalidChannelId,
/// The given network is invalid.
InvalidNetwork,
/// The custom TLVs are invalid.
InvalidCustomTlv,
/// A payment with the given hash has already been initiated.
DuplicatePayment,
/// The available funds are insufficient to complete the given operation.
Expand Down Expand Up @@ -107,6 +109,7 @@ impl fmt::Display for Error {
Self::InvalidInvoice => write!(f, "The given invoice is invalid."),
Self::InvalidChannelId => write!(f, "The given channel ID is invalid."),
Self::InvalidNetwork => write!(f, "The given network is invalid."),
Self::InvalidCustomTlv => write!(f, "The given custom TLVs are invalid."),
Self::DuplicatePayment => {
write!(f, "A payment with the given hash has already been initiated.")
},
Expand Down
11 changes: 8 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ use types::{
Broadcaster, ChainMonitor, ChannelManager, FeeEstimator, KeysManager, NetworkGraph,
PeerManager, Router, Scorer, Sweeper, Wallet,
};
pub use types::{ChannelDetails, PeerDetails, UserChannelId};
pub use types::{ChannelDetails, PeerDetails, TlvEntry, UserChannelId};

use logger::{log_error, log_info, log_trace, FilesystemLogger, Logger};

Expand Down Expand Up @@ -1222,7 +1222,7 @@ impl<K: KVStore + Sync + Send + 'static> Node<K> {

/// Send a spontaneous, aka. "keysend", payment
pub fn send_spontaneous_payment(
&self, amount_msat: u64, node_id: PublicKey,
&self, amount_msat: u64, node_id: PublicKey, custom_tlvs: Vec<TlvEntry>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are the custom_tlvs required in order to send a spontaneous payment?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really required but may be useful. But I see the point, we'll probably take tnull's suggestion to base this change off PR 270; probably once it's merged

) -> Result<PaymentHash, Error> {
let rt_lock = self.runtime.read().unwrap();
if rt_lock.is_none() {
Expand All @@ -1245,7 +1245,12 @@ impl<K: KVStore + Sync + Send + 'static> Node<K> {
PaymentParameters::from_node_id(node_id, self.config.default_cltv_expiry_delta),
amount_msat,
);
let recipient_fields = RecipientOnionFields::spontaneous_empty();
let recipient_fields = RecipientOnionFields::spontaneous_empty()
.with_custom_tlvs(custom_tlvs.into_iter().map(|tlv| (tlv.r#type, tlv.value)).collect())
.map_err(|_| {
log_error!(self.logger, "Payment error: invalid custom TLVs.");
Error::InvalidCustomTlv
})?;

match self.channel_manager.send_spontaneous_payment_with_retry(
Some(payment_preimage),
Expand Down
9 changes: 9 additions & 0 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,3 +456,12 @@ impl Default for ChannelConfig {
LdkChannelConfig::default().into()
}
}

/// Custom TLV entry.
pub struct TlvEntry {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the protocol the TLV entry is defined with a length
https://github.com/lightning/bolts/blob/master/01-messaging.md#type-length-value-format

Whats the reason of not including it here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that LDK is expecting type and value to set the tlv. I guess then the length is set by ldk when sending the message.
Maybe add a bit more info on the type and value describing the restrictions or characterizes of the props:
for example, for type:
type identifiers below 2^16 are reserved for use in this specification. type identifiers greater than or equal to 2^16 are available for custom records. (from the blip)

Copy link
Author

@rdmitr rdmitr Mar 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the protocol the TLV entry is defined with a length https://github.com/lightning/bolts/blob/master/01-messaging.md#type-length-value-format

Whats the reason of not including it here?

The length of the data buffer is used for that. I shall see if we can improve the representation, though

/// Type number.
pub r#type: u64,

/// Serialized value.
pub value: Vec<u8>,
}
9 changes: 6 additions & 3 deletions tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use ldk_node::io::sqlite_store::SqliteStore;
use ldk_node::{
Builder, Config, Event, LogLevel, Node, NodeError, PaymentDirection, PaymentStatus,
Builder, Config, Event, LogLevel, Node, NodeError, PaymentDirection, PaymentStatus, TlvEntry,
};

use lightning::ln::msgs::SocketAddress;
Expand Down Expand Up @@ -490,8 +490,11 @@ pub(crate) fn do_channel_full_cycle<K: KVStore + Sync + Send, E: ElectrumApi>(
// Test spontaneous/keysend payments
println!("\nA send_spontaneous_payment");
let keysend_amount_msat = 2500_000;
let keysend_payment_hash =
node_a.send_spontaneous_payment(keysend_amount_msat, node_b.node_id()).unwrap();
let tlv1 = TlvEntry { r#type: 131073, value: vec![0x00, 0x11, 0x22, 0x33] };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this test validate that the counter-party node received the message?

let tlv2 = TlvEntry { r#type: 131075, value: vec![0xaa, 0xbb] };
let keysend_payment_hash = node_a
.send_spontaneous_payment(keysend_amount_msat, node_b.node_id(), vec![tlv1, tlv2])
.unwrap();
expect_event!(node_a, PaymentSuccessful);
let received_keysend_amount = match node_b.wait_next_event() {
ref e @ Event::PaymentReceived { amount_msat, .. } => {
Expand Down