Browse Source

onion: Print the extracted channel_update and onionreply to debug

This adds one line with the onion and the channel_update we extract from
it. This in turn allows us to check that the channel_update in the onion is not
type prefixed, and that we patch it correctly before passing it to gossipd.
ppa-0.6.1
Christian Decker 7 years ago
committed by Rusty Russell
parent
commit
d3edfc8028
  1. 4
      CHANGELOG.md
  2. 11
      lightningd/pay.c
  3. 7
      tests/test_lightningd.py

4
CHANGELOG.md

@ -53,6 +53,8 @@ changes.
- Fixed crash when shutting down during opening a channel (#1737)
- Don't lose track of our own output when applying penalty transaction (#1738)
- Protocol: `channel_update` inside error messages now refers to correct channel.
- Stripping type prefix from `channel_update`s that are nested in an onion reply
to be compatible with eclair and lnd (#1730).
### Security
@ -84,7 +86,7 @@ changes.
- JSON API: `getlog` result field `creation_time`. Use `created_at`.
- JSON API: `getpeers` result field `channel_reserve_satoshis`. Use `their_channel_reserve_satoshis`.
- JSON API: `getpeers` result field `to_self_delay`. Use `their_to_self_delay`.
[Unreleased]: https://github.com/ElementsProject/lightning/compare/v0.6...HEAD
[0.6]: https://github.com/ElementsProject/lightning/releases/tag/v0.6

11
lightningd/pay.c

@ -297,7 +297,8 @@ remote_routing_failure(const tal_t *ctx,
bool *p_retry_plausible,
bool *p_report_to_gossipd,
const struct wallet_payment *payment,
const struct onionreply *failure)
const struct onionreply *failure,
struct log *log)
{
enum onion_type failcode = fromwire_peektype(failure->msg);
u8 *channel_update;
@ -318,6 +319,11 @@ remote_routing_failure(const tal_t *ctx,
channel_update
= channel_update_from_onion_error(routing_failure,
failure->msg);
if (channel_update)
log_debug(log, "Extracted channel_update %s from onionreply %s",
tal_hex(tmpctx, channel_update),
tal_hex(tmpctx, failure->msg));
retry_plausible = true;
report_to_gossipd = true;
@ -521,7 +527,8 @@ void payment_failed(struct lightningd *ld, const struct htlc_out *hout,
fail = remote_routing_failure(tmpctx,
&retry_plausible,
&report_to_gossipd,
payment, reply);
payment, reply,
hout->key.channel->log);
}
}

7
tests/test_lightningd.py

@ -4725,6 +4725,13 @@ class LightningDTests(BaseLightningDTests):
self.assertRaisesRegex(RpcError, 'WIRE_TEMPORARY_CHANNEL_FAILURE',
l1.rpc.waitsendpay, inv['payment_hash'])
# Make sure we get an onionreply, without the type prefix of the nested
# channel_update, and it should patch it to include a type prefix. The
# prefix 0x0102 should be in the channel_update, but not in the
# onionreply (negation of 0x0102 in the RE)
l1.daemon.wait_for_log(r'Extracted channel_update 0102.*from onionreply 10070080(?!.*0102)')
# And now monitor for l1 to apply the channel_update we just extracted
l1.daemon.wait_for_log('Received channel_update for channel {}\(.\) now DISABLED was ACTIVE \(from error\)'.format(chanid2))
def test_address(self):

Loading…
Cancel
Save