Common point for txprepare and withdraw */
| 347 | |
| 348 | /* Common point for txprepare and withdraw */ |
| 349 | static struct command_result *txprepare_continue(struct command *cmd, |
| 350 | struct txprepare *txp, |
| 351 | const char *feerate, |
| 352 | unsigned int *minconf, |
| 353 | struct bitcoin_outpoint *utxos, |
| 354 | bool is_withdraw) |
| 355 | { |
| 356 | struct out_req *req; |
| 357 | |
| 358 | txp->is_withdraw = is_withdraw; |
| 359 | |
| 360 | /* p_opt_def doesn't compile with strings... */ |
| 361 | if (!feerate) |
| 362 | feerate = "opening"; |
| 363 | |
| 364 | /* These calls are deliberately very similar, but utxopsbt wants utxos, |
| 365 | * and fundpsbt wants minconf */ |
| 366 | if (utxos) { |
| 367 | req = jsonrpc_request_start(cmd->plugin, cmd, "utxopsbt", |
| 368 | psbt_created, forward_error, |
| 369 | txp); |
| 370 | json_array_start(req->js, "utxos"); |
| 371 | for (size_t i = 0; i < tal_count(utxos); i++) { |
| 372 | json_add_outpoint(req->js, NULL, &utxos[i]); |
| 373 | } |
| 374 | json_array_end(req->js); |
| 375 | } else { |
| 376 | req = jsonrpc_request_start(cmd->plugin, cmd, "fundpsbt", |
| 377 | psbt_created, forward_error, |
| 378 | txp); |
| 379 | json_add_u32(req->js, "minconf", *minconf); |
| 380 | } |
| 381 | |
| 382 | if (txp->all_output_idx == -1) |
| 383 | json_add_sats(req->js, "satoshi", txp->output_total); |
| 384 | else |
| 385 | json_add_string(req->js, "satoshi", "all"); |
| 386 | |
| 387 | json_add_u32(req->js, "startweight", txp->weight); |
| 388 | |
| 389 | json_add_string(req->js, "feerate", feerate); |
| 390 | return send_outreq(cmd->plugin, req); |
| 391 | } |
| 392 | |
| 393 | static struct command_result *json_txprepare(struct command *cmd, |
| 394 | const char *buffer, |
no test coverage detected