mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
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:
@@ -2050,7 +2050,6 @@ static void accepter_start(struct state *state, const u8 *oc2_msg)
|
|||||||
|
|
||||||
/* This is an `option_will_fund` request */
|
/* This is an `option_will_fund` request */
|
||||||
if (open_tlv->request_funds) {
|
if (open_tlv->request_funds) {
|
||||||
/* FIXME: Do we support this? */
|
|
||||||
requested_amt
|
requested_amt
|
||||||
= amount_sat(open_tlv->request_funds->requested_sats);
|
= amount_sat(open_tlv->request_funds->requested_sats);
|
||||||
tx_state->blockheight
|
tx_state->blockheight
|
||||||
|
|||||||
@@ -577,6 +577,19 @@ json_openchannel2_call(struct command *cmd,
|
|||||||
return command_hook_success(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 */
|
/* Check that their block height isn't too far behind */
|
||||||
if (!amount_sat_zero(info->requested_lease)) {
|
if (!amount_sat_zero(info->requested_lease)) {
|
||||||
u32 upper_bound, lower_bound;
|
u32 upper_bound, lower_bound;
|
||||||
|
|||||||
@@ -26,10 +26,8 @@ def test_queryrates(node_factory, bitcoind):
|
|||||||
l2.fundwallet(amount * 10)
|
l2.fundwallet(amount * 10)
|
||||||
|
|
||||||
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
|
||||||
result = l1.rpc.queryrates(l2.info['id'], amount, amount * 10)
|
with pytest.raises(RpcError, match=r'not advertising liquidity'):
|
||||||
assert result['our_funding_msat'] == Millisatoshi(amount * 1000)
|
l1.rpc.queryrates(l2.info['id'], amount, amount * 10)
|
||||||
assert result['their_funding_msat'] == Millisatoshi(0)
|
|
||||||
assert 'weight_charge' not in result
|
|
||||||
|
|
||||||
l2.rpc.call('funderupdate', {'policy': 'match',
|
l2.rpc.call('funderupdate', {'policy': 'match',
|
||||||
'policy_mod': 100,
|
'policy_mod': 100,
|
||||||
|
|||||||
Reference in New Issue
Block a user