lightningd: don't log that we're trying to pay if we're not.

Looking through logs I was surprise to see:

```
lightningd-1 2023-10-26T03:42:36.824Z INFO    lightningd: Sending 200000000msat over 1 hops to deliver 200000000msat
```

On a re-payment where we simply returned from sendpay immediately!  Move that log to later.
This commit is contained in:
Rusty Russell 2023-10-28 13:39:15 +10:30
parent f65c3cab75
commit 9ec6ac9922
2 changed files with 32 additions and 3 deletions

View File

@ -1086,6 +1086,16 @@ send_payment_core(struct lightningd *ld,
return command_failed(cmd, data);
}
if (route_channels)
log_info(ld->log, "Sending %s over %zu hops to deliver %s",
fmt_amount_msat(tmpctx, first_hop->amount),
tal_count(route_channels),
fmt_amount_msat(tmpctx, msat));
else
log_info(ld->log, "Sending %s in onion to deliver %s",
fmt_amount_msat(tmpctx, first_hop->amount),
fmt_amount_msat(tmpctx, msat));
failmsg = send_onion(tmpctx, ld, packet, first_hop, msat,
rhash, NULL, partid,
group, channel, &hout);
@ -1206,9 +1216,6 @@ send_payment(struct lightningd *ld,
for (i = 0; i < n_hops; ++i)
channels[i] = route[i].scid;
log_info(ld->log, "Sending %s over %zu hops to deliver %s",
type_to_string(tmpctx, struct amount_msat, &route[0].amount),
n_hops, type_to_string(tmpctx, struct amount_msat, &msat));
packet = create_onionpacket(tmpctx, path, ROUTING_INFO_SIZE, &path_secrets);
return send_payment_core(ld, cmd, rhash, partid, group, &route[0],
msat, total_msat,

View File

@ -691,6 +691,28 @@ def test_sendpay(node_factory):
assert payments[-1]['payment_preimage'] == preimage3
def test_repay(node_factory):
l1, l2 = node_factory.line_graph(2, fundamount=10**6)
amt = 200000000
inv = l2.rpc.invoice(amt, 'testpayment2', 'desc')
routestep = {
'amount_msat': amt,
'id': l2.info['id'],
'delay': 5,
'channel': first_scid(l1, l2)
}
l1.rpc.sendpay([routestep], inv['payment_hash'], payment_secret=inv['payment_secret'])
l1.daemon.wait_for_log("Sending 200000000msat over 1 hops to deliver 200000000msat")
l1.rpc.waitsendpay(inv['payment_hash'])['payment_preimage']
# Re-attempt is instant
assert l1.rpc.sendpay([routestep], inv['payment_hash'], payment_secret=inv['payment_secret'])['status'] == 'complete'
# Don't re-log that we are sending!
assert l1.daemon.is_in_log("Sending 200000000msat over 1 hops to deliver 200000000msat", start=l1.daemon.logsearch_start) is None
@unittest.skipIf(TEST_NETWORK != 'regtest', "The reserve computation is bitcoin specific")
@pytest.mark.parametrize("anchors", [False, True])
def test_sendpay_cant_afford(node_factory, anchors):