| 1345 | } |
| 1346 | |
| 1347 | static struct splice_script_error *compress_2nd_operands(const tal_t *ctx, |
| 1348 | struct token ***tokens_inout) |
| 1349 | { |
| 1350 | struct token **input = *tokens_inout; |
| 1351 | struct token **tokens = tal_arr(ctx, struct token *, tal_count(input)); |
| 1352 | size_t n = 0; |
| 1353 | |
| 1354 | for (size_t i = 0; i < tal_count(input); i++) { |
| 1355 | switch(input[i]->type) { |
| 1356 | case TOK_CHAR: |
| 1357 | case TOK_ATSYM: |
| 1358 | case TOK_COLON: |
| 1359 | return new_error(ctx, INVALID_TOKEN, input[i], |
| 1360 | "2nd_operands"); |
| 1361 | case TOK_DELIMITER: |
| 1362 | case TOK_ARROW: |
| 1363 | case TOK_STR: |
| 1364 | case TOK_SATS: |
| 1365 | case TOK_PERCENT: |
| 1366 | case TOK_QUESTION: |
| 1367 | case TOK_WILDCARD: |
| 1368 | case TOK_CHANID: |
| 1369 | case TOK_WALLET: |
| 1370 | case TOK_FEERATE: |
| 1371 | case TOK_NODEID: |
| 1372 | case TOK_BTCADDR: |
| 1373 | case TOK_CHANQUERY: |
| 1374 | case TOK_MULTI_CHANID: |
| 1375 | case TOK_LEASERATE: |
| 1376 | tokens[n++] = tal_steal(tokens, input[i]); |
| 1377 | break; |
| 1378 | case TOK_MINUS: |
| 1379 | case TOK_PLUS: |
| 1380 | if (i + 1 >= tal_count(input) |
| 1381 | || input[i+1]->type != TOK_FEE) |
| 1382 | return new_error(ctx, MISSING_FEESTR, input[i], |
| 1383 | "2nd_operands"); |
| 1384 | |
| 1385 | /* This token is consumed. If negative, add flag to next |
| 1386 | * token */ |
| 1387 | if (input[i]->type == TOK_MINUS) |
| 1388 | input[i+1]->flags |= TOKEN_FLAG_FEERATE_NEGATIVE; |
| 1389 | break; |
| 1390 | case TOK_FEE: |
| 1391 | if (!n) |
| 1392 | return new_error(ctx, INVALID_TOKEN, input[i], |
| 1393 | "2nd_operands"); |
| 1394 | |
| 1395 | /* We put FEE on the middle spot of the amount */ |
| 1396 | tokens[n-1]->middle = tal_steal(tokens[n-1], input[i]); |
| 1397 | break; |
| 1398 | case TOK_PIPE: |
| 1399 | if (!n || i + 1 >= tal_count(input)) |
| 1400 | return new_error(ctx, INVALID_TOKEN, input[i], |
| 1401 | "2nd_operands"); |
| 1402 | input[i]->type = TOK_LEASEREQ; |
| 1403 | input[i]->right = tal_steal(input[i], input[i+1]); |
| 1404 |
no test coverage detected