df: push back psbt to validate iff peer requests confirmed inputs

`openchannel_init` takes a psbt, which we pipe over to dualopend
process.

If the peer requests that they'll only accept confirmed inputs, we need
to go validate those before we continue.

This wires up the harness for this (validation check yet tc)
This commit is contained in:
niftynei
2023-01-10 15:04:54 -06:00
committed by Alex Myers
parent 9f53e3c7f5
commit cea7fe3f05
3 changed files with 56 additions and 0 deletions

View File

@@ -2941,6 +2941,31 @@ static struct command_result *json_openchannel_init(struct command *cmd,
return command_still_pending(cmd);
}
static void handle_validate_inputs(struct subd *dualopend,
const u8 *msg)
{
struct wally_psbt *psbt;
enum tx_role role_to_validate;
if (!fromwire_dualopend_validate_inputs(msg, msg,
&psbt,
&role_to_validate)) {
channel_internal_error(dualopend->channel,
"Bad DUALOPEND_VALIDATE_INPUTS: %s",
tal_hex(msg, msg));
return;
}
/* FIXME: actually validate inputs on psbt */
log_debug(dualopend->ld->log,
"validating psbt for role: %s",
role_to_validate == TX_INITIATOR ?
"initiator" : "accepter");
subd_send_msg(dualopend,
take(towire_dualopend_validate_inputs_reply(NULL)));
}
static void
channel_fail_fallen_behind(struct subd* dualopend, const u8 *msg)
{
@@ -3268,6 +3293,9 @@ static unsigned int dual_opend_msg(struct subd *dualopend,
case WIRE_DUALOPEND_LOCAL_PRIVATE_CHANNEL:
handle_local_private_channel(dualopend, msg);
return 0;
case WIRE_DUALOPEND_VALIDATE_INPUTS:
handle_validate_inputs(dualopend, msg);
return 0;
/* Messages we send */
case WIRE_DUALOPEND_INIT:
case WIRE_DUALOPEND_REINIT:
@@ -3275,6 +3303,7 @@ static unsigned int dual_opend_msg(struct subd *dualopend,
case WIRE_DUALOPEND_RBF_INIT:
case WIRE_DUALOPEND_GOT_OFFER_REPLY:
case WIRE_DUALOPEND_GOT_RBF_OFFER_REPLY:
case WIRE_DUALOPEND_VALIDATE_INPUTS_REPLY:
case WIRE_DUALOPEND_RBF_VALID:
case WIRE_DUALOPEND_VALIDATE_LEASE_REPLY:
case WIRE_DUALOPEND_FAIL: