|
8 | 8 | #include <common/json_command.h>
|
9 | 9 | #include <common/json_param.h>
|
10 | 10 | #include <common/key_derive.h>
|
| 11 | +#include <common/psbt_open.h> |
11 | 12 | #include <common/type_to_string.h>
|
12 | 13 | #include <lightningd/chaintopology.h>
|
13 | 14 | #include <lightningd/channel.h>
|
@@ -677,13 +678,18 @@ static struct command_result *json_addpsbtoutput(struct command *cmd,
|
677 | 678 | struct pubkey pubkey;
|
678 | 679 | s64 keyidx;
|
679 | 680 | const u8 *b32script;
|
| 681 | + bool *add_initiator_serial_ids; |
| 682 | + struct wally_psbt_output *output; |
| 683 | + u64 serial_id; |
680 | 684 |
|
681 | 685 | if (!param_check(cmd, buffer, params,
|
682 | 686 | p_req("satoshi", param_sat, &amount),
|
683 | 687 | p_opt("initialpsbt", param_psbt, &psbt),
|
684 | 688 | p_opt("locktime", param_number, &locktime),
|
685 | 689 | p_opt("destination", param_bitcoin_address,
|
686 | 690 | &b32script),
|
| 691 | + p_opt_def("add_initiator_serial_ids", param_bool, |
| 692 | + &add_initiator_serial_ids, false), |
687 | 693 | NULL))
|
688 | 694 | return command_param_failed();
|
689 | 695 |
|
@@ -737,7 +743,13 @@ static struct command_result *json_addpsbtoutput(struct command *cmd,
|
737 | 743 | }
|
738 | 744 |
|
739 | 745 | outnum = psbt->num_outputs;
|
740 |
| - psbt_append_output(psbt, b32script, *amount); |
| 746 | + output = psbt_append_output(psbt, b32script, *amount); |
| 747 | + |
| 748 | + if (*add_initiator_serial_ids) { |
| 749 | + serial_id = psbt_new_output_serial(psbt, TX_INITIATOR); |
| 750 | + psbt_output_set_serial_id(psbt, output, serial_id); |
| 751 | + } |
| 752 | + |
741 | 753 | /* Add additional weight of output */
|
742 | 754 | weight = bitcoin_tx_output_weight(
|
743 | 755 | chainparams->is_elements ? BITCOIN_SCRIPTPUBKEY_P2WPKH_LEN : BITCOIN_SCRIPTPUBKEY_P2TR_LEN);
|
|
0 commit comments