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

Function validate_and_clean

common/splice_script.c:2075–2272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2073}
2074
2075static struct splice_script_error *validate_and_clean(const tal_t *ctx,
2076 struct splice_script_chan **channels,
2077 struct token ***tokens_inout)
2078{
2079 struct token **input = *tokens_inout;
2080 struct token **tokens = tal_arr(ctx, struct token *, tal_count(input));
2081 size_t n = 0;
2082 struct channel_id *chan_ids = tal_arr(ctx, struct channel_id, 0);
2083 struct token *lease, *leaserate, *fee, *feerate;
2084 bool pay_fee_found = false;
2085
2086 for (size_t i = 0; i < tal_count(input); i++) {
2087 switch(input[i]->type) {
2088 case TOK_CHAR:
2089 case TOK_ATSYM:
2090 case TOK_PLUS:
2091 case TOK_MINUS:
2092 case TOK_COLON:
2093 case TOK_LEASERATE:
2094 case TOK_ARROW:
2095 case TOK_PIPE:
2096 case TOK_STR:
2097 case TOK_SATS:
2098 case TOK_PERCENT:
2099 case TOK_QUESTION:
2100 case TOK_WILDCARD:
2101 case TOK_FEE:
2102 case TOK_CHANID:
2103 case TOK_WALLET:
2104 case TOK_FEERATE:
2105 case TOK_NODEID:
2106 case TOK_BTCADDR:
2107 case TOK_CHANQUERY:
2108 case TOK_MULTI_CHANID:
2109 case TOK_LEASEREQ:
2110 case TOK_DELIMITER:
2111 return new_error(ctx, INVALID_TOKEN, input[i],
2112 "validate_and_clean");
2113 case TOK_SEGMENT:
2114 if (!is_valid_amount(input[i]->left))
2115 return new_error(ctx, MISSING_AMOUNT_OR_WILD_OP,
2116 input[i]->left,
2117 "validate_and_clean");
2118 if (!is_valid_amount(input[i]->right))
2119 return new_error(ctx, MISSING_AMOUNT_OR_WILD_OP,
2120 input[i]->right,
2121 "validate_and_clean");
2122
2123 /* Process lease & lease rate.
2124 * ex: "0|10M@1% -> chan_id" (lease 10M at 1% fee) */
2125 lease = input[i]->left->right;
2126 leaserate = NULL;
2127 if (lease) {
2128 if (lease->type != TOK_LEASEREQ)
2129 return new_error(ctx, INTERNAL_ERROR,
2130 lease,
2131 "validate_and_clean");
2132 if (lease->right->type != TOK_SATS)

Callers 1

parse_splice_scriptFunction · 0.85

Calls 7

new_errorFunction · 0.85
is_valid_amountFunction · 0.85
amount_sat_is_zeroFunction · 0.85
is_valid_nonzero_amountFunction · 0.85
valid_channel_idFunction · 0.85
is_valid_middleFunction · 0.85
tal_freeFunction · 0.85

Tested by

no test coverage detected