Commit eda6fcb
feat(gl-sdk): NodeState snapshot, hex identifiers, list_payments fixes
NodeState
- Unified node_state() snapshot aggregating get_info,
list_peer_channels, and list_funds into a single record with
balances, capacity, utxos, and connected-channel-peer set.
- Reserved UTXOs (in-flight PSBTs) excluded from on-chain balance.
FundOutput now carries `reserved` from listfunds.outputs[].reserved.
- Closing-channel double-count fixed. Onchain-state channels only
contribute to pending_onchain_balance_msat when we initiated the
close and our payout is still timelocked (DELAYED_OUTPUT_TO_US);
otherwise the payout is already a wallet UTXO and would be counted
twice. PeerChannel exposes `closer` (ChannelSide) and `status` to
support this gate.
- ChannelState::from_i32 unknown fallback now maps to a new
ChannelState::Unknown variant rather than Onchain (which silently
counted unmapped states as closing). Unknown is treated as neither
open nor closing by balance math. gl-sdk-cli output formatter
handles the new variant too.
- Immature outputs (confirmed but timelocked, e.g. coinbase
maturation) surface as immature_onchain_balance_msat instead of
being silently dropped. OutputStatus match is exhaustive.
- The three underlying RPCs run concurrently via tokio::join!.
NodeState aggregate fields:
- total_onchain_msat (confirmed + unconfirmed + immature)
- total_balance_msat (everything the user owns)
- spendable_balance_msat (send-screen gate)
- max_chan_reserve_msat (protocol reserve locked across channels)
- utxos: Vec<FundOutput> for coin-control UIs
Other NodeState changes:
- channels_balance_msat / max_payable_msat docstrings explicitly
name their roles: home-screen display vs send-button gate.
- num_active/pending/inactive_channels docstrings clarify which
balance fields each count contributes to.
- connected_peers renamed to connected_channel_peers (only lists
peers we have a channel with); dedup via HashSet.
- fees_collected_msat removed from NodeState (still on
GetInfoResponse); it's a routing-node concern.
Hex identifier surface
- Every identifier (pubkey, payment hash, txid, preimage, funding
txid, channel id) on public structs is now a lowercase hex String
instead of Vec<u8>. Affected: NodeState, PeerChannel, FundOutput,
FundChannel, GetInfoResponse, Peer, Invoice, Pay, Payment,
SendResponse, OnchainSendResponse (txid only; raw tx stays bytes),
InvoicePaidEvent, ParsedInvoice.
- Kept as Vec<u8>: Credentials::load/save bytes, raw on-chain tx
bytes, Peer.features bitfield, DeveloperCert/Signer constructor
arguments.
list_payments fixes
- Unpaid (open) and expired invoices are dropped from list_payments.
Only Paid invoices appear as Payment rows on the received side;
list_invoices() still surfaces the full invoice list for callers
that want to inspect open invoices directly.
- Payment.destination is documented as always-None for
PaymentType::Received: Lightning's privacy model does not reveal
the sender's pubkey to the recipient, and the only pubkey
derivable from a paid invoice is the payee (our own node), which
is uninteresting per-row. PaymentStatus::Pending stays on the
public type — it remains valid for in-flight sent payments.
NAPI mirrors synced (Buffer→String everywhere the underlying field
became hex), gl-sdk-cli output formatters simplified, NodeExtensions
defaults adjusted, and Python + Kotlin tests updated to match.1 parent f45a39a commit eda6fcb
10 files changed
Lines changed: 1428 additions & 267 deletions
File tree
- libs
- gl-sdk-android/lib/src
- androidInstrumentedTest/kotlin/com/blockstream/glsdk
- commonMain/kotlin/com/blockstream/glsdk
- gl-sdk-cli/src
- gl-sdk-napi
- src
- gl-sdk
- glsdk
- src
- tests
Lines changed: 20 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| |||
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
44 | 64 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| 133 | + | |
133 | 134 | | |
134 | 135 | | |
135 | 136 | | |
136 | 137 | | |
137 | 138 | | |
138 | 139 | | |
139 | | - | |
| 140 | + | |
140 | 141 | | |
141 | 142 | | |
142 | 143 | | |
143 | | - | |
144 | | - | |
| 144 | + | |
| 145 | + | |
145 | 146 | | |
146 | 147 | | |
147 | 148 | | |
| |||
205 | 206 | | |
206 | 207 | | |
207 | 208 | | |
208 | | - | |
| 209 | + | |
209 | 210 | | |
210 | 211 | | |
211 | 212 | | |
| |||
218 | 219 | | |
219 | 220 | | |
220 | 221 | | |
221 | | - | |
| 222 | + | |
222 | 223 | | |
223 | 224 | | |
224 | | - | |
| 225 | + | |
225 | 226 | | |
226 | 227 | | |
227 | 228 | | |
228 | 229 | | |
229 | | - | |
| 230 | + | |
230 | 231 | | |
231 | 232 | | |
232 | 233 | | |
| |||
267 | 268 | | |
268 | 269 | | |
269 | 270 | | |
270 | | - | |
| 271 | + | |
271 | 272 | | |
272 | 273 | | |
273 | 274 | | |
| |||
301 | 302 | | |
302 | 303 | | |
303 | 304 | | |
304 | | - | |
| 305 | + | |
305 | 306 | | |
306 | 307 | | |
307 | 308 | | |
| |||
330 | 331 | | |
331 | 332 | | |
332 | 333 | | |
333 | | - | |
| 334 | + | |
334 | 335 | | |
335 | | - | |
| 336 | + | |
336 | 337 | | |
337 | 338 | | |
338 | 339 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments