Reserve these UTXOs and print to JSON */
| 49 | |
| 50 | /* Reserve these UTXOs and print to JSON */ |
| 51 | static void reserve_and_report(struct json_stream *response, |
| 52 | struct wallet *wallet, |
| 53 | u32 current_height, |
| 54 | u32 reserve, |
| 55 | struct utxo **utxos) |
| 56 | { |
| 57 | json_array_start(response, "reservations"); |
| 58 | for (size_t i = 0; i < tal_count(utxos); i++) { |
| 59 | enum output_status oldstatus; |
| 60 | u32 old_res; |
| 61 | |
| 62 | oldstatus = utxos[i]->status; |
| 63 | old_res = utxos[i]->reserved_til; |
| 64 | |
| 65 | if (!wallet_reserve_utxo(wallet, |
| 66 | utxos[i], |
| 67 | current_height, |
| 68 | reserve)) { |
| 69 | fatal("Unable to reserve %s!", |
| 70 | type_to_string(tmpctx, |
| 71 | struct bitcoin_outpoint, |
| 72 | &utxos[i]->outpoint)); |
| 73 | } |
| 74 | json_add_reservestatus(response, utxos[i], oldstatus, old_res, |
| 75 | current_height); |
| 76 | } |
| 77 | json_array_end(response); |
| 78 | } |
| 79 | |
| 80 | static struct command_result *json_reserveinputs(struct command *cmd, |
| 81 | const char *buffer, |
no test coverage detected