lightninglabs / lightninglabs/pool

API: Make it easier to determine a batch and an on-chain txid given an order

Open
#333 0 comments 1 reaction 0 assignees View on GitHub
API enhancement feature request rpc
Dominant language
Go
Stars
259
Forks
51
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem? Please describe.**
I would like to easily correlate a given order, to a given batch and txid of that batch. Currently I need to iterate over a lot of data in order to finally obtain all of this information.

**Describe the solution you'd like**

Ideally: when calling `list_sidecars` or `list_orders` if the order/sidecar has been matched, it should show the txid and batch id in this API

**Describe alternatives you've considered**
Currently I am achieving this like so:
```
# First start with a sidecar id. I got this one by listing the sidecars and finding one that was in the completed state
sidecar_id = b"\3405\254(B\300\225\231"
sidecar_nonce = pool.list_sidecars(sidecar_id).tickets[0].order_bid_nonce

# Obtain the order, associated with the sidecar
# it would be understandable if I could stop here, and get the information I want from the order object
# but I must continue...
for i in pool.list_orders(active_only=False).bids:
if i.details.order_nonce == sidecar_nonce:
order = i

# get the lease txid by matching nonces
target_lease = None
for i in pool.leases(batch_ids=[],accounts=[]).leases:
if i.order_nonce == sidecar_nonce:
target_lease = i
break
lease_txid = target_lease.channel_point.txid[::-1].hex()

# finally get the batch_id by matching batch_txid with the above txid
bs = pool.batch_snapshots(b"", 50)

lease_batch = None
for b in bs.batches:
if b.batch_tx_id == lease_txid:
lease_batch = b.batch_id
break

```

This is kind of tedious, and also if the database of leases/orders/sidecars is really large, could be very inefficient.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading the API implementations for list_sidecars and list_orders, then trace the existing leases and batch_snapshots data used in the example. Define how matched orders or sidecars expose the batch ID and transaction ID, and verify that callers can obtain both without iterating across the other collections.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.