From f19bed8068e3538eedaccafc850c8f3fe03fd078 Mon Sep 17 00:00:00 2001 From: ffranr Date: Fri, 15 Mar 2024 15:40:47 +0000 Subject: [PATCH 1/8] rfq+rfqmsg: generalise reject message construction We need to generalise our reject message constructor so that we can generate reject messages for the new sell request message type in addition to the existing buy request message type. --- rfq/negotiator.go | 5 +++-- rfqmsg/reject.go | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/rfq/negotiator.go b/rfq/negotiator.go index e7e5dda64..befb8684f 100644 --- a/rfq/negotiator.go +++ b/rfq/negotiator.go @@ -227,7 +227,7 @@ func (n *Negotiator) HandleIncomingBuyRequest( // If we do not have a suitable sell offer, then we will reject // the quote request with an error. reject := rfqmsg.NewReject( - request, rfqmsg.ErrNoSuitableSellOffer, + request.Peer, request.ID, rfqmsg.ErrNoSuitableSellOffer, ) var msg rfqmsg.OutgoingMsg = reject @@ -271,7 +271,8 @@ func (n *Negotiator) HandleIncomingBuyRequest( if err != nil { // Send a reject message to the peer. msg := rfqmsg.NewReject( - request, rfqmsg.ErrUnknownReject, + request.Peer, request.ID, + rfqmsg.ErrUnknownReject, ) sendOutgoingMsg(msg) diff --git a/rfqmsg/reject.go b/rfqmsg/reject.go index 41c767820..6dc5d6588 100644 --- a/rfqmsg/reject.go +++ b/rfqmsg/reject.go @@ -168,11 +168,13 @@ type Reject struct { } // NewReject creates a new instance of a quote reject message. -func NewReject(request BuyRequest, rejectErr RejectErr) *Reject { +func NewReject(peer route.Vertex, requestId ID, + rejectErr RejectErr) *Reject { + return &Reject{ - Peer: request.Peer, + Peer: peer, rejectMsgData: rejectMsgData{ - ID: request.ID, + ID: requestId, Err: rejectErr, }, } From 209e0af892e54fbca25ca878226413b827bf6fa1 Mon Sep 17 00:00:00 2001 From: ffranr Date: Mon, 18 Mar 2024 10:55:47 +0000 Subject: [PATCH 2/8] rfq+rpc: rename IncomingAcceptQuoteEvent such that it is buy specific This commit renames the RFQ event type `IncomingAcceptQuoteEvent` to `PeerAcceptedBuyQuoteEvent` such that it is "buy" specific. We will add a new "sell" specific event type in a future commit. --- rfq/manager.go | 31 ++++++++++++++++--------------- rpcserver.go | 4 ++-- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/rfq/manager.go b/rfq/manager.go index 126c42180..0989c58de 100644 --- a/rfq/manager.go +++ b/rfq/manager.go @@ -275,8 +275,9 @@ func (m *Manager) handleIncomingMessage(incomingMsg rfqmsg.IncomingMsg) error { scid := SerialisedScid(msg.ShortChannelId()) m.peerAcceptedQuotes.Store(scid, *msg) - // Notify subscribers of the incoming quote accept. - event := NewIncomingAcceptQuoteEvent(msg) + // Notify subscribers of the incoming peer accepted asset buy + // quote. + event := NewPeerAcceptedBuyQuoteEvent(msg) m.publishSubscriberEvent(event) case *rfqmsg.Reject: @@ -487,34 +488,34 @@ func (m *Manager) publishSubscriberEvent(event fn.Event) { ) } -// IncomingAcceptQuoteEvent is an event that is broadcast when the RFQ manager -// receives an accept quote message from a peer. -type IncomingAcceptQuoteEvent struct { +// PeerAcceptedBuyQuoteEvent is an event that is broadcast when the RFQ manager +// receives an accept quote message from a peer. This is a quote which was +// requested by our node and has been accepted by a peer. +type PeerAcceptedBuyQuoteEvent struct { // timestamp is the event creation UTC timestamp. timestamp time.Time - // BuyAccept is the accepted quote. + // BuyAccept is the accepted asset buy quote. rfqmsg.BuyAccept } -// NewIncomingAcceptQuoteEvent creates a new IncomingAcceptQuoteEvent. -func NewIncomingAcceptQuoteEvent( - accept *rfqmsg.BuyAccept) *IncomingAcceptQuoteEvent { +// NewPeerAcceptedBuyQuoteEvent creates a new PeerAcceptedBuyQuoteEvent. +func NewPeerAcceptedBuyQuoteEvent( + buyAccept *rfqmsg.BuyAccept) *PeerAcceptedBuyQuoteEvent { - return &IncomingAcceptQuoteEvent{ + return &PeerAcceptedBuyQuoteEvent{ timestamp: time.Now().UTC(), - BuyAccept: *accept, + BuyAccept: *buyAccept, } } // Timestamp returns the event creation UTC timestamp. -func (q *IncomingAcceptQuoteEvent) Timestamp() time.Time { +func (q *PeerAcceptedBuyQuoteEvent) Timestamp() time.Time { return q.timestamp.UTC() } -// Ensure that the IncomingAcceptQuoteEvent struct implements the Event -// interface. -var _ fn.Event = (*IncomingAcceptQuoteEvent)(nil) +// Ensure that the PeerAcceptedBuyQuoteEvent struct implements the Event interface. +var _ fn.Event = (*PeerAcceptedBuyQuoteEvent)(nil) // IncomingRejectQuoteEvent is an event that is broadcast when the RFQ manager // receives a reject quote message from a peer. diff --git a/rpcserver.go b/rpcserver.go index a8a98075e..71e22496c 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -5595,8 +5595,8 @@ func marshallRfqEvent(eventInterface fn.Event) (*rfqrpc.RfqEvent, error) { timestamp := eventInterface.Timestamp().UTC().Unix() switch event := eventInterface.(type) { - case *rfq.IncomingAcceptQuoteEvent: - acceptedQuote := &rfqrpc.AcceptedQuote{ + case *rfq.PeerAcceptedBuyQuoteEvent: + acceptedQuote := &rfqrpc.PeerAcceptedBuyQuote{ Peer: event.Peer.String(), Id: event.ID[:], Scid: uint64(event.ShortChannelId()), From d82306594f7daf9c2dbb1bff2b25415ce7f980fa Mon Sep 17 00:00:00 2001 From: ffranr Date: Mon, 18 Mar 2024 11:26:12 +0000 Subject: [PATCH 3/8] rfq: rename field peerAcceptedQuotes such that it is buy specific --- rfq/manager.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/rfq/manager.go b/rfq/manager.go index 0989c58de..19b9b6b13 100644 --- a/rfq/manager.go +++ b/rfq/manager.go @@ -78,10 +78,11 @@ type Manager struct { // events. acceptHtlcEvents chan *AcceptHtlcEvent - // peerAcceptedQuotes is a map of serialised short channel IDs (SCIDs) - // to associated accepted quotes. These quotes have been accepted by - // peer nodes and are therefore available for use in buying assets. - peerAcceptedQuotes lnutils.SyncMap[SerialisedScid, rfqmsg.BuyAccept] + // peerAcceptedBuyQuotes holds buy quotes for assets that our node has + // requested and that have been accepted by peer nodes. These quotes are + // exclusively used by our node for the acquisition of assets, as they + // represent agreed-upon terms for purchase transactions with our peers. + peerAcceptedBuyQuotes lnutils.SyncMap[SerialisedScid, rfqmsg.BuyAccept] // subscribers is a map of components that want to be notified on new // events, keyed by their subscription ID. @@ -104,7 +105,7 @@ func NewManager(cfg ManagerCfg) (*Manager, error) { outgoingMessages: make(chan rfqmsg.OutgoingMsg), acceptHtlcEvents: make(chan *AcceptHtlcEvent), - peerAcceptedQuotes: lnutils.SyncMap[ + peerAcceptedBuyQuotes: lnutils.SyncMap[ SerialisedScid, rfqmsg.BuyAccept]{}, subscribers: lnutils.SyncMap[ @@ -273,7 +274,7 @@ func (m *Manager) handleIncomingMessage(incomingMsg rfqmsg.IncomingMsg) error { // so that it can be used to send a payment by our lightning // node. scid := SerialisedScid(msg.ShortChannelId()) - m.peerAcceptedQuotes.Store(scid, *msg) + m.peerAcceptedBuyQuotes.Store(scid, *msg) // Notify subscribers of the incoming peer accepted asset buy // quote. @@ -433,10 +434,10 @@ func (m *Manager) QueryAcceptedQuotes() map[SerialisedScid]rfqmsg.BuyAccept { // create a copy. quotesCopy := make(map[SerialisedScid]rfqmsg.BuyAccept) - m.peerAcceptedQuotes.ForEach( + m.peerAcceptedBuyQuotes.ForEach( func(scid SerialisedScid, accept rfqmsg.BuyAccept) error { if time.Now().Unix() > int64(accept.Expiry) { - m.peerAcceptedQuotes.Delete(scid) + m.peerAcceptedBuyQuotes.Delete(scid) return nil } From 53639732d9a29358653bf7bca652a15d4ce62d23 Mon Sep 17 00:00:00 2001 From: ffranr Date: Mon, 18 Mar 2024 11:47:56 +0000 Subject: [PATCH 4/8] rfq+rpc: rename to clarify that subject quotes were accepted by peers In this commit, we rename methods, RPC endpoints, and variables to clarify that the subject quotes are those that were requested by our node and were accepted by our peers. They are not quotes that our node has accepted. Quotes that our node has accepted are stored as sale/purchase policies in the RFQ order handler. --- itest/rfq_test.go | 10 +- perms/perms.go | 2 +- rfq/manager.go | 7 +- rpcserver.go | 44 ++--- taprpc/rfqrpc/rfq.pb.go | 299 +++++++++++++++++---------------- taprpc/rfqrpc/rfq.pb.gw.go | 32 ++-- taprpc/rfqrpc/rfq.pb.json.go | 6 +- taprpc/rfqrpc/rfq.proto | 32 ++-- taprpc/rfqrpc/rfq.swagger.json | 91 +++++----- taprpc/rfqrpc/rfq.yaml | 4 +- taprpc/rfqrpc/rfq_grpc.pb.go | 40 ++--- 11 files changed, 291 insertions(+), 276 deletions(-) diff --git a/itest/rfq_test.go b/itest/rfq_test.go index 8e834af80..5dc3767ce 100644 --- a/itest/rfq_test.go +++ b/itest/rfq_test.go @@ -98,7 +98,7 @@ func testRfqHtlcIntercept(t *harnessTest) { event, err := carolEventNtfns.Recv() require.NoError(t.t, err) - _, ok := event.Event.(*rfqrpc.RfqEvent_IncomingAcceptQuote) + _, ok := event.Event.(*rfqrpc.RfqEvent_PeerAcceptedBuyQuote) require.True(t.t, ok, "unexpected event: %v", event) return nil @@ -107,11 +107,11 @@ func testRfqHtlcIntercept(t *harnessTest) { // Carol should have received an accepted quote from Bob. This accepted // quote can be used by Carol to make a payment to Bob. - acceptedQuotes, err := ts.CarolTapd.QueryRfqAcceptedQuotes( - ctxt, &rfqrpc.QueryRfqAcceptedQuotesRequest{}, + acceptedQuotes, err := ts.CarolTapd.QueryPeerAcceptedQuotes( + ctxt, &rfqrpc.QueryPeerAcceptedQuotesRequest{}, ) require.NoError(t.t, err, "unable to query accepted quotes") - require.Len(t.t, acceptedQuotes.AcceptedQuotes, 1) + require.Len(t.t, acceptedQuotes.BuyQuotes, 1) // Carol will now use the accepted quote (received from Bob) to create // a lightning invoice which will be given to and settled by Alice. @@ -126,7 +126,7 @@ func testRfqHtlcIntercept(t *harnessTest) { // pays the invoice, the payment will arrive to Bob's node with the // expected scid. Bob will then use the scid to identify the HTLC as // relating to the accepted quote. - acceptedQuote := acceptedQuotes.AcceptedQuotes[0] + acceptedQuote := acceptedQuotes.BuyQuotes[0] t.Logf("Accepted quote scid: %d", acceptedQuote.Scid) scid := lnwire.NewShortChanIDFromInt(acceptedQuote.Scid) diff --git a/perms/perms.go b/perms/perms.go index 8ed4fcb98..c008c281a 100644 --- a/perms/perms.go +++ b/perms/perms.go @@ -228,7 +228,7 @@ var ( Entity: "rfq", Action: "write", }}, - "/rfqrpc.Rfq/QueryRfqAcceptedQuotes": {{ + "/rfqrpc.Rfq/QueryPeerAcceptedQuotes": {{ Entity: "rfq", Action: "read", }}, diff --git a/rfq/manager.go b/rfq/manager.go index 19b9b6b13..f3deea225 100644 --- a/rfq/manager.go +++ b/rfq/manager.go @@ -427,9 +427,10 @@ func (m *Manager) UpsertAssetBuyOrder(order BuyOrder) error { return nil } -// QueryAcceptedQuotes returns a map of accepted quotes that have been -// registered with the RFQ manager. -func (m *Manager) QueryAcceptedQuotes() map[SerialisedScid]rfqmsg.BuyAccept { +// QueryPeerAcceptedQuotes returns quotes that were requested by our node and +// have been accepted by our peers. These quotes are exclusively available to +// our node for the acquisition/sale of assets. +func (m *Manager) QueryPeerAcceptedQuotes() map[SerialisedScid]rfqmsg.BuyAccept { // Returning the map directly is not thread safe. We will therefore // create a copy. quotesCopy := make(map[SerialisedScid]rfqmsg.BuyAccept) diff --git a/rpcserver.go b/rpcserver.go index 71e22496c..2928c5a1f 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -5554,14 +5554,18 @@ func (r *rpcServer) AddAssetSellOffer(_ context.Context, return &rfqrpc.AddAssetSellOfferResponse{}, nil } -// marshalAcceptedQuotes marshals a map of accepted quotes into the RPC form. -func marshalAcceptedQuotes( - acceptedQuotes map[rfq.SerialisedScid]rfqmsg.BuyAccept) []*rfqrpc.AcceptedQuote { +// marshalPeerAcceptedQuotes marshals a map of peer accepted quotes into the RPC +// form. These are quotes that were requested by our node and have been accepted +// by our peers. +func marshalPeerAcceptedQuotes( + peerAcceptedQuotes map[rfq.SerialisedScid]rfqmsg.BuyAccept) []*rfqrpc.PeerAcceptedBuyQuote { // Marshal the accepted quotes into the RPC form. - rpcQuotes := make([]*rfqrpc.AcceptedQuote, 0, len(acceptedQuotes)) - for scid, quote := range acceptedQuotes { - rpcQuote := &rfqrpc.AcceptedQuote{ + rpcQuotes := make( + []*rfqrpc.PeerAcceptedBuyQuote, 0, len(peerAcceptedQuotes), + ) + for scid, quote := range peerAcceptedQuotes { + rpcQuote := &rfqrpc.PeerAcceptedBuyQuote{ Peer: quote.Peer.String(), Id: quote.ID[:], Scid: uint64(scid), @@ -5575,18 +5579,20 @@ func marshalAcceptedQuotes( return rpcQuotes } -// QueryRfqAcceptedQuotes queries for accepted quotes from the RFQ system. -func (r *rpcServer) QueryRfqAcceptedQuotes(_ context.Context, - _ *rfqrpc.QueryRfqAcceptedQuotesRequest) ( - *rfqrpc.QueryRfqAcceptedQuotesResponse, error) { +// QueryPeerAcceptedQuotes is used to query for quotes that were requested by +// our node and have been accepted our peers. +func (r *rpcServer) QueryPeerAcceptedQuotes(_ context.Context, + _ *rfqrpc.QueryPeerAcceptedQuotesRequest) ( + *rfqrpc.QueryPeerAcceptedQuotesResponse, error) { - // Query the RFQ manager for accepted quotes. - acceptedQuotes := r.cfg.RfqManager.QueryAcceptedQuotes() + // Query the RFQ manager for quotes that were requested by our node and + // have been accepted by our peers. + peerAcceptedQuotes := r.cfg.RfqManager.QueryPeerAcceptedQuotes() - rpcQuotes := marshalAcceptedQuotes(acceptedQuotes) + rpcQuotes := marshalPeerAcceptedQuotes(peerAcceptedQuotes) - return &rfqrpc.QueryRfqAcceptedQuotesResponse{ - AcceptedQuotes: rpcQuotes, + return &rfqrpc.QueryPeerAcceptedQuotesResponse{ + BuyQuotes: rpcQuotes, }, nil } @@ -5605,10 +5611,10 @@ func marshallRfqEvent(eventInterface fn.Event) (*rfqrpc.RfqEvent, error) { Expiry: event.Expiry, } - eventRpc := &rfqrpc.RfqEvent_IncomingAcceptQuote{ - IncomingAcceptQuote: &rfqrpc.IncomingAcceptQuoteEvent{ - Timestamp: uint64(timestamp), - AcceptedQuote: acceptedQuote, + eventRpc := &rfqrpc.RfqEvent_PeerAcceptedBuyQuote{ + PeerAcceptedBuyQuote: &rfqrpc.PeerAcceptedBuyQuoteEvent{ + Timestamp: uint64(timestamp), + PeerAcceptedBuyQuote: acceptedQuote, }, } return &rfqrpc.RfqEvent{ diff --git a/taprpc/rfqrpc/rfq.pb.go b/taprpc/rfqrpc/rfq.pb.go index 9113be8b4..49cef41f9 100644 --- a/taprpc/rfqrpc/rfq.pb.go +++ b/taprpc/rfqrpc/rfq.pb.go @@ -352,14 +352,14 @@ func (*AddAssetSellOfferResponse) Descriptor() ([]byte, []int) { return file_rfqrpc_rfq_proto_rawDescGZIP(), []int{4} } -type QueryRfqAcceptedQuotesRequest struct { +type QueryPeerAcceptedQuotesRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields } -func (x *QueryRfqAcceptedQuotesRequest) Reset() { - *x = QueryRfqAcceptedQuotesRequest{} +func (x *QueryPeerAcceptedQuotesRequest) Reset() { + *x = QueryPeerAcceptedQuotesRequest{} if protoimpl.UnsafeEnabled { mi := &file_rfqrpc_rfq_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -367,13 +367,13 @@ func (x *QueryRfqAcceptedQuotesRequest) Reset() { } } -func (x *QueryRfqAcceptedQuotesRequest) String() string { +func (x *QueryPeerAcceptedQuotesRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*QueryRfqAcceptedQuotesRequest) ProtoMessage() {} +func (*QueryPeerAcceptedQuotesRequest) ProtoMessage() {} -func (x *QueryRfqAcceptedQuotesRequest) ProtoReflect() protoreflect.Message { +func (x *QueryPeerAcceptedQuotesRequest) ProtoReflect() protoreflect.Message { mi := &file_rfqrpc_rfq_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -385,12 +385,12 @@ func (x *QueryRfqAcceptedQuotesRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use QueryRfqAcceptedQuotesRequest.ProtoReflect.Descriptor instead. -func (*QueryRfqAcceptedQuotesRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use QueryPeerAcceptedQuotesRequest.ProtoReflect.Descriptor instead. +func (*QueryPeerAcceptedQuotesRequest) Descriptor() ([]byte, []int) { return file_rfqrpc_rfq_proto_rawDescGZIP(), []int{5} } -type AcceptedQuote struct { +type PeerAcceptedBuyQuote struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -410,8 +410,8 @@ type AcceptedQuote struct { Expiry uint64 `protobuf:"varint,6,opt,name=expiry,proto3" json:"expiry,omitempty"` } -func (x *AcceptedQuote) Reset() { - *x = AcceptedQuote{} +func (x *PeerAcceptedBuyQuote) Reset() { + *x = PeerAcceptedBuyQuote{} if protoimpl.UnsafeEnabled { mi := &file_rfqrpc_rfq_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -419,13 +419,13 @@ func (x *AcceptedQuote) Reset() { } } -func (x *AcceptedQuote) String() string { +func (x *PeerAcceptedBuyQuote) String() string { return protoimpl.X.MessageStringOf(x) } -func (*AcceptedQuote) ProtoMessage() {} +func (*PeerAcceptedBuyQuote) ProtoMessage() {} -func (x *AcceptedQuote) ProtoReflect() protoreflect.Message { +func (x *PeerAcceptedBuyQuote) ProtoReflect() protoreflect.Message { mi := &file_rfqrpc_rfq_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -437,63 +437,65 @@ func (x *AcceptedQuote) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use AcceptedQuote.ProtoReflect.Descriptor instead. -func (*AcceptedQuote) Descriptor() ([]byte, []int) { +// Deprecated: Use PeerAcceptedBuyQuote.ProtoReflect.Descriptor instead. +func (*PeerAcceptedBuyQuote) Descriptor() ([]byte, []int) { return file_rfqrpc_rfq_proto_rawDescGZIP(), []int{6} } -func (x *AcceptedQuote) GetPeer() string { +func (x *PeerAcceptedBuyQuote) GetPeer() string { if x != nil { return x.Peer } return "" } -func (x *AcceptedQuote) GetId() []byte { +func (x *PeerAcceptedBuyQuote) GetId() []byte { if x != nil { return x.Id } return nil } -func (x *AcceptedQuote) GetScid() uint64 { +func (x *PeerAcceptedBuyQuote) GetScid() uint64 { if x != nil { return x.Scid } return 0 } -func (x *AcceptedQuote) GetAssetAmount() uint64 { +func (x *PeerAcceptedBuyQuote) GetAssetAmount() uint64 { if x != nil { return x.AssetAmount } return 0 } -func (x *AcceptedQuote) GetAskPrice() uint64 { +func (x *PeerAcceptedBuyQuote) GetAskPrice() uint64 { if x != nil { return x.AskPrice } return 0 } -func (x *AcceptedQuote) GetExpiry() uint64 { +func (x *PeerAcceptedBuyQuote) GetExpiry() uint64 { if x != nil { return x.Expiry } return 0 } -type QueryRfqAcceptedQuotesResponse struct { +type QueryPeerAcceptedQuotesResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - AcceptedQuotes []*AcceptedQuote `protobuf:"bytes,1,rep,name=accepted_quotes,json=acceptedQuotes,proto3" json:"accepted_quotes,omitempty"` + // buy_quotes is a list of asset buy quotes which were requested by our + // node and have been accepted by our peers. + BuyQuotes []*PeerAcceptedBuyQuote `protobuf:"bytes,1,rep,name=buy_quotes,json=buyQuotes,proto3" json:"buy_quotes,omitempty"` } -func (x *QueryRfqAcceptedQuotesResponse) Reset() { - *x = QueryRfqAcceptedQuotesResponse{} +func (x *QueryPeerAcceptedQuotesResponse) Reset() { + *x = QueryPeerAcceptedQuotesResponse{} if protoimpl.UnsafeEnabled { mi := &file_rfqrpc_rfq_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -501,13 +503,13 @@ func (x *QueryRfqAcceptedQuotesResponse) Reset() { } } -func (x *QueryRfqAcceptedQuotesResponse) String() string { +func (x *QueryPeerAcceptedQuotesResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*QueryRfqAcceptedQuotesResponse) ProtoMessage() {} +func (*QueryPeerAcceptedQuotesResponse) ProtoMessage() {} -func (x *QueryRfqAcceptedQuotesResponse) ProtoReflect() protoreflect.Message { +func (x *QueryPeerAcceptedQuotesResponse) ProtoReflect() protoreflect.Message { mi := &file_rfqrpc_rfq_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -519,14 +521,14 @@ func (x *QueryRfqAcceptedQuotesResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use QueryRfqAcceptedQuotesResponse.ProtoReflect.Descriptor instead. -func (*QueryRfqAcceptedQuotesResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use QueryPeerAcceptedQuotesResponse.ProtoReflect.Descriptor instead. +func (*QueryPeerAcceptedQuotesResponse) Descriptor() ([]byte, []int) { return file_rfqrpc_rfq_proto_rawDescGZIP(), []int{7} } -func (x *QueryRfqAcceptedQuotesResponse) GetAcceptedQuotes() []*AcceptedQuote { +func (x *QueryPeerAcceptedQuotesResponse) GetBuyQuotes() []*PeerAcceptedBuyQuote { if x != nil { - return x.AcceptedQuotes + return x.BuyQuotes } return nil } @@ -569,19 +571,19 @@ func (*SubscribeRfqEventNtfnsRequest) Descriptor() ([]byte, []int) { return file_rfqrpc_rfq_proto_rawDescGZIP(), []int{8} } -type IncomingAcceptQuoteEvent struct { +type PeerAcceptedBuyQuoteEvent struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields // Unix timestamp. Timestamp uint64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - // The accepted quote. - AcceptedQuote *AcceptedQuote `protobuf:"bytes,2,opt,name=accepted_quote,json=acceptedQuote,proto3" json:"accepted_quote,omitempty"` + // The asset buy quote that was accepted by out peer. + PeerAcceptedBuyQuote *PeerAcceptedBuyQuote `protobuf:"bytes,2,opt,name=peer_accepted_buy_quote,json=peerAcceptedBuyQuote,proto3" json:"peer_accepted_buy_quote,omitempty"` } -func (x *IncomingAcceptQuoteEvent) Reset() { - *x = IncomingAcceptQuoteEvent{} +func (x *PeerAcceptedBuyQuoteEvent) Reset() { + *x = PeerAcceptedBuyQuoteEvent{} if protoimpl.UnsafeEnabled { mi := &file_rfqrpc_rfq_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -589,13 +591,13 @@ func (x *IncomingAcceptQuoteEvent) Reset() { } } -func (x *IncomingAcceptQuoteEvent) String() string { +func (x *PeerAcceptedBuyQuoteEvent) String() string { return protoimpl.X.MessageStringOf(x) } -func (*IncomingAcceptQuoteEvent) ProtoMessage() {} +func (*PeerAcceptedBuyQuoteEvent) ProtoMessage() {} -func (x *IncomingAcceptQuoteEvent) ProtoReflect() protoreflect.Message { +func (x *PeerAcceptedBuyQuoteEvent) ProtoReflect() protoreflect.Message { mi := &file_rfqrpc_rfq_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -607,21 +609,21 @@ func (x *IncomingAcceptQuoteEvent) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use IncomingAcceptQuoteEvent.ProtoReflect.Descriptor instead. -func (*IncomingAcceptQuoteEvent) Descriptor() ([]byte, []int) { +// Deprecated: Use PeerAcceptedBuyQuoteEvent.ProtoReflect.Descriptor instead. +func (*PeerAcceptedBuyQuoteEvent) Descriptor() ([]byte, []int) { return file_rfqrpc_rfq_proto_rawDescGZIP(), []int{9} } -func (x *IncomingAcceptQuoteEvent) GetTimestamp() uint64 { +func (x *PeerAcceptedBuyQuoteEvent) GetTimestamp() uint64 { if x != nil { return x.Timestamp } return 0 } -func (x *IncomingAcceptQuoteEvent) GetAcceptedQuote() *AcceptedQuote { +func (x *PeerAcceptedBuyQuoteEvent) GetPeerAcceptedBuyQuote() *PeerAcceptedBuyQuote { if x != nil { - return x.AcceptedQuote + return x.PeerAcceptedBuyQuote } return nil } @@ -691,7 +693,7 @@ type RfqEvent struct { // Types that are assignable to Event: // - // *RfqEvent_IncomingAcceptQuote + // *RfqEvent_PeerAcceptedBuyQuote // *RfqEvent_AcceptHtlc Event isRfqEvent_Event `protobuf_oneof:"event"` } @@ -735,9 +737,9 @@ func (m *RfqEvent) GetEvent() isRfqEvent_Event { return nil } -func (x *RfqEvent) GetIncomingAcceptQuote() *IncomingAcceptQuoteEvent { - if x, ok := x.GetEvent().(*RfqEvent_IncomingAcceptQuote); ok { - return x.IncomingAcceptQuote +func (x *RfqEvent) GetPeerAcceptedBuyQuote() *PeerAcceptedBuyQuoteEvent { + if x, ok := x.GetEvent().(*RfqEvent_PeerAcceptedBuyQuote); ok { + return x.PeerAcceptedBuyQuote } return nil } @@ -753,10 +755,10 @@ type isRfqEvent_Event interface { isRfqEvent_Event() } -type RfqEvent_IncomingAcceptQuote struct { - // incoming_accept_quote is an event that is sent when an incoming - // accept quote message is received. - IncomingAcceptQuote *IncomingAcceptQuoteEvent `protobuf:"bytes,1,opt,name=incoming_accept_quote,json=incomingAcceptQuote,proto3,oneof"` +type RfqEvent_PeerAcceptedBuyQuote struct { + // peer_accepted_buy_quote is an event that is emitted when a peer + // accepted (incoming) asset buy quote message is received. + PeerAcceptedBuyQuote *PeerAcceptedBuyQuoteEvent `protobuf:"bytes,1,opt,name=peer_accepted_buy_quote,json=peerAcceptedBuyQuote,proto3,oneof"` } type RfqEvent_AcceptHtlc struct { @@ -765,7 +767,7 @@ type RfqEvent_AcceptHtlc struct { AcceptHtlc *AcceptHtlcEvent `protobuf:"bytes,2,opt,name=accept_htlc,json=acceptHtlc,proto3,oneof"` } -func (*RfqEvent_IncomingAcceptQuote) isRfqEvent_Event() {} +func (*RfqEvent_PeerAcceptedBuyQuote) isRfqEvent_Event() {} func (*RfqEvent_AcceptHtlc) isRfqEvent_Event() {} @@ -808,77 +810,80 @@ var file_rfqrpc_rfq_proto_rawDesc = []byte{ 0x6d, 0x61, 0x78, 0x5f, 0x75, 0x6e, 0x69, 0x74, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x6d, 0x61, 0x78, 0x55, 0x6e, 0x69, 0x74, 0x73, 0x22, 0x1b, 0x0a, 0x19, 0x41, 0x64, 0x64, 0x41, 0x73, 0x73, 0x65, 0x74, 0x53, 0x65, 0x6c, 0x6c, 0x4f, 0x66, 0x66, 0x65, 0x72, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1f, 0x0a, 0x1d, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, - 0x66, 0x71, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x51, 0x75, 0x6f, 0x74, 0x65, 0x73, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x9f, 0x01, 0x0a, 0x0d, 0x41, 0x63, 0x63, 0x65, - 0x70, 0x74, 0x65, 0x64, 0x51, 0x75, 0x6f, 0x74, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x65, 0x65, - 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x65, 0x65, 0x72, 0x12, 0x0e, 0x0a, - 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, - 0x04, 0x73, 0x63, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x73, 0x63, 0x69, - 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x61, 0x73, 0x73, 0x65, 0x74, 0x5f, 0x61, 0x6d, 0x6f, 0x75, 0x6e, - 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x61, 0x73, 0x73, 0x65, 0x74, 0x41, 0x6d, - 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x61, 0x73, 0x6b, 0x5f, 0x70, 0x72, 0x69, 0x63, - 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x61, 0x73, 0x6b, 0x50, 0x72, 0x69, 0x63, - 0x65, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x78, 0x70, 0x69, 0x72, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, - 0x04, 0x52, 0x06, 0x65, 0x78, 0x70, 0x69, 0x72, 0x79, 0x22, 0x60, 0x0a, 0x1e, 0x51, 0x75, 0x65, - 0x72, 0x79, 0x52, 0x66, 0x71, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x51, 0x75, 0x6f, - 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3e, 0x0a, 0x0f, 0x61, - 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x5f, 0x71, 0x75, 0x6f, 0x74, 0x65, 0x73, 0x18, 0x01, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x72, 0x66, 0x71, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x63, - 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x51, 0x75, 0x6f, 0x74, 0x65, 0x52, 0x0e, 0x61, 0x63, 0x63, - 0x65, 0x70, 0x74, 0x65, 0x64, 0x51, 0x75, 0x6f, 0x74, 0x65, 0x73, 0x22, 0x1f, 0x0a, 0x1d, 0x53, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x20, 0x0a, 0x1e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, + 0x65, 0x65, 0x72, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x51, 0x75, 0x6f, 0x74, 0x65, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xa6, 0x01, 0x0a, 0x14, 0x50, 0x65, 0x65, + 0x72, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x42, 0x75, 0x79, 0x51, 0x75, 0x6f, 0x74, + 0x65, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x65, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x70, 0x65, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0c, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x63, 0x69, 0x64, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x04, 0x73, 0x63, 0x69, 0x64, 0x12, 0x21, 0x0a, 0x0c, 0x61, 0x73, 0x73, + 0x65, 0x74, 0x5f, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x0b, 0x61, 0x73, 0x73, 0x65, 0x74, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1b, 0x0a, 0x09, + 0x61, 0x73, 0x6b, 0x5f, 0x70, 0x72, 0x69, 0x63, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x08, 0x61, 0x73, 0x6b, 0x50, 0x72, 0x69, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x78, 0x70, + 0x69, 0x72, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x65, 0x78, 0x70, 0x69, 0x72, + 0x79, 0x22, 0x5e, 0x0a, 0x1f, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x65, 0x65, 0x72, 0x41, 0x63, + 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x51, 0x75, 0x6f, 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3b, 0x0a, 0x0a, 0x62, 0x75, 0x79, 0x5f, 0x71, 0x75, 0x6f, 0x74, + 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x72, 0x66, 0x71, 0x72, 0x70, + 0x63, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x42, 0x75, + 0x79, 0x51, 0x75, 0x6f, 0x74, 0x65, 0x52, 0x09, 0x62, 0x75, 0x79, 0x51, 0x75, 0x6f, 0x74, 0x65, + 0x73, 0x22, 0x1f, 0x0a, 0x1d, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x66, + 0x71, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x4e, 0x74, 0x66, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x22, 0x8e, 0x01, 0x0a, 0x19, 0x50, 0x65, 0x65, 0x72, 0x41, 0x63, 0x63, 0x65, 0x70, + 0x74, 0x65, 0x64, 0x42, 0x75, 0x79, 0x51, 0x75, 0x6f, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, + 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x53, + 0x0a, 0x17, 0x70, 0x65, 0x65, 0x72, 0x5f, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x5f, + 0x62, 0x75, 0x79, 0x5f, 0x71, 0x75, 0x6f, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1c, 0x2e, 0x72, 0x66, 0x71, 0x72, 0x70, 0x63, 0x2e, 0x50, 0x65, 0x65, 0x72, 0x41, 0x63, 0x63, + 0x65, 0x70, 0x74, 0x65, 0x64, 0x42, 0x75, 0x79, 0x51, 0x75, 0x6f, 0x74, 0x65, 0x52, 0x14, 0x70, + 0x65, 0x65, 0x72, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x42, 0x75, 0x79, 0x51, 0x75, + 0x6f, 0x74, 0x65, 0x22, 0x43, 0x0a, 0x0f, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x48, 0x74, 0x6c, + 0x63, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, + 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x63, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x04, 0x73, 0x63, 0x69, 0x64, 0x22, 0xab, 0x01, 0x0a, 0x08, 0x52, 0x66, 0x71, + 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x5a, 0x0a, 0x17, 0x70, 0x65, 0x65, 0x72, 0x5f, 0x61, 0x63, + 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x5f, 0x62, 0x75, 0x79, 0x5f, 0x71, 0x75, 0x6f, 0x74, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x72, 0x66, 0x71, 0x72, 0x70, 0x63, 0x2e, + 0x50, 0x65, 0x65, 0x72, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x42, 0x75, 0x79, 0x51, + 0x75, 0x6f, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x14, 0x70, 0x65, 0x65, + 0x72, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x42, 0x75, 0x79, 0x51, 0x75, 0x6f, 0x74, + 0x65, 0x12, 0x3a, 0x0a, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x5f, 0x68, 0x74, 0x6c, 0x63, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x72, 0x66, 0x71, 0x72, 0x70, 0x63, 0x2e, + 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x48, 0x74, 0x6c, 0x63, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, + 0x00, 0x52, 0x0a, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x48, 0x74, 0x6c, 0x63, 0x42, 0x07, 0x0a, + 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x32, 0xf7, 0x02, 0x0a, 0x03, 0x52, 0x66, 0x71, 0x12, 0x55, + 0x0a, 0x10, 0x41, 0x64, 0x64, 0x41, 0x73, 0x73, 0x65, 0x74, 0x42, 0x75, 0x79, 0x4f, 0x72, 0x64, + 0x65, 0x72, 0x12, 0x1f, 0x2e, 0x72, 0x66, 0x71, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x64, 0x64, 0x41, + 0x73, 0x73, 0x65, 0x74, 0x42, 0x75, 0x79, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x72, 0x66, 0x71, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x64, 0x64, + 0x41, 0x73, 0x73, 0x65, 0x74, 0x42, 0x75, 0x79, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x58, 0x0a, 0x11, 0x41, 0x64, 0x64, 0x41, 0x73, 0x73, 0x65, + 0x74, 0x53, 0x65, 0x6c, 0x6c, 0x4f, 0x66, 0x66, 0x65, 0x72, 0x12, 0x20, 0x2e, 0x72, 0x66, 0x71, + 0x72, 0x70, 0x63, 0x2e, 0x41, 0x64, 0x64, 0x41, 0x73, 0x73, 0x65, 0x74, 0x53, 0x65, 0x6c, 0x6c, + 0x4f, 0x66, 0x66, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x72, + 0x66, 0x71, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x64, 0x64, 0x41, 0x73, 0x73, 0x65, 0x74, 0x53, 0x65, + 0x6c, 0x6c, 0x4f, 0x66, 0x66, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x6a, 0x0a, 0x17, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x65, 0x65, 0x72, 0x41, 0x63, 0x63, 0x65, + 0x70, 0x74, 0x65, 0x64, 0x51, 0x75, 0x6f, 0x74, 0x65, 0x73, 0x12, 0x26, 0x2e, 0x72, 0x66, 0x71, + 0x72, 0x70, 0x63, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x65, 0x65, 0x72, 0x41, 0x63, 0x63, + 0x65, 0x70, 0x74, 0x65, 0x64, 0x51, 0x75, 0x6f, 0x74, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x72, 0x66, 0x71, 0x72, 0x70, 0x63, 0x2e, 0x51, 0x75, 0x65, 0x72, + 0x79, 0x50, 0x65, 0x65, 0x72, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x51, 0x75, 0x6f, + 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x53, 0x0a, 0x16, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x66, 0x71, 0x45, 0x76, 0x65, 0x6e, 0x74, - 0x4e, 0x74, 0x66, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x76, 0x0a, 0x18, - 0x49, 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x51, 0x75, - 0x6f, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, - 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x3c, 0x0a, 0x0e, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, - 0x65, 0x64, 0x5f, 0x71, 0x75, 0x6f, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, - 0x2e, 0x72, 0x66, 0x71, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, - 0x51, 0x75, 0x6f, 0x74, 0x65, 0x52, 0x0d, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x51, - 0x75, 0x6f, 0x74, 0x65, 0x22, 0x43, 0x0a, 0x0f, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x48, 0x74, - 0x6c, 0x63, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, - 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, - 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x63, 0x69, 0x64, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x04, 0x73, 0x63, 0x69, 0x64, 0x22, 0xa7, 0x01, 0x0a, 0x08, 0x52, 0x66, - 0x71, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x56, 0x0a, 0x15, 0x69, 0x6e, 0x63, 0x6f, 0x6d, 0x69, - 0x6e, 0x67, 0x5f, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x5f, 0x71, 0x75, 0x6f, 0x74, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x72, 0x66, 0x71, 0x72, 0x70, 0x63, 0x2e, 0x49, - 0x6e, 0x63, 0x6f, 0x6d, 0x69, 0x6e, 0x67, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x51, 0x75, 0x6f, - 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x13, 0x69, 0x6e, 0x63, 0x6f, 0x6d, - 0x69, 0x6e, 0x67, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x51, 0x75, 0x6f, 0x74, 0x65, 0x12, 0x3a, - 0x0a, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x5f, 0x68, 0x74, 0x6c, 0x63, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x72, 0x66, 0x71, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x63, 0x63, - 0x65, 0x70, 0x74, 0x48, 0x74, 0x6c, 0x63, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x48, 0x00, 0x52, 0x0a, - 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x48, 0x74, 0x6c, 0x63, 0x42, 0x07, 0x0a, 0x05, 0x65, 0x76, - 0x65, 0x6e, 0x74, 0x32, 0xf4, 0x02, 0x0a, 0x03, 0x52, 0x66, 0x71, 0x12, 0x55, 0x0a, 0x10, 0x41, - 0x64, 0x64, 0x41, 0x73, 0x73, 0x65, 0x74, 0x42, 0x75, 0x79, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, - 0x1f, 0x2e, 0x72, 0x66, 0x71, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x64, 0x64, 0x41, 0x73, 0x73, 0x65, - 0x74, 0x42, 0x75, 0x79, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x20, 0x2e, 0x72, 0x66, 0x71, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x64, 0x64, 0x41, 0x73, 0x73, - 0x65, 0x74, 0x42, 0x75, 0x79, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x58, 0x0a, 0x11, 0x41, 0x64, 0x64, 0x41, 0x73, 0x73, 0x65, 0x74, 0x53, 0x65, - 0x6c, 0x6c, 0x4f, 0x66, 0x66, 0x65, 0x72, 0x12, 0x20, 0x2e, 0x72, 0x66, 0x71, 0x72, 0x70, 0x63, - 0x2e, 0x41, 0x64, 0x64, 0x41, 0x73, 0x73, 0x65, 0x74, 0x53, 0x65, 0x6c, 0x6c, 0x4f, 0x66, 0x66, - 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x72, 0x66, 0x71, 0x72, - 0x70, 0x63, 0x2e, 0x41, 0x64, 0x64, 0x41, 0x73, 0x73, 0x65, 0x74, 0x53, 0x65, 0x6c, 0x6c, 0x4f, - 0x66, 0x66, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x67, 0x0a, 0x16, - 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x66, 0x71, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, - 0x51, 0x75, 0x6f, 0x74, 0x65, 0x73, 0x12, 0x25, 0x2e, 0x72, 0x66, 0x71, 0x72, 0x70, 0x63, 0x2e, - 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x66, 0x71, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, - 0x51, 0x75, 0x6f, 0x74, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, - 0x72, 0x66, 0x71, 0x72, 0x70, 0x63, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x66, 0x71, 0x41, - 0x63, 0x63, 0x65, 0x70, 0x74, 0x65, 0x64, 0x51, 0x75, 0x6f, 0x74, 0x65, 0x73, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x53, 0x0a, 0x16, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, - 0x62, 0x65, 0x52, 0x66, 0x71, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x4e, 0x74, 0x66, 0x6e, 0x73, 0x12, - 0x25, 0x2e, 0x72, 0x66, 0x71, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, - 0x62, 0x65, 0x52, 0x66, 0x71, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x4e, 0x74, 0x66, 0x6e, 0x73, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x72, 0x66, 0x71, 0x72, 0x70, 0x63, 0x2e, - 0x52, 0x66, 0x71, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x30, 0x01, 0x42, 0x37, 0x5a, 0x35, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x6e, 0x69, - 0x6e, 0x67, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x74, 0x61, 0x70, 0x72, 0x6f, 0x6f, 0x74, 0x2d, 0x61, - 0x73, 0x73, 0x65, 0x74, 0x73, 0x2f, 0x74, 0x61, 0x70, 0x72, 0x70, 0x63, 0x2f, 0x72, 0x66, 0x71, - 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x4e, 0x74, 0x66, 0x6e, 0x73, 0x12, 0x25, 0x2e, 0x72, 0x66, 0x71, 0x72, 0x70, 0x63, 0x2e, 0x53, + 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x66, 0x71, 0x45, 0x76, 0x65, 0x6e, 0x74, + 0x4e, 0x74, 0x66, 0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x72, + 0x66, 0x71, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x66, 0x71, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x30, 0x01, + 0x42, 0x37, 0x5a, 0x35, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, + 0x69, 0x67, 0x68, 0x74, 0x6e, 0x69, 0x6e, 0x67, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x74, 0x61, 0x70, + 0x72, 0x6f, 0x6f, 0x74, 0x2d, 0x61, 0x73, 0x73, 0x65, 0x74, 0x73, 0x2f, 0x74, 0x61, 0x70, 0x72, + 0x70, 0x63, 0x2f, 0x72, 0x66, 0x71, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( @@ -895,33 +900,33 @@ func file_rfqrpc_rfq_proto_rawDescGZIP() []byte { var file_rfqrpc_rfq_proto_msgTypes = make([]protoimpl.MessageInfo, 12) var file_rfqrpc_rfq_proto_goTypes = []interface{}{ - (*AssetSpecifier)(nil), // 0: rfqrpc.AssetSpecifier - (*AddAssetBuyOrderRequest)(nil), // 1: rfqrpc.AddAssetBuyOrderRequest - (*AddAssetBuyOrderResponse)(nil), // 2: rfqrpc.AddAssetBuyOrderResponse - (*AddAssetSellOfferRequest)(nil), // 3: rfqrpc.AddAssetSellOfferRequest - (*AddAssetSellOfferResponse)(nil), // 4: rfqrpc.AddAssetSellOfferResponse - (*QueryRfqAcceptedQuotesRequest)(nil), // 5: rfqrpc.QueryRfqAcceptedQuotesRequest - (*AcceptedQuote)(nil), // 6: rfqrpc.AcceptedQuote - (*QueryRfqAcceptedQuotesResponse)(nil), // 7: rfqrpc.QueryRfqAcceptedQuotesResponse - (*SubscribeRfqEventNtfnsRequest)(nil), // 8: rfqrpc.SubscribeRfqEventNtfnsRequest - (*IncomingAcceptQuoteEvent)(nil), // 9: rfqrpc.IncomingAcceptQuoteEvent - (*AcceptHtlcEvent)(nil), // 10: rfqrpc.AcceptHtlcEvent - (*RfqEvent)(nil), // 11: rfqrpc.RfqEvent + (*AssetSpecifier)(nil), // 0: rfqrpc.AssetSpecifier + (*AddAssetBuyOrderRequest)(nil), // 1: rfqrpc.AddAssetBuyOrderRequest + (*AddAssetBuyOrderResponse)(nil), // 2: rfqrpc.AddAssetBuyOrderResponse + (*AddAssetSellOfferRequest)(nil), // 3: rfqrpc.AddAssetSellOfferRequest + (*AddAssetSellOfferResponse)(nil), // 4: rfqrpc.AddAssetSellOfferResponse + (*QueryPeerAcceptedQuotesRequest)(nil), // 5: rfqrpc.QueryPeerAcceptedQuotesRequest + (*PeerAcceptedBuyQuote)(nil), // 6: rfqrpc.PeerAcceptedBuyQuote + (*QueryPeerAcceptedQuotesResponse)(nil), // 7: rfqrpc.QueryPeerAcceptedQuotesResponse + (*SubscribeRfqEventNtfnsRequest)(nil), // 8: rfqrpc.SubscribeRfqEventNtfnsRequest + (*PeerAcceptedBuyQuoteEvent)(nil), // 9: rfqrpc.PeerAcceptedBuyQuoteEvent + (*AcceptHtlcEvent)(nil), // 10: rfqrpc.AcceptHtlcEvent + (*RfqEvent)(nil), // 11: rfqrpc.RfqEvent } var file_rfqrpc_rfq_proto_depIdxs = []int32{ 0, // 0: rfqrpc.AddAssetBuyOrderRequest.asset_specifier:type_name -> rfqrpc.AssetSpecifier 0, // 1: rfqrpc.AddAssetSellOfferRequest.asset_specifier:type_name -> rfqrpc.AssetSpecifier - 6, // 2: rfqrpc.QueryRfqAcceptedQuotesResponse.accepted_quotes:type_name -> rfqrpc.AcceptedQuote - 6, // 3: rfqrpc.IncomingAcceptQuoteEvent.accepted_quote:type_name -> rfqrpc.AcceptedQuote - 9, // 4: rfqrpc.RfqEvent.incoming_accept_quote:type_name -> rfqrpc.IncomingAcceptQuoteEvent + 6, // 2: rfqrpc.QueryPeerAcceptedQuotesResponse.buy_quotes:type_name -> rfqrpc.PeerAcceptedBuyQuote + 6, // 3: rfqrpc.PeerAcceptedBuyQuoteEvent.peer_accepted_buy_quote:type_name -> rfqrpc.PeerAcceptedBuyQuote + 9, // 4: rfqrpc.RfqEvent.peer_accepted_buy_quote:type_name -> rfqrpc.PeerAcceptedBuyQuoteEvent 10, // 5: rfqrpc.RfqEvent.accept_htlc:type_name -> rfqrpc.AcceptHtlcEvent 1, // 6: rfqrpc.Rfq.AddAssetBuyOrder:input_type -> rfqrpc.AddAssetBuyOrderRequest 3, // 7: rfqrpc.Rfq.AddAssetSellOffer:input_type -> rfqrpc.AddAssetSellOfferRequest - 5, // 8: rfqrpc.Rfq.QueryRfqAcceptedQuotes:input_type -> rfqrpc.QueryRfqAcceptedQuotesRequest + 5, // 8: rfqrpc.Rfq.QueryPeerAcceptedQuotes:input_type -> rfqrpc.QueryPeerAcceptedQuotesRequest 8, // 9: rfqrpc.Rfq.SubscribeRfqEventNtfns:input_type -> rfqrpc.SubscribeRfqEventNtfnsRequest 2, // 10: rfqrpc.Rfq.AddAssetBuyOrder:output_type -> rfqrpc.AddAssetBuyOrderResponse 4, // 11: rfqrpc.Rfq.AddAssetSellOffer:output_type -> rfqrpc.AddAssetSellOfferResponse - 7, // 12: rfqrpc.Rfq.QueryRfqAcceptedQuotes:output_type -> rfqrpc.QueryRfqAcceptedQuotesResponse + 7, // 12: rfqrpc.Rfq.QueryPeerAcceptedQuotes:output_type -> rfqrpc.QueryPeerAcceptedQuotesResponse 11, // 13: rfqrpc.Rfq.SubscribeRfqEventNtfns:output_type -> rfqrpc.RfqEvent 10, // [10:14] is the sub-list for method output_type 6, // [6:10] is the sub-list for method input_type @@ -997,7 +1002,7 @@ func file_rfqrpc_rfq_proto_init() { } } file_rfqrpc_rfq_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*QueryRfqAcceptedQuotesRequest); i { + switch v := v.(*QueryPeerAcceptedQuotesRequest); i { case 0: return &v.state case 1: @@ -1009,7 +1014,7 @@ func file_rfqrpc_rfq_proto_init() { } } file_rfqrpc_rfq_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*AcceptedQuote); i { + switch v := v.(*PeerAcceptedBuyQuote); i { case 0: return &v.state case 1: @@ -1021,7 +1026,7 @@ func file_rfqrpc_rfq_proto_init() { } } file_rfqrpc_rfq_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*QueryRfqAcceptedQuotesResponse); i { + switch v := v.(*QueryPeerAcceptedQuotesResponse); i { case 0: return &v.state case 1: @@ -1045,7 +1050,7 @@ func file_rfqrpc_rfq_proto_init() { } } file_rfqrpc_rfq_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*IncomingAcceptQuoteEvent); i { + switch v := v.(*PeerAcceptedBuyQuoteEvent); i { case 0: return &v.state case 1: @@ -1088,7 +1093,7 @@ func file_rfqrpc_rfq_proto_init() { (*AssetSpecifier_GroupKeyStr)(nil), } file_rfqrpc_rfq_proto_msgTypes[11].OneofWrappers = []interface{}{ - (*RfqEvent_IncomingAcceptQuote)(nil), + (*RfqEvent_PeerAcceptedBuyQuote)(nil), (*RfqEvent_AcceptHtlc)(nil), } type x struct{} diff --git a/taprpc/rfqrpc/rfq.pb.gw.go b/taprpc/rfqrpc/rfq.pb.gw.go index cea2df7f0..ff00f4fbb 100644 --- a/taprpc/rfqrpc/rfq.pb.gw.go +++ b/taprpc/rfqrpc/rfq.pb.gw.go @@ -303,20 +303,20 @@ func local_request_Rfq_AddAssetSellOffer_1(ctx context.Context, marshaler runtim } -func request_Rfq_QueryRfqAcceptedQuotes_0(ctx context.Context, marshaler runtime.Marshaler, client RfqClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRfqAcceptedQuotesRequest +func request_Rfq_QueryPeerAcceptedQuotes_0(ctx context.Context, marshaler runtime.Marshaler, client RfqClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPeerAcceptedQuotesRequest var metadata runtime.ServerMetadata - msg, err := client.QueryRfqAcceptedQuotes(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.QueryPeerAcceptedQuotes(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Rfq_QueryRfqAcceptedQuotes_0(ctx context.Context, marshaler runtime.Marshaler, server RfqServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRfqAcceptedQuotesRequest +func local_request_Rfq_QueryPeerAcceptedQuotes_0(ctx context.Context, marshaler runtime.Marshaler, server RfqServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPeerAcceptedQuotesRequest var metadata runtime.ServerMetadata - msg, err := server.QueryRfqAcceptedQuotes(ctx, &protoReq) + msg, err := server.QueryPeerAcceptedQuotes(ctx, &protoReq) return msg, metadata, err } @@ -452,7 +452,7 @@ func RegisterRfqHandlerServer(ctx context.Context, mux *runtime.ServeMux, server }) - mux.Handle("GET", pattern_Rfq_QueryRfqAcceptedQuotes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Rfq_QueryPeerAcceptedQuotes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -460,12 +460,12 @@ func RegisterRfqHandlerServer(ctx context.Context, mux *runtime.ServeMux, server inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/rfqrpc.Rfq/QueryRfqAcceptedQuotes", runtime.WithHTTPPathPattern("/v1/taproot-assets/rfq/quotes/accepted")) + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/rfqrpc.Rfq/QueryPeerAcceptedQuotes", runtime.WithHTTPPathPattern("/v1/taproot-assets/rfq/quotes/peeraccepted")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Rfq_QueryRfqAcceptedQuotes_0(annotatedContext, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Rfq_QueryPeerAcceptedQuotes_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { @@ -473,7 +473,7 @@ func RegisterRfqHandlerServer(ctx context.Context, mux *runtime.ServeMux, server return } - forward_Rfq_QueryRfqAcceptedQuotes_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Rfq_QueryPeerAcceptedQuotes_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -613,25 +613,25 @@ func RegisterRfqHandlerClient(ctx context.Context, mux *runtime.ServeMux, client }) - mux.Handle("GET", pattern_Rfq_QueryRfqAcceptedQuotes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Rfq_QueryPeerAcceptedQuotes_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) var err error var annotatedContext context.Context - annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/rfqrpc.Rfq/QueryRfqAcceptedQuotes", runtime.WithHTTPPathPattern("/v1/taproot-assets/rfq/quotes/accepted")) + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/rfqrpc.Rfq/QueryPeerAcceptedQuotes", runtime.WithHTTPPathPattern("/v1/taproot-assets/rfq/quotes/peeraccepted")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Rfq_QueryRfqAcceptedQuotes_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Rfq_QueryPeerAcceptedQuotes_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_Rfq_QueryRfqAcceptedQuotes_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Rfq_QueryPeerAcceptedQuotes_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -669,7 +669,7 @@ var ( pattern_Rfq_AddAssetSellOffer_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"v1", "taproot-assets", "rfq", "selloffer", "group-key", "asset_specifier.group_key_str"}, "")) - pattern_Rfq_QueryRfqAcceptedQuotes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"v1", "taproot-assets", "rfq", "quotes", "accepted"}, "")) + pattern_Rfq_QueryPeerAcceptedQuotes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"v1", "taproot-assets", "rfq", "quotes", "peeraccepted"}, "")) pattern_Rfq_SubscribeRfqEventNtfns_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"v1", "taproot-assets", "rfq", "ntfs"}, "")) ) @@ -683,7 +683,7 @@ var ( forward_Rfq_AddAssetSellOffer_1 = runtime.ForwardResponseMessage - forward_Rfq_QueryRfqAcceptedQuotes_0 = runtime.ForwardResponseMessage + forward_Rfq_QueryPeerAcceptedQuotes_0 = runtime.ForwardResponseMessage forward_Rfq_SubscribeRfqEventNtfns_0 = runtime.ForwardResponseStream ) diff --git a/taprpc/rfqrpc/rfq.pb.json.go b/taprpc/rfqrpc/rfq.pb.json.go index 94a38f886..110719567 100644 --- a/taprpc/rfqrpc/rfq.pb.json.go +++ b/taprpc/rfqrpc/rfq.pb.json.go @@ -71,10 +71,10 @@ func RegisterRfqJSONCallbacks(registry map[string]func(ctx context.Context, callback(string(respBytes), nil) } - registry["rfqrpc.Rfq.QueryRfqAcceptedQuotes"] = func(ctx context.Context, + registry["rfqrpc.Rfq.QueryPeerAcceptedQuotes"] = func(ctx context.Context, conn *grpc.ClientConn, reqJSON string, callback func(string, error)) { - req := &QueryRfqAcceptedQuotesRequest{} + req := &QueryPeerAcceptedQuotesRequest{} err := marshaler.Unmarshal([]byte(reqJSON), req) if err != nil { callback("", err) @@ -82,7 +82,7 @@ func RegisterRfqJSONCallbacks(registry map[string]func(ctx context.Context, } client := NewRfqClient(conn) - resp, err := client.QueryRfqAcceptedQuotes(ctx, req) + resp, err := client.QueryPeerAcceptedQuotes(ctx, req) if err != nil { callback("", err) return diff --git a/taprpc/rfqrpc/rfq.proto b/taprpc/rfqrpc/rfq.proto index ac1956eba..74c6044d5 100644 --- a/taprpc/rfqrpc/rfq.proto +++ b/taprpc/rfqrpc/rfq.proto @@ -19,12 +19,12 @@ service Rfq { rpc AddAssetSellOffer (AddAssetSellOfferRequest) returns (AddAssetSellOfferResponse); - /* tapcli: `rfq acceptedquotes` - QueryRfqAcceptedQuotes is used to upsert a sell order for a specific - asset. + /* tapcli: `rfq peeracceptedquotes` + QueryPeerAcceptedQuotes is used to query for quotes that were requested by + our node and have been accepted our peers. */ - rpc QueryRfqAcceptedQuotes (QueryRfqAcceptedQuotesRequest) - returns (QueryRfqAcceptedQuotesResponse); + rpc QueryPeerAcceptedQuotes (QueryPeerAcceptedQuotesRequest) + returns (QueryPeerAcceptedQuotesResponse); /* SubscribeRfqEventNtfns is used to subscribe to RFQ events. @@ -82,10 +82,10 @@ message AddAssetSellOfferRequest { message AddAssetSellOfferResponse { } -message QueryRfqAcceptedQuotesRequest { +message QueryPeerAcceptedQuotesRequest { } -message AcceptedQuote { +message PeerAcceptedBuyQuote { // Quote counterparty peer. string peer = 1; @@ -106,19 +106,21 @@ message AcceptedQuote { uint64 expiry = 6; } -message QueryRfqAcceptedQuotesResponse { - repeated AcceptedQuote accepted_quotes = 1; +message QueryPeerAcceptedQuotesResponse { + // buy_quotes is a list of asset buy quotes which were requested by our + // node and have been accepted by our peers. + repeated PeerAcceptedBuyQuote buy_quotes = 1; } message SubscribeRfqEventNtfnsRequest { } -message IncomingAcceptQuoteEvent { +message PeerAcceptedBuyQuoteEvent { // Unix timestamp. uint64 timestamp = 1; - // The accepted quote. - AcceptedQuote accepted_quote = 2; + // The asset buy quote that was accepted by out peer. + PeerAcceptedBuyQuote peer_accepted_buy_quote = 2; } message AcceptHtlcEvent { @@ -132,9 +134,9 @@ message AcceptHtlcEvent { message RfqEvent { oneof event { - // incoming_accept_quote is an event that is sent when an incoming - // accept quote message is received. - IncomingAcceptQuoteEvent incoming_accept_quote = 1; + // peer_accepted_buy_quote is an event that is emitted when a peer + // accepted (incoming) asset buy quote message is received. + PeerAcceptedBuyQuoteEvent peer_accepted_buy_quote = 1; // accept_htlc is an event that is sent when a HTLC is accepted by the // RFQ service. diff --git a/taprpc/rfqrpc/rfq.swagger.json b/taprpc/rfqrpc/rfq.swagger.json index 9d6735a52..6fee961bd 100644 --- a/taprpc/rfqrpc/rfq.swagger.json +++ b/taprpc/rfqrpc/rfq.swagger.json @@ -224,15 +224,15 @@ ] } }, - "/v1/taproot-assets/rfq/quotes/accepted": { + "/v1/taproot-assets/rfq/quotes/peeraccepted": { "get": { - "summary": "tapcli: `rfq acceptedquotes`\nQueryRfqAcceptedQuotes is used to upsert a sell order for a specific\nasset.", - "operationId": "Rfq_QueryRfqAcceptedQuotes", + "summary": "tapcli: `rfq peeracceptedquotes`\nQueryPeerAcceptedQuotes is used to query for quotes that were requested by\nour node and have been accepted our peers.", + "operationId": "Rfq_QueryPeerAcceptedQuotes", "responses": { "200": { "description": "A successful response.", "schema": { - "$ref": "#/definitions/rfqrpcQueryRfqAcceptedQuotesResponse" + "$ref": "#/definitions/rfqrpcQueryPeerAcceptedQuotesResponse" } }, "default": { @@ -409,7 +409,36 @@ } } }, - "rfqrpcAcceptedQuote": { + "rfqrpcAddAssetBuyOrderResponse": { + "type": "object" + }, + "rfqrpcAddAssetSellOfferResponse": { + "type": "object" + }, + "rfqrpcAssetSpecifier": { + "type": "object", + "properties": { + "asset_id": { + "type": "string", + "format": "byte", + "description": "The 32-byte asset ID specified as raw bytes (gRPC only)." + }, + "asset_id_str": { + "type": "string", + "description": "The 32-byte asset ID encoded as a hex string (use this for REST)." + }, + "group_key": { + "type": "string", + "format": "byte", + "description": "The 32-byte asset group key specified as raw bytes (gRPC only)." + }, + "group_key_str": { + "type": "string", + "description": "The 32-byte asset group key encoded as hex string (use this for\nREST)." + } + } + }, + "rfqrpcPeerAcceptedBuyQuote": { "type": "object", "properties": { "peer": { @@ -443,36 +472,7 @@ } } }, - "rfqrpcAddAssetBuyOrderResponse": { - "type": "object" - }, - "rfqrpcAddAssetSellOfferResponse": { - "type": "object" - }, - "rfqrpcAssetSpecifier": { - "type": "object", - "properties": { - "asset_id": { - "type": "string", - "format": "byte", - "description": "The 32-byte asset ID specified as raw bytes (gRPC only)." - }, - "asset_id_str": { - "type": "string", - "description": "The 32-byte asset ID encoded as a hex string (use this for REST)." - }, - "group_key": { - "type": "string", - "format": "byte", - "description": "The 32-byte asset group key specified as raw bytes (gRPC only)." - }, - "group_key_str": { - "type": "string", - "description": "The 32-byte asset group key encoded as hex string (use this for\nREST)." - } - } - }, - "rfqrpcIncomingAcceptQuoteEvent": { + "rfqrpcPeerAcceptedBuyQuoteEvent": { "type": "object", "properties": { "timestamp": { @@ -480,30 +480,31 @@ "format": "uint64", "description": "Unix timestamp." }, - "accepted_quote": { - "$ref": "#/definitions/rfqrpcAcceptedQuote", - "description": "The accepted quote." + "peer_accepted_buy_quote": { + "$ref": "#/definitions/rfqrpcPeerAcceptedBuyQuote", + "description": "The asset buy quote that was accepted by out peer." } } }, - "rfqrpcQueryRfqAcceptedQuotesResponse": { + "rfqrpcQueryPeerAcceptedQuotesResponse": { "type": "object", "properties": { - "accepted_quotes": { + "buy_quotes": { "type": "array", "items": { "type": "object", - "$ref": "#/definitions/rfqrpcAcceptedQuote" - } + "$ref": "#/definitions/rfqrpcPeerAcceptedBuyQuote" + }, + "description": "buy_quotes is a list of asset buy quotes which were requested by our\nnode and have been accepted by our peers." } } }, "rfqrpcRfqEvent": { "type": "object", "properties": { - "incoming_accept_quote": { - "$ref": "#/definitions/rfqrpcIncomingAcceptQuoteEvent", - "description": "incoming_accept_quote is an event that is sent when an incoming\naccept quote message is received." + "peer_accepted_buy_quote": { + "$ref": "#/definitions/rfqrpcPeerAcceptedBuyQuoteEvent", + "description": "peer_accepted_buy_quote is an event that is emitted when a peer\naccepted (incoming) asset buy quote message is received." }, "accept_htlc": { "$ref": "#/definitions/rfqrpcAcceptHtlcEvent", diff --git a/taprpc/rfqrpc/rfq.yaml b/taprpc/rfqrpc/rfq.yaml index b91892d1e..26ea695b8 100644 --- a/taprpc/rfqrpc/rfq.yaml +++ b/taprpc/rfqrpc/rfq.yaml @@ -17,8 +17,8 @@ http: - post: "/v1/taproot-assets/rfq/selloffer/group-key/{asset_specifier.group_key_str}" body: "*" - - selector: rfqrpc.Rfq.QueryRfqAcceptedQuotes - get: "/v1/taproot-assets/rfq/quotes/accepted" + - selector: rfqrpc.Rfq.QueryPeerAcceptedQuotes + get: "/v1/taproot-assets/rfq/quotes/peeraccepted" - selector: rfqrpc.Rfq.SubscribeRfqEventNtfns post: "/v1/taproot-assets/rfq/ntfs" diff --git a/taprpc/rfqrpc/rfq_grpc.pb.go b/taprpc/rfqrpc/rfq_grpc.pb.go index 2f6488d9d..2b62b074c 100644 --- a/taprpc/rfqrpc/rfq_grpc.pb.go +++ b/taprpc/rfqrpc/rfq_grpc.pb.go @@ -26,10 +26,10 @@ type RfqClient interface { // AddAssetSellOffer is used to add a sell offer for a specific asset. If a // sell offer already exists for the asset, it will be updated. AddAssetSellOffer(ctx context.Context, in *AddAssetSellOfferRequest, opts ...grpc.CallOption) (*AddAssetSellOfferResponse, error) - // tapcli: `rfq acceptedquotes` - // QueryRfqAcceptedQuotes is used to upsert a sell order for a specific - // asset. - QueryRfqAcceptedQuotes(ctx context.Context, in *QueryRfqAcceptedQuotesRequest, opts ...grpc.CallOption) (*QueryRfqAcceptedQuotesResponse, error) + // tapcli: `rfq peeracceptedquotes` + // QueryPeerAcceptedQuotes is used to query for quotes that were requested by + // our node and have been accepted our peers. + QueryPeerAcceptedQuotes(ctx context.Context, in *QueryPeerAcceptedQuotesRequest, opts ...grpc.CallOption) (*QueryPeerAcceptedQuotesResponse, error) // SubscribeRfqEventNtfns is used to subscribe to RFQ events. SubscribeRfqEventNtfns(ctx context.Context, in *SubscribeRfqEventNtfnsRequest, opts ...grpc.CallOption) (Rfq_SubscribeRfqEventNtfnsClient, error) } @@ -60,9 +60,9 @@ func (c *rfqClient) AddAssetSellOffer(ctx context.Context, in *AddAssetSellOffer return out, nil } -func (c *rfqClient) QueryRfqAcceptedQuotes(ctx context.Context, in *QueryRfqAcceptedQuotesRequest, opts ...grpc.CallOption) (*QueryRfqAcceptedQuotesResponse, error) { - out := new(QueryRfqAcceptedQuotesResponse) - err := c.cc.Invoke(ctx, "/rfqrpc.Rfq/QueryRfqAcceptedQuotes", in, out, opts...) +func (c *rfqClient) QueryPeerAcceptedQuotes(ctx context.Context, in *QueryPeerAcceptedQuotesRequest, opts ...grpc.CallOption) (*QueryPeerAcceptedQuotesResponse, error) { + out := new(QueryPeerAcceptedQuotesResponse) + err := c.cc.Invoke(ctx, "/rfqrpc.Rfq/QueryPeerAcceptedQuotes", in, out, opts...) if err != nil { return nil, err } @@ -113,10 +113,10 @@ type RfqServer interface { // AddAssetSellOffer is used to add a sell offer for a specific asset. If a // sell offer already exists for the asset, it will be updated. AddAssetSellOffer(context.Context, *AddAssetSellOfferRequest) (*AddAssetSellOfferResponse, error) - // tapcli: `rfq acceptedquotes` - // QueryRfqAcceptedQuotes is used to upsert a sell order for a specific - // asset. - QueryRfqAcceptedQuotes(context.Context, *QueryRfqAcceptedQuotesRequest) (*QueryRfqAcceptedQuotesResponse, error) + // tapcli: `rfq peeracceptedquotes` + // QueryPeerAcceptedQuotes is used to query for quotes that were requested by + // our node and have been accepted our peers. + QueryPeerAcceptedQuotes(context.Context, *QueryPeerAcceptedQuotesRequest) (*QueryPeerAcceptedQuotesResponse, error) // SubscribeRfqEventNtfns is used to subscribe to RFQ events. SubscribeRfqEventNtfns(*SubscribeRfqEventNtfnsRequest, Rfq_SubscribeRfqEventNtfnsServer) error mustEmbedUnimplementedRfqServer() @@ -132,8 +132,8 @@ func (UnimplementedRfqServer) AddAssetBuyOrder(context.Context, *AddAssetBuyOrde func (UnimplementedRfqServer) AddAssetSellOffer(context.Context, *AddAssetSellOfferRequest) (*AddAssetSellOfferResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AddAssetSellOffer not implemented") } -func (UnimplementedRfqServer) QueryRfqAcceptedQuotes(context.Context, *QueryRfqAcceptedQuotesRequest) (*QueryRfqAcceptedQuotesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryRfqAcceptedQuotes not implemented") +func (UnimplementedRfqServer) QueryPeerAcceptedQuotes(context.Context, *QueryPeerAcceptedQuotesRequest) (*QueryPeerAcceptedQuotesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryPeerAcceptedQuotes not implemented") } func (UnimplementedRfqServer) SubscribeRfqEventNtfns(*SubscribeRfqEventNtfnsRequest, Rfq_SubscribeRfqEventNtfnsServer) error { return status.Errorf(codes.Unimplemented, "method SubscribeRfqEventNtfns not implemented") @@ -187,20 +187,20 @@ func _Rfq_AddAssetSellOffer_Handler(srv interface{}, ctx context.Context, dec fu return interceptor(ctx, in, info, handler) } -func _Rfq_QueryRfqAcceptedQuotes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryRfqAcceptedQuotesRequest) +func _Rfq_QueryPeerAcceptedQuotes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPeerAcceptedQuotesRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(RfqServer).QueryRfqAcceptedQuotes(ctx, in) + return srv.(RfqServer).QueryPeerAcceptedQuotes(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/rfqrpc.Rfq/QueryRfqAcceptedQuotes", + FullMethod: "/rfqrpc.Rfq/QueryPeerAcceptedQuotes", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(RfqServer).QueryRfqAcceptedQuotes(ctx, req.(*QueryRfqAcceptedQuotesRequest)) + return srv.(RfqServer).QueryPeerAcceptedQuotes(ctx, req.(*QueryPeerAcceptedQuotesRequest)) } return interceptor(ctx, in, info, handler) } @@ -242,8 +242,8 @@ var Rfq_ServiceDesc = grpc.ServiceDesc{ Handler: _Rfq_AddAssetSellOffer_Handler, }, { - MethodName: "QueryRfqAcceptedQuotes", - Handler: _Rfq_QueryRfqAcceptedQuotes_Handler, + MethodName: "QueryPeerAcceptedQuotes", + Handler: _Rfq_QueryPeerAcceptedQuotes_Handler, }, }, Streams: []grpc.StreamDesc{ From 3196ea9ad69d82d6ddc168fd2c62fb926635440a Mon Sep 17 00:00:00 2001 From: ffranr Date: Mon, 18 Mar 2024 13:54:58 +0000 Subject: [PATCH 5/8] itest: rename RFQ test to clarify payment init by asset buy request In this commit we rename a test and update its doc to clarify that the payment made as part of the test is initiated via an asset buy RFQ request. This change is made in preparation for adding a future itest where a payment is made following an asset sell RFQ request. --- itest/rfq_test.go | 16 ++++++++++------ itest/test_list_on_test.go | 4 ++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/itest/rfq_test.go b/itest/rfq_test.go index 5dc3767ce..239e1d401 100644 --- a/itest/rfq_test.go +++ b/itest/rfq_test.go @@ -20,18 +20,22 @@ import ( "github.com/stretchr/testify/require" ) -// testRfqHtlcIntercept tests RFQ negotiation and HTLC interception and -// validation between three peers. +// testRfqAssetBuyHtlcIntercept tests RFQ negotiation, HTLC interception, and +// validation between three peers. The RFQ negotiation is initiated by an asset +// buy request. // // The procedure is as follows: -// 1. Carol sends a tap asset request for quote (buy order) to Bob. +// 1. Carol sends a tap asset buy quote request to Bob. // 2. Bob's node accepts the quote. -// 3. Carol uses the quote accept message to construct a lightning invoice which -// will pay for the quote accepted by Bob. +// 3. Carol uses the buy accept message to construct a lightning invoice +// which will pay for the quote accepted by Bob. // 4. Alice pays the invoice. // 5. Bob's node intercepts the lightning payment from Alice and validates it // against the quote accepted between Bob and Carol. -func testRfqHtlcIntercept(t *harnessTest) { +// +// As a final step (which is not part of this test), Bob's node will transfer +// the tap asset to Carol's node. +func testRfqAssetBuyHtlcIntercept(t *harnessTest) { // Initialize a new test scenario. ts := newRfqTestScenario(t) diff --git a/itest/test_list_on_test.go b/itest/test_list_on_test.go index 624254703..5d7bfccd6 100644 --- a/itest/test_list_on_test.go +++ b/itest/test_list_on_test.go @@ -244,8 +244,8 @@ var testCases = []*testCase{ // Request for quote (RFQ) tests. { - name: "rfq htlc intercept", - test: testRfqHtlcIntercept, + name: "rfq asset buy htlc intercept", + test: testRfqAssetBuyHtlcIntercept, }, { name: "multi signature on all levels", From ff6aebfb42265f771bc0125112ab559043ee89b0 Mon Sep 17 00:00:00 2001 From: ffranr Date: Mon, 18 Mar 2024 15:58:02 +0000 Subject: [PATCH 6/8] rfq: mock price oracle `QueryAskPrice` selects given bid or const In this commit we ensure that the mock price oracle returns an ask price when queried even if a suggested bid price is not provided. --- rfq/oracle.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rfq/oracle.go b/rfq/oracle.go index 9e01e3adb..34753e91f 100644 --- a/rfq/oracle.go +++ b/rfq/oracle.go @@ -145,8 +145,13 @@ func (m *MockPriceOracle) QueryAskPrice(_ context.Context, // Calculate the rate expiryDelay lifetime. expiry := uint64(time.Now().Unix()) + m.expiryDelay + askPrice := lnwire.MilliSatoshi(42000) + if suggestedBidPrice != nil { + askPrice = *suggestedBidPrice + } + return &OracleAskResponse{ - AskPrice: suggestedBidPrice, + AskPrice: &askPrice, Expiry: expiry, }, nil } From d9da309bb5e3abf2077c14292a4d0a688af8d248 Mon Sep 17 00:00:00 2001 From: ffranr Date: Tue, 19 Mar 2024 13:39:56 +0000 Subject: [PATCH 7/8] rfq+rpc: refactor order handler channel remit structure This commit makes three changes: 1. Drop the word "remit" in favour of the more well known word "policy". 2. Make the policy struct asset sale specific to make room for an asset purchase policy which will be added in a future commit. 3. Add new `Policy` interface so that the code remains simple going forward. --- rfq/manager.go | 12 ++-- rfq/order.go | 171 ++++++++++++++++++++++++++++--------------------- rpcserver.go | 2 +- 3 files changed, 105 insertions(+), 80 deletions(-) diff --git a/rfq/manager.go b/rfq/manager.go index f3deea225..0c8f5290f 100644 --- a/rfq/manager.go +++ b/rfq/manager.go @@ -557,18 +557,18 @@ type AcceptHtlcEvent struct { // Htlc is the intercepted HTLC. Htlc lndclient.InterceptedHtlc - // ChannelRemit is the channel remit that the HTLC complies with. - ChannelRemit ChannelRemit + // Policy is the policy with which the HTLC is compliant. + Policy Policy } // NewAcceptHtlcEvent creates a new AcceptedHtlcEvent. func NewAcceptHtlcEvent(htlc lndclient.InterceptedHtlc, - channelRemit ChannelRemit) *AcceptHtlcEvent { + policy Policy) *AcceptHtlcEvent { return &AcceptHtlcEvent{ - timestamp: uint64(time.Now().UTC().Unix()), - Htlc: htlc, - ChannelRemit: channelRemit, + timestamp: uint64(time.Now().UTC().Unix()), + Htlc: htlc, + Policy: policy, } } diff --git a/rfq/order.go b/rfq/order.go index 6c5092a81..e9d71be50 100644 --- a/rfq/order.go +++ b/rfq/order.go @@ -16,12 +16,27 @@ import ( // SerialisedScid is a serialised short channel id (SCID). type SerialisedScid uint64 -// ChannelRemit is a struct that holds the terms which determine whether a -// channel HTLC is accepted or rejected. -type ChannelRemit struct { - // Scid is the serialised short channel ID (SCID) of the channel to - // which the remit applies. - Scid SerialisedScid +// Policy is an interface that abstracts the terms which determine whether an +// asset sale/purchase channel HTLC is accepted or rejected. +type Policy interface { + // CheckHtlcCompliance returns an error if the given HTLC intercept + // descriptor does not satisfy the subject policy. + CheckHtlcCompliance(htlc lndclient.InterceptedHtlc) error + + // Expiry returns the policy's expiry time as a unix timestamp. + Expiry() uint64 + + // Scid returns the serialised short channel ID (SCID) of the channel to + // which the policy applies. + Scid() uint64 +} + +// AssetSalePolicy is a struct that holds the terms which determine whether an +// asset sale channel HTLC is accepted or rejected. +type AssetSalePolicy struct { + // scid is the serialised short channel ID (SCID) of the channel to + // which the policy applies. + scid SerialisedScid // AssetAmount is the amount of the tap asset that is being requested. AssetAmount uint64 @@ -30,52 +45,67 @@ type ChannelRemit struct { // must be sent in the HTLC. MinimumChannelPayment lnwire.MilliSatoshi - // Expiry is the asking price expiryDelay lifetime unix timestamp. - Expiry uint64 + // expiry is the policy's expiry unix timestamp after which the policy + // is no longer valid. + expiry uint64 } -// NewChannelRemit creates a new channel remit. -func NewChannelRemit(quoteAccept rfqmsg.BuyAccept) *ChannelRemit { +// NewAssetSalePolicy creates a new asset sale policy. +func NewAssetSalePolicy(quote rfqmsg.BuyAccept) *AssetSalePolicy { // Compute the serialised short channel ID (SCID) for the channel. - scid := SerialisedScid(quoteAccept.ShortChannelId()) + scid := SerialisedScid(quote.ShortChannelId()) - return &ChannelRemit{ - Scid: scid, - AssetAmount: quoteAccept.AssetAmount, - MinimumChannelPayment: quoteAccept.AskPrice, - Expiry: quoteAccept.Expiry, + return &AssetSalePolicy{ + scid: scid, + AssetAmount: quote.AssetAmount, + MinimumChannelPayment: quote.AskPrice, + expiry: quote.Expiry, } } // CheckHtlcCompliance returns an error if the given HTLC intercept descriptor -// does not satisfy the subject channel remit. -func (c *ChannelRemit) CheckHtlcCompliance( +// does not satisfy the subject policy. +func (c *AssetSalePolicy) CheckHtlcCompliance( htlc lndclient.InterceptedHtlc) error { // Check that the channel SCID is as expected. htlcScid := SerialisedScid(htlc.OutgoingChannelID.ToUint64()) - if htlcScid != c.Scid { + if htlcScid != c.scid { return fmt.Errorf("htlc outgoing channel ID does not match "+ - "remit's SCID (htlc_scid=%d, remit_scid=%d)", htlcScid, - c.Scid) + "policy's SCID (htlc_scid=%d, policy_scid=%d)", + htlcScid, c.scid) } // Check that the HTLC amount is at least the minimum acceptable amount. if htlc.AmountOutMsat < c.MinimumChannelPayment { - return fmt.Errorf("htlc out amount is less than the remit's "+ - "minimum (htlc_out_msat=%d, remit_min_msat=%d)", + return fmt.Errorf("htlc out amount is less than the policy "+ + "minimum (htlc_out_msat=%d, policy_min_msat=%d)", htlc.AmountOutMsat, c.MinimumChannelPayment) } - // Lastly, check to ensure that the channel remit has not expired. - if time.Now().Unix() > int64(c.Expiry) { - return fmt.Errorf("channel remit has expired "+ - "(expiry_unix_ts=%d)", c.Expiry) + // Lastly, check to ensure that the policy has not expired. + if time.Now().Unix() > int64(c.expiry) { + return fmt.Errorf("policy has expired (expiry_unix_ts=%d)", + c.expiry) } return nil } +// Expiry returns the policy's expiry time as a unix timestamp. +func (c *AssetSalePolicy) Expiry() uint64 { + return c.expiry +} + +// Scid returns the serialised short channel ID (SCID) of the channel to which +// the policy applies. +func (c *AssetSalePolicy) Scid() uint64 { + return uint64(c.scid) +} + +// Ensure that AssetSalePolicy implements the Policy interface. +var _ Policy = (*AssetSalePolicy)(nil) + // OrderHandlerCfg is a struct that holds the configuration parameters for the // order handler service. type OrderHandlerCfg struct { @@ -101,9 +131,9 @@ type OrderHandler struct { // cfg holds the configuration parameters for the RFQ order handler. cfg OrderHandlerCfg - // channelRemits is a map of serialised short channel IDs (SCIDs) to - // associated active channel remits. - channelRemits lnutils.SyncMap[SerialisedScid, *ChannelRemit] + // policies is a map of serialised short channel IDs (SCIDs) to + // associated asset transaction policies. + policies lnutils.SyncMap[SerialisedScid, Policy] // ContextGuard provides a wait group and main quit channel that can be // used to create guarded contexts. @@ -113,8 +143,8 @@ type OrderHandler struct { // NewOrderHandler creates a new struct instance. func NewOrderHandler(cfg OrderHandlerCfg) (*OrderHandler, error) { return &OrderHandler{ - cfg: cfg, - channelRemits: lnutils.SyncMap[SerialisedScid, *ChannelRemit]{}, + cfg: cfg, + policies: lnutils.SyncMap[SerialisedScid, Policy]{}, ContextGuard: &fn.ContextGuard{ DefaultTimeout: DefaultTimeout, Quit: make(chan struct{}), @@ -133,34 +163,33 @@ func (h *OrderHandler) handleIncomingHtlc(_ context.Context, log.Debug("Handling incoming HTLC") scid := SerialisedScid(htlc.OutgoingChannelID.ToUint64()) - channelRemit, ok := h.fetchChannelRemit(scid) + policy, ok := h.fetchPolicy(scid) - // If a channel remit does not exist for the channel SCID, we resume the - // HTLC. This is because the HTLC may be relevant to another interceptor + // If a policy does not exist for the channel SCID, we resume the HTLC. + // This is because the HTLC may be relevant to another interceptor // service. We only reject HTLCs that are relevant to the RFQ service - // and do not comply with a known channel remit. + // and do not comply with a known policy. if !ok { return &lndclient.InterceptedHtlcResponse{ Action: lndclient.InterceptorActionResume, }, nil } - // At this point, we know that the channel remit exists and has not - // expired whilst sitting in the local cache. We can now check that the - // HTLC complies with the channel remit. - err := channelRemit.CheckHtlcCompliance(htlc) + // At this point, we know that a policy exists and has not expired + // whilst sitting in the local cache. We can now check that the HTLC + // complies with the policy. + err := policy.CheckHtlcCompliance(htlc) if err != nil { - log.Warnf("HTLC does not comply with channel remit: %v "+ - "(htlc=%v, channel_remit=%v)", err, htlc, channelRemit) + log.Warnf("HTLC does not comply with policy: %v "+ + "(htlc=%v, policy=%v)", err, htlc, policy) return &lndclient.InterceptedHtlcResponse{ Action: lndclient.InterceptorActionFail, }, nil } - log.Debug("HTLC complies with channel remit. Broadcasting accept " + - "event.") - acceptHtlcEvent := NewAcceptHtlcEvent(htlc, *channelRemit) + log.Debug("HTLC complies with policy. Broadcasting accept event.") + acceptHtlcEvent := NewAcceptHtlcEvent(htlc, policy) h.cfg.AcceptHtlcEvents <- acceptHtlcEvent return &lndclient.InterceptedHtlcResponse{ @@ -195,12 +224,11 @@ func (h *OrderHandler) mainEventLoop() { for { select { - // Periodically clean up expired channel remits from our local - // cache. + // Periodically clean up expired policies from our local cache. case <-cleanupTicker.C: - log.Debug("Cleaning up any stale channel remits from " + - "the order handler") - h.cleanupStaleChannelRemits() + log.Debug("Cleaning up any stale policy from the " + + "order handler") + h.cleanupStalePolicies() case <-h.Quit: log.Debug("Received quit signal. Stopping negotiator " + @@ -245,47 +273,44 @@ func (h *OrderHandler) RegisterAssetSalePolicy(buyAccept rfqmsg.BuyAccept) { log.Debugf("Order handler is registering an asset sale policy given a "+ "buy accept message: %s", buyAccept.String()) - channelRemit := NewChannelRemit(buyAccept) - h.channelRemits.Store(channelRemit.Scid, channelRemit) + policy := NewAssetSalePolicy(buyAccept) + h.policies.Store(policy.scid, policy) } -// fetchChannelRemit fetches a channel remit given a serialised SCID. If a -// channel remit is not found, false is returned. Expired channel remits are -// not returned and are removed from the cache. -func (h *OrderHandler) fetchChannelRemit(scid SerialisedScid) (*ChannelRemit, - bool) { - - remit, ok := h.channelRemits.Load(scid) +// fetchPolicy fetches a policy given a serialised SCID. If a policy is not +// found, false is returned. Expired policies are not returned and are removed +// from the cache. +func (h *OrderHandler) fetchPolicy(scid SerialisedScid) (Policy, bool) { + policy, ok := h.policies.Load(scid) if !ok { return nil, false } - // If the remit has expired, return false and clear it from the cache. - expireTime := time.Unix(int64(remit.Expiry), 0).UTC() + // If the policy has expired, return false and clear it from the cache. + expireTime := time.Unix(int64(policy.Expiry()), 0).UTC() currentTime := time.Now().UTC() if currentTime.After(expireTime) { - h.channelRemits.Delete(scid) + h.policies.Delete(scid) return nil, false } - return remit, true + return policy, true } -// cleanupStaleChannelRemits removes expired channel remits from the local -// cache. -func (h *OrderHandler) cleanupStaleChannelRemits() { - // Iterate over the channel remits and remove any that have expired. +// cleanupStalePolicies removes expired policies from the local cache. +func (h *OrderHandler) cleanupStalePolicies() { + // Iterate over policies and remove any that have expired. staleCounter := 0 - h.channelRemits.ForEach( - func(scid SerialisedScid, remit *ChannelRemit) error { - expireTime := time.Unix(int64(remit.Expiry), 0).UTC() + h.policies.ForEach( + func(scid SerialisedScid, policy Policy) error { + expireTime := time.Unix(int64(policy.Expiry()), 0).UTC() currentTime := time.Now().UTC() if currentTime.After(expireTime) { staleCounter++ - h.channelRemits.Delete(scid) + h.policies.Delete(scid) } return nil @@ -293,8 +318,8 @@ func (h *OrderHandler) cleanupStaleChannelRemits() { ) if staleCounter > 0 { - log.Tracef("Removed stale channel remits from the order "+ - "handler: (count=%d)", staleCounter) + log.Tracef("Removed stale policies from the order handler: "+ + "(count=%d)", staleCounter) } } diff --git a/rpcserver.go b/rpcserver.go index 2928c5a1f..c3ef9e8f3 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -5625,7 +5625,7 @@ func marshallRfqEvent(eventInterface fn.Event) (*rfqrpc.RfqEvent, error) { eventRpc := &rfqrpc.RfqEvent_AcceptHtlc{ AcceptHtlc: &rfqrpc.AcceptHtlcEvent{ Timestamp: uint64(timestamp), - Scid: uint64(event.ChannelRemit.Scid), + Scid: event.Policy.Scid(), }, } return &rfqrpc.RfqEvent{ From 13dddf3dff39f6d2fe5c7aaa32feb62fc59b1988 Mon Sep 17 00:00:00 2001 From: ffranr Date: Tue, 19 Mar 2024 17:23:48 +0000 Subject: [PATCH 8/8] rfqmsg: add SCID method to ID type The short channel ID (SCID) is derived from the message ID. We add a method to the message ID type in an effort to remove duplication of the SCID derivation code. --- rfqmsg/buy_accept.go | 9 +-------- rfqmsg/messages.go | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/rfqmsg/buy_accept.go b/rfqmsg/buy_accept.go index c68ebfdd7..e3923dbf1 100644 --- a/rfqmsg/buy_accept.go +++ b/rfqmsg/buy_accept.go @@ -2,7 +2,6 @@ package rfqmsg import ( "bytes" - "encoding/binary" "fmt" "io" @@ -198,13 +197,7 @@ func NewBuyAcceptFromWireMsg(wireMsg WireMessage) (*BuyAccept, error) { // ShortChannelId returns the short channel ID of the quote accept. func (q *BuyAccept) ShortChannelId() SerialisedScid { - // Given valid RFQ message id, we then define a RFQ short chain id - // (SCID) by taking the last 8 bytes of the RFQ message id and - // interpreting them as a 64-bit integer. - scidBytes := q.ID[24:] - - scidInteger := binary.BigEndian.Uint64(scidBytes) - return SerialisedScid(scidInteger) + return q.ID.Scid() } // ToWire returns a wire message with a serialized data field. diff --git a/rfqmsg/messages.go b/rfqmsg/messages.go index 39dc0ed3d..5796d5436 100644 --- a/rfqmsg/messages.go +++ b/rfqmsg/messages.go @@ -1,6 +1,7 @@ package rfqmsg import ( + "encoding/binary" "encoding/hex" "errors" "math" @@ -9,6 +10,9 @@ import ( "github.com/lightningnetwork/lnd/routing/route" ) +// SerialisedScid is a serialised short channel id (SCID). +type SerialisedScid uint64 + // ID is the identifier for a RFQ message. type ID [32]byte @@ -17,8 +21,16 @@ func (id ID) String() string { return hex.EncodeToString(id[:]) } -// SerialisedScid is a serialised short channel id (SCID). -type SerialisedScid uint64 +// Scid returns the short channel id (SCID) of the RFQ message. +func (id ID) Scid() SerialisedScid { + // Given valid RFQ message id, we then define a RFQ short channel id + // (SCID) by taking the last 8 bytes of the RFQ message id and + // interpreting them as a 64-bit integer. + scidBytes := id[24:] + + scidInteger := binary.BigEndian.Uint64(scidBytes) + return SerialisedScid(scidInteger) +} // MaxMessageType is the maximum supported message type value. const MaxMessageType = lnwire.MessageType(math.MaxUint16)