mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-15 20:09:18 +01:00
plugin: Add reserve
to openchannel
hook result
Changelog-Added: plugin: The `openchannel` hook may return a custom absolute `reserve` value that the peer must not dip below.
This commit is contained in:
parent
5c1de8029a
commit
9a97f8c154
2 changed files with 28 additions and 1 deletions
|
@ -1198,13 +1198,29 @@ e.g.
|
|||
{
|
||||
"result": "continue",
|
||||
"close_to": "bc1qlq8srqnz64wgklmqvurv7qnr4rvtq2u96hhfg2"
|
||||
"mindepth": 0,
|
||||
"reserve": "1234sat"
|
||||
}
|
||||
```
|
||||
|
||||
Note that `close_to` must be a valid address for the current chain,
|
||||
an invalid address will cause the node to exit with an error.
|
||||
|
||||
Note that `openchannel` is a chained hook. Therefore `close_to` will only be
|
||||
- `mindepth` is the number of confirmations to require before making
|
||||
the channel usable. Notice that setting this to 0 (`zeroconf`) or
|
||||
some other low value might expose you to double-spending issues, so
|
||||
only lower this value from the default if you trust the peer not to
|
||||
double-spend, or you reject incoming payments, including forwards,
|
||||
until the funding is confirmed.
|
||||
|
||||
- `reserve` is an absolute value for the amount in the channel that
|
||||
the peer must keep on their side. This ensures that they always
|
||||
have something to lose, so only lower this below the 1% of funding
|
||||
amount if you trust the peer. The protocol requires this to be
|
||||
larger than the dust limit, hence it will be adjusted to be the
|
||||
dust limit if the specified value is below.
|
||||
|
||||
Note that `openchannel` is a chained hook. Therefore `close_to`, `reserve` will only be
|
||||
evaluated for the first plugin that sets it. If more than one plugin tries to
|
||||
set a `close_to` address an error will be logged.
|
||||
|
||||
|
|
|
@ -732,6 +732,7 @@ openchannel_hook_deserialize(struct openchannel_hook_payload *payload,
|
|||
const jsmntok_t *t_errmsg = json_get_member(buffer, toks, "error_message");
|
||||
const jsmntok_t *t_closeto = json_get_member(buffer, toks, "close_to");
|
||||
const jsmntok_t *t_mindepth = json_get_member(buffer, toks, "mindepth");
|
||||
const jsmntok_t *t_reserve = json_get_member(buffer, toks, "reserve");
|
||||
|
||||
if (!t_result)
|
||||
fatal("Plugin returned an invalid response to the"
|
||||
|
@ -793,6 +794,16 @@ openchannel_hook_deserialize(struct openchannel_hook_payload *payload,
|
|||
payload->uc->minimum_depth);
|
||||
}
|
||||
|
||||
if (t_reserve != NULL) {
|
||||
payload->uc->reserve = tal(payload->uc, struct amount_sat);
|
||||
json_to_sat(buffer, t_reserve, payload->uc->reserve);
|
||||
log_debug(openingd->ld->log,
|
||||
"Setting reserve=%s for this channel as requested by "
|
||||
"the openchannel hook",
|
||||
type_to_string(tmpctx, struct amount_sat,
|
||||
payload->uc->reserve));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue