FIXME: do proper error handling for BOLT12 */
| 199 | |
| 200 | /* FIXME: do proper error handling for BOLT12 */ |
| 201 | static struct command_result *handle_failure(struct routefail *r) |
| 202 | { |
| 203 | /* BOLT #4: |
| 204 | * |
| 205 | * A _forwarding node_ MAY, but a _final node_ MUST NOT: |
| 206 | *... |
| 207 | * - return an `invalid_onion_version` error. |
| 208 | *... |
| 209 | * - return an `invalid_onion_hmac` error. |
| 210 | *... |
| 211 | * - return an `invalid_onion_key` error. |
| 212 | *... |
| 213 | * - return a `temporary_channel_failure` error. |
| 214 | *... |
| 215 | * - return a `permanent_channel_failure` error. |
| 216 | *... |
| 217 | * - return a `required_channel_feature_missing` error. |
| 218 | *... |
| 219 | * - return an `unknown_next_peer` error. |
| 220 | *... |
| 221 | * - return an `amount_below_minimum` error. |
| 222 | *... |
| 223 | * - return a `fee_insufficient` error. |
| 224 | *... |
| 225 | * - return an `incorrect_cltv_expiry` error. |
| 226 | *... |
| 227 | * - return an `expiry_too_soon` error. |
| 228 | *... |
| 229 | * - return an `expiry_too_far` error. |
| 230 | *... |
| 231 | * - return a `channel_disabled` error. |
| 232 | */ |
| 233 | /* BOLT #4: |
| 234 | * |
| 235 | * An _intermediate hop_ MUST NOT, but the _final node_: |
| 236 | *... |
| 237 | * - MUST return an `incorrect_or_unknown_payment_details` error. |
| 238 | *... |
| 239 | * - MUST return `final_incorrect_cltv_expiry` error. |
| 240 | *... |
| 241 | * - MUST return a `final_incorrect_htlc_amount` error. |
| 242 | */ |
| 243 | assert(r); |
| 244 | struct route *route = r->route; |
| 245 | assert(route); |
| 246 | struct payment_result *result = route->result; |
| 247 | assert(result); |
| 248 | struct payment *payment = r->payment; |
| 249 | assert(payment); |
| 250 | |
| 251 | int path_len = 0; |
| 252 | if (route->hops) |
| 253 | path_len = tal_count(route->hops); |
| 254 | |
| 255 | enum onion_wire failcode; |
| 256 | if(result->failcode) |
| 257 | failcode = *result->failcode; |
| 258 | else{ |
no test coverage detected