| 514 | } |
| 515 | |
| 516 | static struct command_result * |
| 517 | mw_after_newaddr(struct command *cmd, |
| 518 | const char *buf, |
| 519 | const jsmntok_t *result, |
| 520 | struct multiwithdraw_command *mw) |
| 521 | { |
| 522 | const jsmntok_t *bech32tok; |
| 523 | const u8 *script; |
| 524 | |
| 525 | bech32tok = json_get_member(buf, result, "bech32"); |
| 526 | if (!bech32tok |
| 527 | || json_to_address_scriptpubkey(mw, chainparams, buf, bech32tok, |
| 528 | &script) != ADDRESS_PARSE_SUCCESS) |
| 529 | plugin_err(mw->cmd->plugin, |
| 530 | "Unexpected result from newaddr: %.*s", |
| 531 | json_tok_full_len(result), |
| 532 | json_tok_full(buf, result)); |
| 533 | |
| 534 | plugin_log(mw->cmd->plugin, LOG_DBG, |
| 535 | "multiwithdraw %"PRIu64": change output: %.*s.", |
| 536 | mw->id, |
| 537 | json_tok_full_len(bech32tok), |
| 538 | json_tok_full(buf, bech32tok)); |
| 539 | |
| 540 | /* Now add the change output. */ |
| 541 | struct multiwithdraw_destination change; |
| 542 | change.script = script; |
| 543 | change.amount = mw->change_amount; |
| 544 | change.all = false; |
| 545 | change.is_to_external = false; |
| 546 | |
| 547 | tal_arr_expand(&mw->outputs, change); |
| 548 | |
| 549 | return mw_load_outputs(mw); |
| 550 | } |
| 551 | |
| 552 | /*----------------------------------------------------------------------------- |
| 553 | PSBT Outputs Creation |
nothing calls this directly
no test coverage detected