Skip to content

Commit

Permalink
Boss/Mod/ChannelCreator/Manager.cpp: set {min|max} channel size
Browse files Browse the repository at this point in the history
* Permit modification of ChannelCreator {min|max}_amount

* Change the minimum and maximum channel sizes CLBOSS will try to create
using `clboss-{min|max}-channel-size` flags with lightningd

Signed-off-by: willcl-ark <[email protected]>
  • Loading branch information
willcl-ark committed Aug 26, 2021
1 parent d9681e5 commit 6f7fa6e
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 3 deletions.
65 changes: 62 additions & 3 deletions Boss/Mod/ChannelCreator/Manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#include"Boss/Mod/ChannelCreator/RearrangerBySize.hpp"
#include"Boss/Mod/Rpc.hpp"
#include"Boss/Msg/Init.hpp"
#include"Boss/Msg/ManifestOption.hpp"
#include"Boss/Msg/Manifestation.hpp"
#include"Boss/Msg/Option.hpp"
#include"Boss/Msg/RequestChannelCreation.hpp"
#include"Boss/Msg/SolicitChannelCandidates.hpp"
#include"Boss/concurrent.hpp"
Expand All @@ -26,8 +29,8 @@
namespace {

/* Minimum and maximum channel size. */
auto const min_amount = Ln::Amount::btc(0.005);
auto const max_amount = Ln::Amount::sat(16777215);
auto min_amount = Ln::Amount::btc(0.005);
auto max_amount = Ln::Amount::sat(16777215);
/* If it is difficult to fit the amount among multiple
* proposals, how much should we target leaving until
* next time?
Expand Down Expand Up @@ -68,7 +71,63 @@ Ev::Io<void> report_proposals( S::Bus& bus, char const* prefix
namespace Boss { namespace Mod { namespace ChannelCreator {

void Manager::start() {
bus.subscribe<Msg::Init
Ln::Amount custom_min_amount;
Ln::Amount custom_max_amount;

bus.subscribe<Msg::Manifestation
>([this](Msg::Manifestation const& _) {
return bus.raise(Msg::ManifestOption{
"clboss-min-channel-size",
Msg::OptionType_Int,
Json::Out::direct(min_amount.to_sat()),
"Minimum channel size CLBOSS will create. "
"Set to an integer number of satoshis. "
"default=500000"
});
});

bus.subscribe<Msg::Option
>([this, &custom_min_amount](Msg::Option const& o) {
if (o.name != "clboss-min-channel-size")
return Ev::lift();
custom_min_amount = Ln::Amount::sat((double) o.value);
if (custom_min_amount != min_amount) {
min_amount = custom_min_amount;
return Boss::log( bus, Info
, "ChannelCreator: "
"set min-channel-size: %s."
, std::string(custom_min_amount).c_str()
);
}
return Ev::lift();
});
bus.subscribe<Msg::Manifestation
>([this](Msg::Manifestation const& _) {
return bus.raise(Msg::ManifestOption{
"clboss-max-channel-size",
Msg::OptionType_Int,
Json::Out::direct(min_amount.to_sat()),
"Maximum channel size CLBOSS will create. "
"Set to an integer number of satoshis. "
"default=16777215"
});
});
bus.subscribe<Msg::Option
>([this, &custom_max_amount](Msg::Option const& o) {
if (o.name != "clboss-max-channel-size")
return Ev::lift();
custom_max_amount = Ln::Amount::sat((double) o.value);
if (custom_max_amount != max_amount) {
max_amount = custom_max_amount;
return Boss::log( bus, Info
, "ChannelCreator: "
"set max-channel-size: %s."
, std::string(custom_max_amount).c_str()
);
}
return Ev::lift();
});
bus.subscribe<Msg::Init
>([this](Msg::Init const& init) {
rpc = &init.rpc;
self = init.self_id;
Expand Down
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,3 +329,28 @@ particular channels to particular nodes will not be auto-closed
by CLBOSS (they may still be closed by `lightningd` due to an
HTLC timeout, or by the peer for any reason, or by you; this
just suppresses CLBOSS).

### `--clboss-min-channel-size=<satoshis>`

Pass this option to `lightningd` to configure the minimum
channel size CLBOSS should consider creating.

The amount specified must be an ordinary number, and must be
in satoshis unit, without any trailing units or other strings.

The default is "500000", or 0.005 BTC.

### `--clboss-max-channel-size=<satoshis>`

Pass this option to `lightningd` to configure the maximum
channel size CLBOSS should consider creating.

The amount specified must be an ordinary number, and must be
in satoshis unit, without any trailing units or other strings.

The default is "16777215", or 0.16777215 BTC.

Anything larger than this default is considered a large (or
"wumbo") channel.
Using wumbo-sized channels will require passing `lightningd`
the `--large-channels|--wumbo` option.

0 comments on commit 6f7fa6e

Please sign in to comment.