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

Function check_emergency_sat

plugins/spender/splice.c:1233–1262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1231}
1232
1233static struct command_result *check_emergency_sat(struct command *cmd,
1234 struct splice_cmd *splice_cmd)
1235{
1236 struct amount_sat to_wallet = AMOUNT_SAT(0);
1237 if (amount_sat_is_zero(splice_cmd->emergency_sat))
1238 return NULL;
1239
1240 for (size_t i = 0; i < tal_count(splice_cmd->actions); i++) {
1241 struct splice_script_result *action = splice_cmd->actions[i];
1242 if (action->onchain_wallet)
1243 if (!amount_sat_add(&to_wallet, to_wallet,
1244 action->in_sat))
1245 return do_fail(cmd, splice_cmd,
1246 JSONRPC2_INVALID_PARAMS,
1247 "Unable to amount_sat_add"
1248 " wallet amounts for"
1249 " emergency_sat calc");
1250 }
1251
1252 if (!amount_sat_greater_eq(to_wallet, splice_cmd->emergency_sat))
1253 return do_fail(cmd, splice_cmd, JSONRPC2_INVALID_PARAMS,
1254 tal_fmt(tmpctx,
1255 "Amount going to onchain wallet %s is"
1256 " not enough to meet the emergency"
1257 " minimum of %s",
1258 fmt_amount_sat(tmpctx, to_wallet),
1259 fmt_amount_sat(tmpctx, splice_cmd->emergency_sat)));
1260
1261 return NULL;
1262}
1263
1264static struct command_result *handle_wetrun(struct command *cmd,
1265 struct splice_cmd *splice_cmd)

Callers 1

continue_spliceFunction · 0.85

Calls 5

amount_sat_is_zeroFunction · 0.85
do_failFunction · 0.85
amount_sat_addFunction · 0.50
amount_sat_greater_eqFunction · 0.50
fmt_amount_satFunction · 0.50

Tested by

no test coverage detected