| 44 | } |
| 45 | |
| 46 | static void add_to_debug_log(struct splice_cmd *scmd, const char *phase) |
| 47 | { |
| 48 | char **log = &scmd->debug_log; |
| 49 | if (!*log) |
| 50 | return; |
| 51 | |
| 52 | tal_append_fmt(log, "#%d: (%s)\n", ++scmd->debug_counter, phase); |
| 53 | |
| 54 | for (size_t i = 0; i < tal_count(scmd->actions); i++) { |
| 55 | struct splice_script_result *action = scmd->actions[i]; |
| 56 | struct splice_cmd_action_state *state = scmd->states[i]; |
| 57 | bool simulate_wallet_amount = false; |
| 58 | bool hide_fee = false; |
| 59 | |
| 60 | if (action->onchain_wallet && action->pays_fee) { |
| 61 | if (amount_sat_is_zero(action->out_sat)) { |
| 62 | simulate_wallet_amount = true; |
| 63 | action->out_sat = scmd->needed_funds; |
| 64 | } else { |
| 65 | hide_fee = true; |
| 66 | action->pays_fee = false; |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | tal_append_fmt(log, "[%s] %s\n", |
| 71 | cmd_state_string(state->state), |
| 72 | splice_to_string(tmpctx, action)); |
| 73 | |
| 74 | if (simulate_wallet_amount) |
| 75 | action->out_sat = AMOUNT_SAT(0); |
| 76 | |
| 77 | if (hide_fee) |
| 78 | action->pays_fee = true; |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | static void debug_log_to_json(struct json_stream *response, |
| 83 | const char *debug_log) |
no test coverage detected