Skip to content

Commit

Permalink
v2 opens: don't use p2sh inputs for v2 opens
Browse files Browse the repository at this point in the history
They're not allowed!
  • Loading branch information
niftynei committed Jan 17, 2023
1 parent 1a741b6 commit 0c82054
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
15 changes: 8 additions & 7 deletions plugins/funder.c
Expand Up @@ -586,7 +586,7 @@ listfunds_success(struct command *cmd,
avail_prev_outs = tal_arr(info, struct bitcoin_outpoint *, 0);
json_for_each_arr(i, tok, outputs_tok) {
struct funder_utxo *utxo;
bool is_reserved, is_p2sh;
bool is_reserved;
struct bitcoin_outpoint *prev_out;
char *status;
const char *err;
Expand All @@ -609,15 +609,13 @@ listfunds_success(struct command *cmd,
err, json_tok_full_len(result),
json_tok_full(buf, result));

/* is it a p2sh output? */
/* v2 opens don't support p2sh-wrapped inputs */
if (json_get_member(buf, tok, "redeemscript"))
is_p2sh = true;
else
is_p2sh = false;
continue;

/* The estimated fee per utxo. */
est_fee = amount_tx_fee(info->funding_feerate_perkw,
bitcoin_tx_input_weight(is_p2sh, 110));
bitcoin_tx_input_weight(false, 110));

/* Did we use this utxo on a previous attempt? */
prev_out = previously_reserved(info->prev_outs, &utxo->out);
Expand Down Expand Up @@ -697,12 +695,15 @@ listfunds_success(struct command *cmd,
committed_funds,
avail_utxos);
json_add_bool(req->js, "reservedok", true);
} else
} else {
req = jsonrpc_request_start(cmd->plugin, cmd,
"fundpsbt",
&psbt_funded,
&psbt_fund_failed,
info);

json_add_bool(req->js, "nonwrapped", true);
}
json_add_string(req->js, "satoshi",
type_to_string(tmpctx, struct amount_sat,
&info->our_funding));
Expand Down
3 changes: 3 additions & 0 deletions plugins/spender/multifundchannel.c
Expand Up @@ -1404,6 +1404,9 @@ perform_fundpsbt(struct multifundchannel_command *mfc, u32 feerate)
&mfc_forward_error,
mfc);
json_add_u32(req->js, "minconf", mfc->minconf);
/* If there's any v2 opens, we can't use p2sh inputs */
json_add_bool(req->js, "nonwrapped",
dest_count(mfc, OPEN_CHANNEL) > 0);
}

/* The entire point is to reserve the inputs. */
Expand Down

0 comments on commit 0c82054

Please sign in to comment.