order+auctioneer: allow submission of order channel type to auctioneer

This commit is contained in:
Wilmer Paulino 2021-07-26 16:05:01 -07:00 committed by Olaoluwa Osuntokun
parent 2adf6939c3
commit 321e3c3598
No known key found for this signature in database
GPG key ID: 3BBD59E99B280306
7 changed files with 1472 additions and 1302 deletions

View file

@ -406,6 +406,17 @@ func (c *Client) SubmitOrder(ctx context.Context, o order.Order,
Addr: addr.String(),
})
}
var channelType auctioneerrpc.OrderChannelType
switch o.Details().ChannelType {
case order.ChannelTypePeerDependent:
channelType = auctioneerrpc.OrderChannelType_ORDER_CHANNEL_TYPE_PEER_DEPENDENT
case order.ChannelTypeScriptEnforced:
channelType = auctioneerrpc.OrderChannelType_ORDER_CHANNEL_TYPE_SCRIPT_ENFORCED
default:
return fmt.Errorf("unhandled channel type %v", c)
}
details := &auctioneerrpc.ServerOrder{
TraderKey: o.Details().AcctKey[:],
RateFixed: o.Details().FixedRate,
@ -416,6 +427,7 @@ func (c *Client) SubmitOrder(ctx context.Context, o order.Order,
MultiSigKey: serverParams.MultiSigKey[:],
NodePub: serverParams.NodePubkey[:],
NodeAddr: nodeAddrs,
ChannelType: channelType,
MaxBatchFeeRateSatPerKw: uint64(o.Details().MaxBatchFeeRate),
}

File diff suppressed because it is too large Load diff

View file

@ -783,6 +783,24 @@ message AccountDiff {
bytes trader_key = 4;
}
enum OrderChannelType {
// Used to set defaults when a trader doesn't specify a channel type.
ORDER_CHANNEL_TYPE_UNKNOWN = 0;
/*
The channel type will vary per matched channel based on the features shared
between its participants.
*/
ORDER_CHANNEL_TYPE_PEER_DEPENDENT = 1;
/*
A channel type that builds upon the anchors commitment format to enforce
channel lease maturities in the commitment and HTLC outputs that pay to the
channel initiator/seller.
*/
ORDER_CHANNEL_TYPE_SCRIPT_ENFORCED = 2;
}
message ServerOrder {
/*
The trader's account key of the account to use for the order.
@ -843,7 +861,7 @@ message ServerOrder {
/*
The type of the channel that should be opened.
*/
uint32 chan_type = 12;
OrderChannelType channel_type = 12;
/*
Maximum fee rate the trader is willing to pay for the batch transaction,
@ -1202,7 +1220,7 @@ message AskSnapshot {
uint32 rate_fixed = 3;
// The channel type to be created.
uint32 chan_type = 4;
OrderChannelType chan_type = 4;
}
message BidSnapshot {
// The version of the order.
@ -1215,7 +1233,7 @@ message BidSnapshot {
uint32 rate_fixed = 3;
// The channel type to be created.
uint32 chan_type = 4;
OrderChannelType chan_type = 4;
}
message MatchedOrderSnapshot {
// The full ask order that was matched.

View file

@ -62,6 +62,25 @@ func ParseRPCOrder(version, leaseDuration uint32,
}
kit.MinUnitsMatch = SupplyUnit(details.MinUnitsMatch)
switch details.ChannelType {
// Default value, trader didn't specify a channel type.
case auctioneerrpc.OrderChannelType_ORDER_CHANNEL_TYPE_UNKNOWN:
// TODO: Switch to script enforcement by default once we can
// enforce the lnd release supporting script enforced channels
// as the minimalCompatibleVersion.
kit.ChannelType = ChannelTypePeerDependent
case auctioneerrpc.OrderChannelType_ORDER_CHANNEL_TYPE_PEER_DEPENDENT:
kit.ChannelType = ChannelTypePeerDependent
case auctioneerrpc.OrderChannelType_ORDER_CHANNEL_TYPE_SCRIPT_ENFORCED:
kit.ChannelType = ChannelTypeScriptEnforced
default:
return nil, fmt.Errorf("unhandled channel type %v",
details.ChannelType)
}
return kit, nil
}
@ -169,6 +188,22 @@ func ParseRPCServerOrder(version uint32, details *auctioneerrpc.ServerOrder,
}
copy(multiSigKey[:], multiSigPubkey.SerializeCompressed())
switch details.ChannelType {
// Default value, trader didn't specify a channel type.
case auctioneerrpc.OrderChannelType_ORDER_CHANNEL_TYPE_UNKNOWN:
kit.ChannelType = ChannelTypePeerDependent
case auctioneerrpc.OrderChannelType_ORDER_CHANNEL_TYPE_PEER_DEPENDENT:
kit.ChannelType = ChannelTypePeerDependent
case auctioneerrpc.OrderChannelType_ORDER_CHANNEL_TYPE_SCRIPT_ENFORCED:
kit.ChannelType = ChannelTypeScriptEnforced
default:
return nil, nodeKey, nil, multiSigKey,
fmt.Errorf("unhandled channel type %v", details.ChannelType)
}
return kit, nodeKey, nodeAddrs, multiSigKey, nil
}

File diff suppressed because it is too large Load diff

View file

@ -601,6 +601,9 @@ message Order {
// The minimum number of order units that must be matched per order pair.
uint32 min_units_match = 12;
// The channel type to use for the resulting matched channels.
OrderChannelType channel_type = 13;
}
message Bid {

View file

@ -1067,8 +1067,7 @@
"description": "The true bid price of the order in parts per billion."
},
"chan_type": {
"type": "integer",
"format": "int64",
"$ref": "#/definitions/poolrpcOrderChannelType",
"description": "The channel type to be created."
}
}
@ -1203,8 +1202,7 @@
"description": "The true bid price of the order in parts per billion."
},
"chan_type": {
"type": "integer",
"format": "int64",
"$ref": "#/definitions/poolrpcOrderChannelType",
"description": "The channel type to be created."
}
}
@ -1983,9 +1981,23 @@
"type": "integer",
"format": "int64",
"description": "The minimum number of order units that must be matched per order pair."
},
"channel_type": {
"$ref": "#/definitions/poolrpcOrderChannelType",
"description": "The channel type to use for the resulting matched channels."
}
}
},
"poolrpcOrderChannelType": {
"type": "string",
"enum": [
"ORDER_CHANNEL_TYPE_UNKNOWN",
"ORDER_CHANNEL_TYPE_PEER_DEPENDENT",
"ORDER_CHANNEL_TYPE_SCRIPT_ENFORCED"
],
"default": "ORDER_CHANNEL_TYPE_UNKNOWN",
"description": " - ORDER_CHANNEL_TYPE_UNKNOWN: Used to set defaults when a trader doesn't specify a channel type.\n - ORDER_CHANNEL_TYPE_PEER_DEPENDENT: The channel type will vary per matched channel based on the features shared\nbetween its participants.\n - ORDER_CHANNEL_TYPE_SCRIPT_ENFORCED: A channel type that builds upon the anchors commitment format to enforce\nchannel lease maturities in the commitment and HTLC outputs that pay to the\nchannel initiator/seller."
},
"poolrpcOrderEvent": {
"type": "object",
"properties": {