-
Notifications
You must be signed in to change notification settings - Fork 116
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
[custom channels]: add new RPC methods for asset channel specific calls #1048
Conversation
3b044ca
to
62ded9c
Compare
62ded9c
to
6acd611
Compare
Ready for review. Will do manual and integration test validation in lightninglabs/lightning-terminal#807 (since these new RPCs can't really be tested well in |
Looking at the failure in the |
4000798
to
664a6a1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good!
have some Qs
switch { | ||
// If there are multiple asset channels for the same asset, we need to | ||
// ask the user to specify the peer public key. Otherwise, we don't know | ||
// who to ask for a quote. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we could convert this into a feature in next versions, the user may not want to pick a single peer here so instead we could ask for a quote from all peers and choose the "best" one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. But that would be a larger overhaul of the whole RFQ system, so I'd rather do that in a follow-up PR.
// channels, it means we have multiple channels with the same asset and | ||
// the same peer. So we just return the first channel. | ||
case len(assetBalances) >= 1: | ||
return &assetBalances[0], nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: the first channel may be depleted, need to think of rotation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this level the actual channel balance doesn't matter. We only need the channel
object to get the peer public key. We don't want to do balance checks at this level really, as that should be handled by the sending logic.
// (invoice amount plus fee limit) in milli-satoshi, not the | ||
// asset amount. Need to change the whole RFQ API to do that | ||
// though. | ||
maxAssetAmount := assetChan.assetInfo.LocalBalance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get the TODO
Isn't this the asset local balance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is currently, but will the threshold will be lowered to match the payment rather than just the entire channel outgoing balance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We set it to the asset balance because the unit is wrong (right now it's the maximum amount in assets, but the user doesn't know how many assets they need to send, that's the question the RFQ call should answer in the first place). We'll do some refactor and eventually this should be the maximum amount the user is willing to pay in satoshis (invoice amount plus the user-defined maximum routing fee they're willing to pay).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be valuable to add itests which exercise the new endpoints in this PR? Just checking for example that the outgoing HTLC contains the correct fields.
rpcserver.go
Outdated
// The last step is to create a hop hint that includes the fake SCID of | ||
// the quote, alongside the channel's routing policy. | ||
channelID := assetChan.channelInfo.ChannelID | ||
ourPolicy, err := r.getOurPolicy(ctx, channelID, peerPubKey.String()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps instead of ourPolicy
in both variable name and method name, just channelPolicy
? Because "their" policy isn't something we deal with. I have the same sort of thoughts around the getOurPolicy
method name and doc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every channel has two routing policies: those set by us (valid for the outbound direction) and those set by our peer (valid for the inbound direction). So the our/their kind of made sense IMO.
But while thinking about the name and how to make it more easy to understand, I actually noticed that we need to use the inbound policies (those set by the peer), since this is for a payment coming in.
While doing that, I renamed the function to getInboundPolicy
.
@guggero, remember to re-request review from reviewers when ready |
This commit allows us to use the gRPC import statement to re-use lnd protobuf definitions. We'll use that to be able to embed lnd RPC messages in some of the new tapchannelrpc calls.
With this commit we make sure that the taproot asset channel functionality RPCs are correctly configured and return the expected error when being called. We can't actually test any of their intended functionality because that would require us to run within a litd context. But the integration tests in the litd repo make sure these RPCs work as expected.
664a6a1
to
23c09ff
Compare
As mentioned in the PR body, the full functionality test is done in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🌛
Adds standalone RPC calls to the
tapchannelrpc
package to simplify usage for RPC users.These RPCs mirror the functionality that is currently only available in the command line in
litd
:litcli ln addinvoice
->tapchannelrpc.AddInvoice
litcli ln payinvoice
->tapchannelrpc.SendPayment
litcli ln sendpayment
->tapchannelrpc.SendPayment