| 1293 | } |
| 1294 | |
| 1295 | static struct command_result * |
| 1296 | handle_final_failure(struct command *cmd, |
| 1297 | struct payment *p, |
| 1298 | const struct node_id *final_id, |
| 1299 | enum onion_wire failcode) |
| 1300 | { |
| 1301 | u32 unused; |
| 1302 | |
| 1303 | /* Need to check for blockheight disagreement case here, |
| 1304 | * otherwise we would set the abort flag too eagerly. |
| 1305 | */ |
| 1306 | if (failure_is_blockheight_disagreement(p, &unused)) { |
| 1307 | paymod_log(p, LOG_DBG, |
| 1308 | "Blockheight disagreement, not aborting."); |
| 1309 | goto nonerror; |
| 1310 | } |
| 1311 | |
| 1312 | paymod_log(p, LOG_DBG, |
| 1313 | "Final node %s reported %04x (%s) on route %s", |
| 1314 | fmt_node_id(tmpctx, final_id), |
| 1315 | failcode, onion_wire_name(failcode), |
| 1316 | p->routetxt); |
| 1317 | |
| 1318 | /* We use an exhaustive switch statement here so you get a compile |
| 1319 | * warning when new ones are added, and can think about where they go */ |
| 1320 | switch (failcode) { |
| 1321 | case WIRE_FINAL_INCORRECT_CLTV_EXPIRY: |
| 1322 | report_tampering(p, tal_count(p->route)-1, "cltv"); |
| 1323 | goto error; |
| 1324 | case WIRE_FINAL_INCORRECT_HTLC_AMOUNT: |
| 1325 | report_tampering(p, tal_count(p->route)-1, "amount"); |
| 1326 | goto error; |
| 1327 | |
| 1328 | /* BOLT #4: |
| 1329 | * |
| 1330 | * A _forwarding node_ MAY, but a _final node_ MUST NOT: |
| 1331 | *... |
| 1332 | * - return an `invalid_onion_version` error. |
| 1333 | *... |
| 1334 | * - return an `invalid_onion_hmac` error. |
| 1335 | *... |
| 1336 | * - return an `invalid_onion_key` error. |
| 1337 | *... |
| 1338 | * - return a `temporary_channel_failure` error. |
| 1339 | *... |
| 1340 | * - return a `permanent_channel_failure` error. |
| 1341 | *... |
| 1342 | * - return a `required_channel_feature_missing` error. |
| 1343 | *... |
| 1344 | * - return an `unknown_next_peer` error. |
| 1345 | *... |
| 1346 | * - return an `amount_below_minimum` error. |
| 1347 | *... |
| 1348 | * - return a `fee_insufficient` error. |
| 1349 | *... |
| 1350 | * - return an `incorrect_cltv_expiry` error. |
| 1351 | *... |
| 1352 | * - return an `expiry_too_soon` error. |
no test coverage detected