| 1248 | |
| 1249 | |
| 1250 | static struct command_result * |
| 1251 | handle_intermediate_failure(struct command *cmd, |
| 1252 | struct payment *p, |
| 1253 | const struct node_id *errnode, |
| 1254 | const struct route_hop *errchan, |
| 1255 | enum onion_wire failcode) |
| 1256 | { |
| 1257 | struct payment *root = payment_root(p); |
| 1258 | struct amount_msat estimated; |
| 1259 | |
| 1260 | paymod_log(p, LOG_DBG, |
| 1261 | "Intermediate node %s reported %04x (%s) at %s on route %s", |
| 1262 | type_to_string(tmpctx, struct node_id, errnode), |
| 1263 | failcode, onion_wire_name(failcode), |
| 1264 | type_to_string(tmpctx, struct short_channel_id, |
| 1265 | &errchan->scid), |
| 1266 | p->routetxt); |
| 1267 | |
| 1268 | /* We use an exhaustive switch statement here so you get a compile |
| 1269 | * warning when new ones are added, and can think about where they go */ |
| 1270 | switch (failcode) { |
| 1271 | /* BOLT #4: |
| 1272 | * |
| 1273 | * An _intermediate hop_ MUST NOT, but the _final node_: |
| 1274 | *... |
| 1275 | * - MUST return an `incorrect_or_unknown_payment_details` error. |
| 1276 | *... |
| 1277 | * - MUST return `final_incorrect_cltv_expiry` error. |
| 1278 | *... |
| 1279 | * - MUST return a `final_incorrect_htlc_amount` error. |
| 1280 | */ |
| 1281 | case WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS: |
| 1282 | case WIRE_FINAL_INCORRECT_CLTV_EXPIRY: |
| 1283 | case WIRE_FINAL_INCORRECT_HTLC_AMOUNT: |
| 1284 | /* FIXME: Document in BOLT that intermediates must not return this! */ |
| 1285 | case WIRE_MPP_TIMEOUT: |
| 1286 | goto strange_error; |
| 1287 | |
| 1288 | case WIRE_PERMANENT_CHANNEL_FAILURE: |
| 1289 | case WIRE_CHANNEL_DISABLED: |
| 1290 | case WIRE_UNKNOWN_NEXT_PEER: |
| 1291 | case WIRE_REQUIRED_CHANNEL_FEATURE_MISSING: |
| 1292 | /* All of these result in the channel being marked as disabled. */ |
| 1293 | channel_hints_update(root, errchan->scid, |
| 1294 | errchan->direction, false, false, NULL, |
| 1295 | NULL); |
| 1296 | break; |
| 1297 | |
| 1298 | case WIRE_TEMPORARY_CHANNEL_FAILURE: { |
| 1299 | estimated = errchan->amount; |
| 1300 | |
| 1301 | /* Subtract one msat more, since we know that the amount did not |
| 1302 | * work. This allows us to then allow on equality, this is for |
| 1303 | * example necessary for local channels where exact matches |
| 1304 | * should be allowed. */ |
| 1305 | if (!amount_msat_sub(&estimated, estimated, AMOUNT_MSAT(1))) |
| 1306 | abort(); |
| 1307 |
no test coverage detected