MCPcopy Create free account
hub / github.com/ElementsProject/lightning / resolve_channel_ids

Function resolve_channel_ids

common/splice_script.c:1581–1754  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1579}
1580
1581static struct splice_script_error *resolve_channel_ids(const tal_t *ctx,
1582 struct splice_script_chan **channels,
1583 struct token ***tokens_inout)
1584{
1585 struct token **input = *tokens_inout;
1586 struct token **tokens = tal_arr(ctx, struct token *, tal_count(input));
1587 struct node_id *node_id;
1588 struct channel_id *chan_id;
1589 struct channel_id **chan_ids;
1590 struct token *token_itr;
1591 size_t channel_index;
1592 size_t n = 0;
1593
1594 for (size_t i = 0; i < tal_count(input); i++) {
1595 switch(input[i]->type) {
1596 case TOK_CHAR:
1597 case TOK_ATSYM:
1598 case TOK_PLUS:
1599 case TOK_MINUS:
1600 case TOK_COLON:
1601 case TOK_PIPE:
1602 case TOK_STR:
1603 case TOK_FEE:
1604 return new_error(ctx, INVALID_TOKEN, input[i],
1605 "resolve_channel_ids");
1606 case TOK_LEASERATE:
1607 case TOK_ARROW:
1608 case TOK_SATS:
1609 case TOK_PERCENT:
1610 case TOK_QUESTION:
1611 case TOK_WILDCARD:
1612 case TOK_CHANID:
1613 case TOK_WALLET:
1614 case TOK_FEERATE:
1615 case TOK_NODEID:
1616 case TOK_BTCADDR:
1617 case TOK_LEASEREQ:
1618 case TOK_DELIMITER:
1619 tokens[n++] = tal_steal(tokens, input[i]);
1620 break;
1621 case TOK_CHANQUERY:
1622 if (!input[i]->left || !input[i]->right)
1623 return new_error(ctx, INVALID_TOKEN, input[i],
1624 "resolve_channel_ids");
1625
1626 /* If user specifies *:? it is same as ?:? */
1627 if (input[i]->left->type == TOK_WILDCARD
1628 && input[i]->right->type == TOK_QUESTION)
1629 input[i]->left->type = TOK_QUESTION;
1630
1631 /* If user specifies *:# it is same as ?:# */
1632 if (input[i]->left->type == TOK_WILDCARD
1633 && input[i]->right->type == TOK_SATS)
1634 input[i]->left->type = TOK_QUESTION;
1635
1636 if (input[i]->left->type == TOK_QUESTION) {
1637 node_id = first_node_with_unused_chan(ctx,
1638 channels,

Callers 1

parse_splice_scriptFunction · 0.85

Calls 8

new_errorFunction · 0.85
parse_channel_indexFunction · 0.85
chan_for_node_indexFunction · 0.85
tal_freeFunction · 0.85
unused_chans_for_nodeFunction · 0.85
new_tokenFunction · 0.85
unused_chansFunction · 0.85

Tested by

no test coverage detected