mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
lightningd: don't allow sending of HTLCs while still syncing.
If we don't know block height, we shouldn't be sending HTLCs. This stops us forwarding HTLCs as well as new payments. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
3eebd0cc20
commit
6195a878f7
@ -449,6 +449,12 @@ enum onion_type send_htlc_out(struct channel *out,
|
||||
return WIRE_TEMPORARY_CHANNEL_FAILURE;
|
||||
}
|
||||
|
||||
if (!topology_synced(out->peer->ld->topology)) {
|
||||
log_info(out->log, "Attempt to send HTLC but still syncing"
|
||||
" with bitcoin network");
|
||||
return WIRE_TEMPORARY_CHANNEL_FAILURE;
|
||||
}
|
||||
|
||||
/* Make peer's daemon own it, catch if it dies. */
|
||||
hout = new_htlc_out(out->owner, out, amount, cltv,
|
||||
payment_hash, onion_routing_packet, in == NULL, in);
|
||||
|
@ -152,10 +152,8 @@ def test_lightningd_still_loading(node_factory, bitcoind, executor):
|
||||
"id": r['id']
|
||||
}
|
||||
|
||||
# Start it once, make sure it gets a second block (thus writes into db)
|
||||
l1 = node_factory.get_node()
|
||||
bitcoind.generate_block(1)
|
||||
sync_blockheight(bitcoind, [l1])
|
||||
# Start it, establish channel.
|
||||
l1, l2 = node_factory.line_graph(2, opts={'may_reconnect': True})
|
||||
l1.stop()
|
||||
|
||||
# Now make sure it's behind.
|
||||
@ -171,9 +169,14 @@ def test_lightningd_still_loading(node_factory, bitcoind, executor):
|
||||
assert 'warning_bitcoind_sync' not in l1.rpc.getinfo()
|
||||
assert 'warning_lightningd_sync' in l1.rpc.getinfo()
|
||||
|
||||
# Payments will fail. FIXME: More informative msg?
|
||||
with pytest.raises(RpcError, match=r'TEMPORARY_CHANNEL_FAILURE'):
|
||||
l1.pay(l2, 1000)
|
||||
|
||||
# Release the mock, and it will recover.
|
||||
mock_release.set()
|
||||
wait_for(lambda: 'warning_lightningd_sync' not in l1.rpc.getinfo())
|
||||
l1.pay(l2, 1000)
|
||||
|
||||
|
||||
def test_ping(node_factory):
|
||||
|
Loading…
Reference in New Issue
Block a user