core-lightning/doc/schemas/lightning-feerates.json
2024-04-04 13:16:27 +10:30

491 lines
16 KiB
JSON

{
"$schema": "../rpc-schema-draft.json",
"type": "object",
"additionalProperties": false,
"rpc": "feerates",
"title": "Command for querying recommended onchain feerates",
"description": [
"The **feerates** command returns the feerates that CLN will use. The feerates will be based on the recommended feerates from the backend. The backend may fail to provide estimates, but if it was able to provide estimates in the past, CLN will continue to use those for a while. CLN will also smoothen feerate estimations from the backend.",
"",
"Explorers often present fees in \"sat/vB\": 4 sat/vB is `4000perkb` or `1000perkw`.",
"",
"Bitcoin transactions have non-witness and witness bytes:",
"",
"* Non-witness bytes count as 4 weight, 1 virtual byte. All bytes other than SegWit witness count as non-witness bytes. * Witness bytes count as 1 weight, 0.25 virtual bytes.",
"",
"Thus, all *perkb* feerates will be exactly 4 times *perkw* feerates.",
"",
"To compute the fee for a transaction, multiply its weight or virtual bytes by the appropriate *perkw* or *perkw* feerate returned by this command, then divide by 1000.",
"",
"There is currently no way to change these feerates from the RPC. If you need custom control over onchain feerates, you will need to provide your own plugin that replaces the `bcli` plugin backend. For commands like lightning-withdraw(7) or lightning-fundchannel(7) you can provide a preferred feerate directly as a parameter, which will override the recommended feerates returned by **feerates**."
],
"request": {
"required": [
"style"
],
"properties": {
"style": {
"type": "string",
"description": [
"Fee rate style to use. This can be:",
" *perkw* - provide feerate in units of satoshis per 1000 weight (e.g. the minimum fee is usually `253perkw`).",
" *perkb* - provide feerate in units of satoshis per 1000 virtual bytes (eg. the minimum fee is usually `1000perkb`)."
],
"enum": [
"perkb",
"perkw"
]
}
}
},
"response": {
"required": [],
"properties": {
"warning_missing_feerates": {
"type": "string",
"description": [
"Some fee estimates are missing."
]
},
"perkb": {
"type": "object",
"description": [
"If *style* parameter was perkb."
],
"additionalProperties": false,
"required": [
"min_acceptable",
"max_acceptable",
"floor",
"estimates"
],
"properties": {
"min_acceptable": {
"type": "u32",
"description": [
"The smallest feerate that we allow peers to specify: half the 100-block estimate."
]
},
"max_acceptable": {
"type": "u32",
"description": [
"The largest feerate we will accept from remote negotiations. If a peer attempts to set the feerate higher than this we will unilaterally close the channel (or simply forget it if it's not open yet)."
]
},
"floor": {
"type": "u32",
"added": "v23.05",
"description": [
"The smallest feerate that our backend tells us it will accept (i.e. minrelayfee or mempoolminfee)."
]
},
"estimates": {
"type": "array",
"added": "v23.05",
"description": [
"Feerate estimates from plugin which we are using (usuallly bcli)."
],
"items": {
"type": "object",
"additionalProperties": false,
"required": [
"blockcount",
"feerate",
"smoothed_feerate"
],
"properties": {
"blockcount": {
"type": "u32",
"added": "v23.05",
"description": [
"The number of blocks the feerate is expected to get a transaction in."
]
},
"feerate": {
"type": "u32",
"added": "v23.05",
"description": [
"The feerate for this estimate, in given *style*."
]
},
"smoothed_feerate": {
"type": "u32",
"added": "v23.05",
"description": [
"The feerate, smoothed over time (useful for coordinating with other nodes)."
]
}
}
}
},
"opening": {
"type": "u32",
"description": [
"Default feerate for lightning-fundchannel(7) and lightning-withdraw(7)."
]
},
"mutual_close": {
"type": "u32",
"description": [
"Feerate to aim for in cooperative shutdown. Note that since mutual close is a **negotiation**, the actual feerate used in mutual close will be somewhere between this and the corresponding mutual close feerate of the peer."
]
},
"unilateral_close": {
"type": "u32",
"description": [
"Feerate for commitment_transaction in a live channel which we originally funded."
]
},
"unilateral_anchor_close": {
"type": "u32",
"added": "v23.08",
"description": [
"Feerate for commitment_transaction in a live channel which we originally funded (if anchor_outputs was negotiated)."
]
},
"delayed_to_us": {
"type": "u32",
"deprecated": [
"v23.05",
"v24.05"
],
"description": [
"Feerate for returning unilateral close funds to our wallet."
]
},
"htlc_resolution": {
"type": "u32",
"deprecated": [
"v23.05",
"v24.05"
],
"description": [
"Feerate for returning unilateral close HTLC outputs to our wallet."
]
},
"penalty": {
"type": "u32",
"description": [
"Feerate to use when creating penalty tx for watchtowers."
]
}
}
},
"perkw": {
"type": "object",
"description": [
"If *style* parameter was perkw."
],
"additionalProperties": false,
"required": [
"min_acceptable",
"max_acceptable",
"floor",
"estimates"
],
"properties": {
"min_acceptable": {
"type": "u32",
"description": [
"The smallest feerate that you can use, usually the minimum relayed feerate of the backend."
]
},
"max_acceptable": {
"type": "u32",
"description": [
"The largest feerate we will accept from remote negotiations. If a peer attempts to set the feerate higher than this we will unilaterally close the channel (or simply forget it if it's not open yet)."
]
},
"floor": {
"type": "u32",
"added": "v23.05",
"description": [
"The smallest feerate that our backend tells us it will accept (i.e. minrelayfee or mempoolminfee)."
]
},
"estimates": {
"type": "array",
"added": "v23.05",
"description": [
"Feerate estimates from plugin which we are using (usuallly bcli)."
],
"items": {
"type": "object",
"additionalProperties": false,
"required": [
"blockcount",
"feerate",
"smoothed_feerate"
],
"properties": {
"blockcount": {
"type": "u32",
"added": "v23.05",
"description": [
"The number of blocks the feerate is expected to get a transaction in."
]
},
"feerate": {
"type": "u32",
"added": "v23.05",
"description": [
"The feerate for this estimate, in given *style*."
]
},
"smoothed_feerate": {
"type": "u32",
"added": "v23.05",
"description": [
"The feerate, smoothed over time (useful for coordinating with other nodes)."
]
}
}
}
},
"opening": {
"type": "u32",
"description": [
"Default feerate for lightning-fundchannel(7) and lightning-withdraw(7)."
]
},
"mutual_close": {
"type": "u32",
"description": [
"Feerate to aim for in cooperative shutdown. Note that since mutual close is a **negotiation**, the actual feerate used in mutual close will be somewhere between this and the corresponding mutual close feerate of the peer."
]
},
"unilateral_close": {
"type": "u32",
"description": [
"Feerate for commitment_transaction in a live channel which we originally funded (if anchor_outputs was not negotiated)."
]
},
"unilateral_anchor_close": {
"type": "u32",
"added": "v23.08",
"description": [
"Feerate for commitment_transaction in a live channel which we originally funded (if anchor_outputs was negotiated)."
]
},
"delayed_to_us": {
"type": "u32",
"deprecated": [
"v23.05",
"v24.05"
],
"description": [
"Feerate for returning unilateral close funds to our wallet."
]
},
"htlc_resolution": {
"type": "u32",
"deprecated": [
"v23.05",
"v24.05"
],
"description": [
"Feerate for returning unilateral close HTLC outputs to our wallet."
]
},
"penalty": {
"type": "u32",
"description": [
"Feerate to use when creating penalty tx for watchtowers."
]
}
}
},
"onchain_fee_estimates": {
"type": "object",
"additionalProperties": false,
"required": [
"opening_channel_satoshis",
"mutual_close_satoshis",
"unilateral_close_satoshis",
"htlc_timeout_satoshis",
"htlc_success_satoshis"
],
"properties": {
"opening_channel_satoshis": {
"type": "u64",
"description": [
"Estimated cost of typical channel open."
]
},
"mutual_close_satoshis": {
"type": "u64",
"description": [
"Estimated cost of typical channel close."
]
},
"unilateral_close_satoshis": {
"type": "u64",
"description": [
"Estimated cost of typical unilateral close (without HTLCs). If anchors are supported, this assumes a channel with anchors."
]
},
"unilateral_close_nonanchor_satoshis": {
"added": "v23.08",
"type": "u64",
"description": [
"Estimated cost of non-anchor typical unilateral close (without HTLCs)."
]
},
"htlc_timeout_satoshis": {
"type": "u64",
"description": [
"Estimated cost of typical HTLC timeout transaction (non-anchors)."
]
},
"htlc_success_satoshis": {
"type": "u64",
"description": [
"Estimated cost of typical HTLC fulfillment transaction (non-anchors)."
]
}
}
}
}
},
"errors": [
"The **feerates** command will never error, however some fields may be missing in the result if feerate estimates for that kind of transaction are unavailable."
],
"notes": [
"Many other commands have a *feerate* parameter. This can be:",
"",
"* One of the strings to use lightningd's internal estimates:",
" * *urgent* (next 6 blocks or so)",
" * *normal* (next 12 blocks or so)",
" * *slow* (next 100 blocks or so)",
" * *minimum* for the lowest value bitcoind will currently accept (added in v23.05)",
"",
"* A number, with an optional suffix:",
" * *blocks* means aim for confirmation in that many blocks (added in v23.05)",
" * *perkw* means the number is interpreted as satoshi-per-kilosipa (weight)",
" * *perkb* means it is interpreted bitcoind-style as satoshi-per-kilobyte. ",
"",
"Omitting the suffix is equivalent to *perkb*."
],
"trivia": [
"In C-lightning we like to call the weight unit \"sipa\" in honor of Pieter Wuille, who uses the name \"sipa\" on IRC and elsewhere. Internally we call the *perkw* style as \"feerate per kilosipa\"."
],
"json_example": [
{
"request": {
"id": "example:feerates#1",
"method": "feerates",
"params": {
"style": "perkw",
"urgent": null,
"normal": null,
"slow": null
}
},
"response": {
"perkw": {
"opening": 1000000,
"mutual_close": 26362,
"unilateral_close": 26362,
"unilateral_anchor_close": 1000000,
"penalty": 26362,
"min_acceptable": 3750,
"max_acceptable": 10000000,
"floor": 253,
"estimates": [
{
"blockcount": 2,
"feerate": 1000000,
"smoothed_feerate": 26362
},
{
"blockcount": 6,
"feerate": 1000000,
"smoothed_feerate": 26362
},
{
"blockcount": 12,
"feerate": 1000000,
"smoothed_feerate": 26362
},
{
"blockcount": 100,
"feerate": 1000000,
"smoothed_feerate": 26362
}
]
},
"onchain_fee_estimates": {
"opening_channel_satoshis": 702000,
"mutual_close_satoshis": 17741,
"unilateral_close_satoshis": 1112000,
"unilateral_close_nonanchor_satoshis": 15764,
"htlc_timeout_satoshis": 17478,
"htlc_success_satoshis": 18532
}
}
},
{
"request": {
"id": "example:feerates#2",
"method": "feerates",
"params": {
"style": "perkb",
"urgent": null,
"normal": null,
"slow": null
}
},
"response": {
"perkb": {
"opening": 25000,
"mutual_close": 25000,
"unilateral_close": 44000,
"unilateral_anchor_close": 25000,
"penalty": 25000,
"min_acceptable": 12500,
"max_acceptable": 600000,
"floor": 1012,
"estimates": [
{
"blockcount": 2,
"feerate": 60000,
"smoothed_feerate": 60000
},
{
"blockcount": 6,
"feerate": 44000,
"smoothed_feerate": 44000
},
{
"blockcount": 12,
"feerate": 25000,
"smoothed_feerate": 25000
}
]
},
"onchain_fee_estimates": {
"opening_channel_satoshis": 4387,
"mutual_close_satoshis": 4206,
"unilateral_close_satoshis": 6578,
"unilateral_close_nonanchor_satoshis": 6578,
"htlc_timeout_satoshis": 7293,
"htlc_success_satoshis": 7733
}
}
}
],
"author": [
"ZmnSCPxj <<ZmnSCPxj@protonmail.com>> wrote the initial version of this manpage."
],
"see_also": [
"lightning-parsefeerate(7)",
"lightning-fundchannel(7)",
"lightning-withdraw(7)",
"lightning-txprepare(7)",
"lightning-fundchannel_start(7)"
],
"resources": [
"Main web site: <https://github.com/ElementsProject/lightning>"
]
}