channel-lease: reject if we're not currently advertising liquidity

If there's no plugin currently in place, we simply won't return any
funding at all, in which case we'd expect them to handle however
they want. (our implementation would fail the open, as we only accept
opens that have at least as much as we've requested provided)
This commit is contained in:
niftynei 2021-07-06 12:17:51 -05:00 committed by neil saitug
parent d05a2a5aa9
commit 70bf57d54b
3 changed files with 15 additions and 5 deletions

View file

@ -2050,7 +2050,6 @@ static void accepter_start(struct state *state, const u8 *oc2_msg)
/* This is an `option_will_fund` request */
if (open_tlv->request_funds) {
/* FIXME: Do we support this? */
requested_amt
= amount_sat(open_tlv->request_funds->requested_sats);
tx_state->blockheight

View file

@ -577,6 +577,19 @@ json_openchannel2_call(struct command *cmd,
return command_hook_success(cmd);
}
/* If they've requested funds, but we're not actually
* supporting requested funds...*/
if (!current_policy->rates &&
!amount_sat_zero(info->requested_lease)) {
struct json_stream *res = jsonrpc_stream_success(cmd);
json_add_string(res, "result", "reject");
json_add_string(res, "error_message",
"Peer requested funds but we're not advertising"
" liquidity right now");
return command_finished(cmd, res);
}
/* Check that their block height isn't too far behind */
if (!amount_sat_zero(info->requested_lease)) {
u32 upper_bound, lower_bound;

View file

@ -26,10 +26,8 @@ def test_queryrates(node_factory, bitcoind):
l2.fundwallet(amount * 10)
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
result = l1.rpc.queryrates(l2.info['id'], amount, amount * 10)
assert result['our_funding_msat'] == Millisatoshi(amount * 1000)
assert result['their_funding_msat'] == Millisatoshi(0)
assert 'weight_charge' not in result
with pytest.raises(RpcError, match=r'not advertising liquidity'):
l1.rpc.queryrates(l2.info['id'], amount, amount * 10)
l2.rpc.call('funderupdate', {'policy': 'match',
'policy_mod': 100,