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

Function expand_multichans

common/splice_script.c:1927–2021  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1925}
1926
1927static struct splice_script_error *expand_multichans(const tal_t *ctx,
1928 struct token ***tokens_inout)
1929{
1930 struct token **input = *tokens_inout;
1931 struct token **tokens = tal_arr(ctx, struct token *, 0);
1932 struct token *token_itr;
1933 struct token *token;
1934 size_t chan_count;
1935
1936 for (size_t i = 0; i < tal_count(input); i++) {
1937 switch(input[i]->type) {
1938 case TOK_CHAR:
1939 case TOK_ATSYM:
1940 case TOK_PLUS:
1941 case TOK_MINUS:
1942 case TOK_COLON:
1943 case TOK_LEASERATE:
1944 case TOK_ARROW:
1945 case TOK_PIPE:
1946 case TOK_STR:
1947 case TOK_SATS:
1948 case TOK_PERCENT:
1949 case TOK_QUESTION:
1950 case TOK_WILDCARD:
1951 case TOK_FEE:
1952 case TOK_CHANID:
1953 case TOK_WALLET:
1954 case TOK_FEERATE:
1955 case TOK_NODEID:
1956 case TOK_BTCADDR:
1957 case TOK_CHANQUERY:
1958 case TOK_MULTI_CHANID:
1959 case TOK_LEASEREQ:
1960 case TOK_DELIMITER:
1961 return new_error(ctx, INVALID_TOKEN, input[i],
1962 "expand_multichans");
1963 case TOK_SEGMENT:
1964 if (input[i]->middle->type == TOK_MULTI_CHANID) {
1965 token_itr = input[i]->middle->right;
1966 /* First we count how many chan_ids */
1967 chan_count = 0;
1968 while (token_itr) {
1969 chan_count++;
1970 token_itr = token_itr->right;
1971 }
1972 /* Now we loop through each chan_id */
1973 token_itr = input[i]->middle->right;
1974 while (token_itr) {
1975 /* Duplicate the SEGMENT token */
1976 token = tal_dup(tokens, struct token,
1977 input[i]);
1978 token->left = tal_dup(token,
1979 struct token,
1980 token->left);
1981 token->right = tal_dup(token,
1982 struct token,
1983 token->right);
1984 /* token_itr is already a CHANID */

Callers 1

parse_splice_scriptFunction · 0.85

Calls 3

new_errorFunction · 0.85
steal_sub_tokensFunction · 0.85
tal_freeFunction · 0.85

Tested by

no test coverage detected