multi: endpoints for onion messages
This commit creates the necessary endpoints for onion messages. Specifically, it adds the following: - `SendOnionMessage` endpoint to send onion messages. - `SubscribeOnionMessages` endpoint to subscribe to incoming onion messages. It uses the `msgmux` package to handle the onion messages.
This commit is contained in:
1 parent
2ee0702942
commit
07dc74e198
9 files changed
+398
No files matched your search
@@ -726,6 +726,8 @@ func (h *HarnessRPC) SubscribeChannelEvents() ChannelEventsClient {
|
||||
|
||||
type CustomMessageClient lnrpc.Lightning_SubscribeCustomMessagesClient
|
||||
|
||||
type OnionMessageClient lnrpc.Lightning_SubscribeOnionMessagesClient
|
||||
|
||||
// SubscribeCustomMessages creates a subscription client for custom messages.
|
||||
func (h *HarnessRPC) SubscribeCustomMessages() (CustomMessageClient,
|
||||
context.CancelFunc) {
|
||||
@@ -758,6 +760,38 @@ func (h *HarnessRPC) SendCustomMessage(
|
||||
return resp
|
||||
}
|
||||
|
||||
// SendOnionMessage makes a RPC call to the node's SendOnionMessage and
|
||||
// returns the response.
|
||||
func (h *HarnessRPC) SendOnionMessage(
|
||||
req *lnrpc.SendOnionMessageRequest) *lnrpc.SendOnionMessageResponse {
|
||||
|
||||
ctxt, cancel := context.WithTimeout(h.runCtx, DefaultTimeout)
|
||||
defer cancel()
|
||||
|
||||
resp, err := h.LN.SendOnionMessage(ctxt, req)
|
||||
h.NoError(err, "SendOnionMessage")
|
||||
|
||||
return resp
|
||||
}
|
||||
|
||||
// SubscribeOnionMessages creates a subscription client for onion messages.
|
||||
func (h *HarnessRPC) SubscribeOnionMessages() (OnionMessageClient,
|
||||
context.CancelFunc) {
|
||||
|
||||
ctxt, cancel := context.WithCancel(h.runCtx)
|
||||
|
||||
req := &lnrpc.SubscribeOnionMessagesRequest{}
|
||||
|
||||
// SubscribeCustomMessages needs to have the context alive for the
|
||||
// entire test case as the returned client will be used for send and
|
||||
// receive events stream. Thus we use runCtx here instead of a timeout
|
||||
// context.
|
||||
stream, err := h.LN.SubscribeOnionMessages(ctxt, req)
|
||||
h.NoError(err, "SubscribeOnionMessages")
|
||||
|
||||
return stream, cancel
|
||||
}
|
||||
|
||||
// GetChanInfo makes a RPC call to the node's GetChanInfo and returns the
|
||||
// response.
|
||||
func (h *HarnessRPC) GetChanInfo(
|
||||
|
||||
Reference in new issue
Block a user