Skip to content

Commit 647a1a9

Browse files
committed
Expose on-chain transaction classification (TransactionType) over gRPC
1 parent 6d6d810 commit 647a1a9

3 files changed

Lines changed: 405 additions & 5 deletions

File tree

ldk-server-grpc/src/proto/types.proto

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,90 @@ message Onchain {
4646

4747
// The confirmation status of this payment.
4848
ConfirmationStatus status = 2;
49+
50+
// The classification of this transaction, as reported by LDK when it was broadcast.
51+
//
52+
// Unset for plain on-chain sends, and for payments recorded before this classification was
53+
// tracked.
54+
optional TransactionType tx_type = 3;
55+
}
56+
57+
// A channel referenced by a TransactionType variant.
58+
message TransactionChannel {
59+
// The `node_id` of the channel counterparty.
60+
string counterparty_node_id = 1;
61+
62+
// The ID of the channel.
63+
string channel_id = 2;
64+
}
65+
66+
// The classification of an on-chain transaction, mirroring LDK Node's
67+
// `ldk_node::payment::TransactionType`.
68+
message TransactionType {
69+
oneof kind {
70+
Funding funding = 1;
71+
CooperativeClose cooperative_close = 2;
72+
UnilateralClose unilateral_close = 3;
73+
AnchorBump anchor_bump = 4;
74+
Claim claim = 5;
75+
Sweep sweep = 6;
76+
InteractiveFunding interactive_funding = 7;
77+
}
78+
}
79+
80+
// A funding transaction establishing one or more new channels.
81+
message Funding {
82+
// The channels being funded.
83+
repeated TransactionChannel channels = 1;
84+
}
85+
86+
// A transaction cooperatively closing a channel.
87+
message CooperativeClose {
88+
// The `node_id` of the channel counterparty.
89+
string counterparty_node_id = 1;
90+
91+
// The ID of the channel being closed.
92+
string channel_id = 2;
93+
}
94+
95+
// A transaction force-closing a channel.
96+
message UnilateralClose {
97+
// The `node_id` of the channel counterparty.
98+
string counterparty_node_id = 1;
99+
100+
// The ID of the channel being force-closed.
101+
string channel_id = 2;
102+
}
103+
104+
// An anchor transaction CPFP fee-bumping a closing transaction.
105+
message AnchorBump {
106+
// The `node_id` of the channel counterparty.
107+
string counterparty_node_id = 1;
108+
109+
// The ID of the channel whose closing transaction is being fee-bumped.
110+
string channel_id = 2;
111+
}
112+
113+
// A transaction resolving an output spendable by both us and our counterparty.
114+
message Claim {
115+
// The `node_id` of the channel counterparty.
116+
string counterparty_node_id = 1;
117+
118+
// The ID of the channel from which outputs are being claimed.
119+
string channel_id = 2;
120+
}
121+
122+
// A transaction sweeping spendable outputs to the on-chain wallet.
123+
message Sweep {
124+
// The channels from which outputs are being swept, if known.
125+
repeated TransactionChannel channels = 1;
126+
}
127+
128+
// An interactively-negotiated funding transaction: a splice, or (once supported) a V2
129+
// dual-funded channel open.
130+
message InteractiveFunding {
131+
// The channels participating in the negotiation.
132+
repeated TransactionChannel channels = 1;
49133
}
50134

51135
message ConfirmationStatus {

ldk-server-grpc/src/types.rs

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,150 @@ pub struct Onchain {
8989
/// The confirmation status of this payment.
9090
#[prost(message, optional, tag = "2")]
9191
pub status: ::core::option::Option<ConfirmationStatus>,
92+
/// The classification of this transaction, as reported by LDK when it was broadcast.
93+
///
94+
/// Unset for plain on-chain sends, and for payments recorded before this classification was
95+
/// tracked.
96+
#[prost(message, optional, tag = "3")]
97+
pub tx_type: ::core::option::Option<TransactionType>,
98+
}
99+
/// A channel referenced by a TransactionType variant.
100+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
101+
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
102+
#[cfg_attr(feature = "serde", serde(default))]
103+
#[allow(clippy::derive_partial_eq_without_eq)]
104+
#[derive(Clone, PartialEq, ::prost::Message)]
105+
pub struct TransactionChannel {
106+
/// The `node_id` of the channel counterparty.
107+
#[prost(string, tag = "1")]
108+
pub counterparty_node_id: ::prost::alloc::string::String,
109+
/// The ID of the channel.
110+
#[prost(string, tag = "2")]
111+
pub channel_id: ::prost::alloc::string::String,
112+
}
113+
/// The classification of an on-chain transaction, mirroring LDK Node's
114+
/// `ldk_node::payment::TransactionType`.
115+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
116+
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
117+
#[cfg_attr(feature = "serde", serde(default))]
118+
#[allow(clippy::derive_partial_eq_without_eq)]
119+
#[derive(Clone, PartialEq, ::prost::Message)]
120+
pub struct TransactionType {
121+
#[prost(oneof = "transaction_type::Kind", tags = "1, 2, 3, 4, 5, 6, 7")]
122+
pub kind: ::core::option::Option<transaction_type::Kind>,
123+
}
124+
/// Nested message and enum types in `TransactionType`.
125+
pub mod transaction_type {
126+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
127+
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
128+
#[allow(clippy::derive_partial_eq_without_eq)]
129+
#[derive(Clone, PartialEq, ::prost::Oneof)]
130+
pub enum Kind {
131+
#[prost(message, tag = "1")]
132+
Funding(super::Funding),
133+
#[prost(message, tag = "2")]
134+
CooperativeClose(super::CooperativeClose),
135+
#[prost(message, tag = "3")]
136+
UnilateralClose(super::UnilateralClose),
137+
#[prost(message, tag = "4")]
138+
AnchorBump(super::AnchorBump),
139+
#[prost(message, tag = "5")]
140+
Claim(super::Claim),
141+
#[prost(message, tag = "6")]
142+
Sweep(super::Sweep),
143+
#[prost(message, tag = "7")]
144+
InteractiveFunding(super::InteractiveFunding),
145+
}
146+
}
147+
/// A funding transaction establishing one or more new channels.
148+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
149+
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
150+
#[cfg_attr(feature = "serde", serde(default))]
151+
#[allow(clippy::derive_partial_eq_without_eq)]
152+
#[derive(Clone, PartialEq, ::prost::Message)]
153+
pub struct Funding {
154+
/// The channels being funded.
155+
#[prost(message, repeated, tag = "1")]
156+
pub channels: ::prost::alloc::vec::Vec<TransactionChannel>,
157+
}
158+
/// A transaction cooperatively closing a channel.
159+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
160+
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
161+
#[cfg_attr(feature = "serde", serde(default))]
162+
#[allow(clippy::derive_partial_eq_without_eq)]
163+
#[derive(Clone, PartialEq, ::prost::Message)]
164+
pub struct CooperativeClose {
165+
/// The `node_id` of the channel counterparty.
166+
#[prost(string, tag = "1")]
167+
pub counterparty_node_id: ::prost::alloc::string::String,
168+
/// The ID of the channel being closed.
169+
#[prost(string, tag = "2")]
170+
pub channel_id: ::prost::alloc::string::String,
171+
}
172+
/// A transaction force-closing a channel.
173+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
174+
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
175+
#[cfg_attr(feature = "serde", serde(default))]
176+
#[allow(clippy::derive_partial_eq_without_eq)]
177+
#[derive(Clone, PartialEq, ::prost::Message)]
178+
pub struct UnilateralClose {
179+
/// The `node_id` of the channel counterparty.
180+
#[prost(string, tag = "1")]
181+
pub counterparty_node_id: ::prost::alloc::string::String,
182+
/// The ID of the channel being force-closed.
183+
#[prost(string, tag = "2")]
184+
pub channel_id: ::prost::alloc::string::String,
185+
}
186+
/// An anchor transaction CPFP fee-bumping a closing transaction.
187+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
188+
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
189+
#[cfg_attr(feature = "serde", serde(default))]
190+
#[allow(clippy::derive_partial_eq_without_eq)]
191+
#[derive(Clone, PartialEq, ::prost::Message)]
192+
pub struct AnchorBump {
193+
/// The `node_id` of the channel counterparty.
194+
#[prost(string, tag = "1")]
195+
pub counterparty_node_id: ::prost::alloc::string::String,
196+
/// The ID of the channel whose closing transaction is being fee-bumped.
197+
#[prost(string, tag = "2")]
198+
pub channel_id: ::prost::alloc::string::String,
199+
}
200+
/// A transaction resolving an output spendable by both us and our counterparty.
201+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
202+
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
203+
#[cfg_attr(feature = "serde", serde(default))]
204+
#[allow(clippy::derive_partial_eq_without_eq)]
205+
#[derive(Clone, PartialEq, ::prost::Message)]
206+
pub struct Claim {
207+
/// The `node_id` of the channel counterparty.
208+
#[prost(string, tag = "1")]
209+
pub counterparty_node_id: ::prost::alloc::string::String,
210+
/// The ID of the channel from which outputs are being claimed.
211+
#[prost(string, tag = "2")]
212+
pub channel_id: ::prost::alloc::string::String,
213+
}
214+
/// A transaction sweeping spendable outputs to the on-chain wallet.
215+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
216+
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
217+
#[cfg_attr(feature = "serde", serde(default))]
218+
#[allow(clippy::derive_partial_eq_without_eq)]
219+
#[derive(Clone, PartialEq, ::prost::Message)]
220+
pub struct Sweep {
221+
/// The channels from which outputs are being swept, if known.
222+
#[prost(message, repeated, tag = "1")]
223+
pub channels: ::prost::alloc::vec::Vec<TransactionChannel>,
224+
}
225+
/// An interactively-negotiated funding transaction: a splice, or (once supported) a V2
226+
/// dual-funded channel open.
227+
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
228+
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
229+
#[cfg_attr(feature = "serde", serde(default))]
230+
#[allow(clippy::derive_partial_eq_without_eq)]
231+
#[derive(Clone, PartialEq, ::prost::Message)]
232+
pub struct InteractiveFunding {
233+
/// The channels participating in the negotiation.
234+
#[prost(message, repeated, tag = "1")]
235+
pub channels: ::prost::alloc::vec::Vec<TransactionChannel>,
92236
}
93237
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
94238
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]

0 commit comments

Comments
 (0)