Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ffranr committed Nov 7, 2022
1 parent 4eb4b38 commit 3582501
Show file tree
Hide file tree
Showing 13 changed files with 322 additions and 210 deletions.
1 change: 1 addition & 0 deletions auctioneer/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ func (c *Client) SubmitOrder(ctx context.Context, o order.Order,
IsSidecarChannel: castOrder.SidecarTicket != nil,
UnannouncedChannel: castOrder.UnannouncedChannel,
ZeroConfChannel: castOrder.ZeroConfChannel,
MinReserveChannel: castOrder.MinReserveChannel,
}
rpcRequest.Details = &auctioneerrpc.ServerSubmitOrderRequest_Bid{
Bid: serverBid,
Expand Down
15 changes: 14 additions & 1 deletion auctioneerrpc/auctioneer.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions auctioneerrpc/auctioneer.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,11 @@ message ServerBid {
Signals if this bid is interested in a zero conf channel or not.
*/
bool zero_conf_channel = 9;

/*
Signals if this bid is interested in a minimal reserve channel.
*/
bool min_reserve_channel = 10;
}

message ServerAsk {
Expand Down
12 changes: 12 additions & 0 deletions channel_acceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,18 @@ func (s *ChannelAcceptor) acceptChannel(_ context.Context,
}, nil
}

// If a minimal reserve channel is expected, ensure that the channel
// reserve is equal to the dust limit (minimum according to BOLT#2).
if expectedChanBid.MinReserveChannel {
if req.ChannelReserve != req.DustLimit {
return &lndclient.AcceptorResponse{
Accept: false,
Error: "channel reserve not set to dust limit " +
"even though minimal reserve channel expected",
}, nil
}
}

return &lndclient.AcceptorResponse{
Accept: true,
}, nil
Expand Down
16 changes: 16 additions & 0 deletions clientdb/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ const (
// orderIsPublicType is the tlv type we use to store a flag value when
// it is ok to share details of this order in public markets.
orderIsPublicType tlv.Type = 11

// bidMinReserveChannelType is the tlv type we use to store a flag
// value when a bid accepts minimal reserve channels.
bidMinReserveChannelType tlv.Type = 12
)

var (
Expand Down Expand Up @@ -704,6 +708,7 @@ func deserializeOrderTlvData(r io.Reader, o order.Order) error {
askConfirmationConstraints uint8
auctionType uint8
isPublic uint8
bidMinReserveChannel uint8
)

// We'll add records for all possible additional order data fields here
Expand Down Expand Up @@ -733,6 +738,7 @@ func deserializeOrderTlvData(r io.Reader, o order.Order) error {
),
tlv.MakePrimitiveRecord(orderAuctionType, &auctionType),
tlv.MakePrimitiveRecord(orderIsPublicType, &isPublic),
tlv.MakePrimitiveRecord(bidMinReserveChannelType, &bidMinReserveChannel),
)
if err != nil {
return err
Expand Down Expand Up @@ -788,6 +794,11 @@ func deserializeOrderTlvData(r io.Reader, o order.Order) error {
if ok && t == nil && bidZeroConf == 1 {
castOrder.ZeroConfChannel = true
}

t, ok = parsedTypes[bidMinReserveChannelType]
if ok && t == nil && bidMinReserveChannel == 1 {
castOrder.MinReserveChannel = true
}
}

if t, ok := parsedTypes[orderChannelType]; ok && t == nil {
Expand Down Expand Up @@ -831,6 +842,7 @@ func serializeOrderTlvData(w io.Writer, o order.Order) error {
bidUnannouncedChannel uint8
askConfirmationConstraints uint8
bidZeroConfChannel uint8
bidMinReserveChannel uint8
)

switch castOrder := o.(type) {
Expand Down Expand Up @@ -910,6 +922,10 @@ func serializeOrderTlvData(w io.Writer, o order.Order) error {
bidZeroConfType, &bidZeroConfChannel,
))

tlvRecords = append(tlvRecords, tlv.MakePrimitiveRecord(
bidMinReserveChannelType, &bidMinReserveChannel,
))

tlvRecords = append(tlvRecords, tlv.MakePrimitiveRecord(
askChannelConfirmationConstraintsType,
&askConfirmationConstraints,
Expand Down
6 changes: 6 additions & 0 deletions cmd/pool/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ var baseBidFlags = []cli.Flag{
"the channels resulting from matching this order " +
"will be announced to the network",
},
cli.BoolFlag{
Name: "min_reserve_channel",
Usage: "flag used to signal that this bid is interested only " +
"in channels which have minimal reserves",
},
cli.BoolFlag{
Name: "zero_conf_channel",
Usage: "flag used to signal that this bid is only interested " +
Expand Down Expand Up @@ -685,6 +690,7 @@ func parseBaseBid(ctx *cli.Context) (*poolrpc.Bid, *sidecar.Ticket, error) {
MinNodeTier: nodeTier,
UnannouncedChannel: ctx.Bool("unannounced_channel"),
ZeroConfChannel: ctx.Bool("zero_conf_channel"),
MinReserveChannel: ctx.Bool("min_reserve_channel"),
}

// Let's find out if this is an order for a sidecar channel because if
Expand Down
4 changes: 4 additions & 0 deletions order/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,10 @@ type Bid struct {
// ZeroConfChannel signals if the resulting channels need to be zero
// conf or not.
ZeroConfChannel bool

// MinReserveChannel signals if the resulting channels may have minimal
// reserves or not.
MinReserveChannel bool
}

// Type returns the order type.
Expand Down
Loading

0 comments on commit 3582501

Please sign in to comment.