mirror of
https://github.com/aljazceru/lightning.git
synced 2026-02-02 12:44:26 +01:00
common/channel_type: add zero-fee-anchor type.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -55,6 +55,17 @@ void channel_type_set_scid_alias(struct channel_type *type)
|
||||
COMPULSORY_FEATURE(OPT_SCID_ALIAS));
|
||||
}
|
||||
|
||||
struct channel_type *channel_type_anchors_zero_fee_htlc(const tal_t *ctx)
|
||||
{
|
||||
struct channel_type *type = channel_type_none(ctx);
|
||||
|
||||
set_feature_bit(&type->features,
|
||||
COMPULSORY_FEATURE(OPT_ANCHORS_ZERO_FEE_HTLC_TX));
|
||||
set_feature_bit(&type->features,
|
||||
COMPULSORY_FEATURE(OPT_STATIC_REMOTEKEY));
|
||||
return type;
|
||||
}
|
||||
|
||||
struct channel_type *default_channel_type(const tal_t *ctx,
|
||||
const struct feature_set *our_features,
|
||||
const u8 *their_features)
|
||||
@@ -64,12 +75,15 @@ struct channel_type *default_channel_type(const tal_t *ctx,
|
||||
* - if `channel_type` was present in both `open_channel` and `accept_channel`:
|
||||
* - This is the `channel_type` (they must be equal, required above)
|
||||
* - otherwise:
|
||||
* - if `option_anchors_zero_fee_htlc_tx` was negotiated:
|
||||
* - the `channel_type` is `option_anchors_zero_fee_htlc_tx` and `option_static_remotekey` (bits 22 and 12)
|
||||
* - otherwise, if `option_anchor_outputs` was negotiated:
|
||||
* - the `channel_type` is `option_anchor_outputs` and
|
||||
* `option_static_remotekey` (bits 20 and 12)
|
||||
*/
|
||||
/* BOLT #2:
|
||||
* - otherwise, if `option_anchor_outputs` was negotiated:
|
||||
* - the `channel_type` is `option_anchor_outputs` and
|
||||
* `option_static_remotekey` (bits 20 and 12)
|
||||
*/
|
||||
if (feature_negotiated(our_features, their_features,
|
||||
OPT_ANCHORS_ZERO_FEE_HTLC_TX))
|
||||
return channel_type_anchors_zero_fee_htlc(ctx);
|
||||
if (feature_negotiated(our_features, their_features,
|
||||
OPT_ANCHOR_OUTPUTS))
|
||||
return channel_type_anchor_outputs(ctx);
|
||||
@@ -137,6 +151,7 @@ struct channel_type *channel_type_accept(const tal_t *ctx,
|
||||
|
||||
static const size_t feats[] = {
|
||||
OPT_ANCHOR_OUTPUTS,
|
||||
OPT_ANCHORS_ZERO_FEE_HTLC_TX,
|
||||
OPT_STATIC_REMOTEKEY,
|
||||
OPT_SCID_ALIAS,
|
||||
OPT_ZEROCONF,
|
||||
@@ -185,6 +200,8 @@ struct channel_type *channel_type_accept(const tal_t *ctx,
|
||||
if (channel_type_eq(&proposed, channel_type_none(tmpctx)) ||
|
||||
channel_type_eq(&proposed,
|
||||
channel_type_static_remotekey(tmpctx)) ||
|
||||
channel_type_eq(&proposed,
|
||||
channel_type_anchors_zero_fee_htlc(tmpctx)) ||
|
||||
channel_type_eq(&proposed, channel_type_anchor_outputs(tmpctx))) {
|
||||
/* At this point we know it matches, and maybe has
|
||||
* a couple of extra options. So let's just reply
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
struct channel_type *channel_type_none(const tal_t *ctx);
|
||||
struct channel_type *channel_type_static_remotekey(const tal_t *ctx);
|
||||
struct channel_type *channel_type_anchor_outputs(const tal_t *ctx);
|
||||
struct channel_type *channel_type_anchors_zero_fee_htlc(const tal_t *ctx);
|
||||
|
||||
/* channel_type variants */
|
||||
void channel_type_set_zeroconf(struct channel_type *channel_type);
|
||||
|
||||
@@ -169,6 +169,10 @@ struct channel_type *channel_upgradable_type(const tal_t *ctx,
|
||||
struct channel_type *channel_desired_type(const tal_t *ctx,
|
||||
const struct channel *channel)
|
||||
{
|
||||
/* We don't actually want to downgrade anchors! */
|
||||
if (channel_has(channel, OPT_ANCHORS_ZERO_FEE_HTLC_TX))
|
||||
return channel_type_anchors_zero_fee_htlc(ctx);
|
||||
|
||||
/* We don't actually want to downgrade anchors! */
|
||||
if (channel_has(channel, OPT_ANCHOR_OUTPUTS))
|
||||
return channel_type_anchor_outputs(ctx);
|
||||
|
||||
@@ -29,7 +29,7 @@ On success, an object containing **channels** is returned. It is an array of ob
|
||||
- **state** (string): the channel state, in particular "CHANNELD\_NORMAL" means the channel can be used normally (one of "OPENINGD", "CHANNELD\_AWAITING\_LOCKIN", "CHANNELD\_NORMAL", "CHANNELD\_SHUTTING\_DOWN", "CLOSINGD\_SIGEXCHANGE", "CLOSINGD\_COMPLETE", "AWAITING\_UNILATERAL", "FUNDING\_SPEND\_SEEN", "ONCHAIN", "DUALOPEND\_OPEN\_INIT", "DUALOPEND\_AWAITING\_LOCKIN")
|
||||
- **opener** (string): Who initiated the channel (one of "local", "remote")
|
||||
- **features** (array of strings):
|
||||
- BOLT #9 features which apply to this channel (one of "option\_static\_remotekey", "option\_anchor\_outputs", "option\_scid\_alias", "option\_zeroconf")
|
||||
- BOLT #9 features which apply to this channel (one of "option\_static\_remotekey", "option\_anchor\_outputs", "option\_anchors\_zero\_fee\_htlc\_tx", "option\_scid\_alias", "option\_zeroconf")
|
||||
- **scratch\_txid** (txid, optional): The txid we would use if we went onchain now
|
||||
- **channel\_type** (object, optional): channel\_type as negotiated with peer *(added v23.05)*:
|
||||
- **bits** (array of u32s): Each bit set in this channel\_type:
|
||||
@@ -194,4 +194,4 @@ Main web site: <https://github.com/ElementsProject/lightning> Lightning
|
||||
RFC site (BOLT \#9):
|
||||
<https://github.com/lightningnetwork/lightning-rfc/blob/master/09-features.md>
|
||||
|
||||
[comment]: # ( SHA256STAMP:005c109a25f91eabf18e2003a4c83e305ca6b4a604999ceeef6ca3f0ee4b0006)
|
||||
[comment]: # ( SHA256STAMP:f5103dae3b20a7d2a4112a368e753f1dd0518a269bd34c2fd17657c9f90596d7)
|
||||
|
||||
@@ -212,6 +212,7 @@
|
||||
"enum": [
|
||||
"option_static_remotekey",
|
||||
"option_anchor_outputs",
|
||||
"option_anchors_zero_fee_htlc_tx",
|
||||
"option_scid_alias",
|
||||
"option_zeroconf"
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user