| 1231 | } |
| 1232 | |
| 1233 | static 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 | |
| 1264 | static struct command_result *handle_wetrun(struct command *cmd, |
| 1265 | struct splice_cmd *splice_cmd) |
no test coverage detected