df: wire up peer's "require-confirmed-inputs"

We push this info out to the various RPCs/hooks.
This commit is contained in:
niftynei 2023-01-10 15:03:44 -06:00 committed by Alex Myers
parent f05d450098
commit 9f53e3c7f5
11 changed files with 51 additions and 7 deletions

View file

@ -1257,7 +1257,8 @@ the v2 protocol, and it has passed basic sanity checks:
"channel_max_msat": 16777215000,
"requested_lease_msat": 100000000,
"lease_blockheight_start": 683990,
"node_blockheight": 683990
"node_blockheight": 683990,
"require_confirmed_inputs": false
}
}
```
@ -1389,6 +1390,7 @@ requests an RBF for a channel funding transaction.
"channel_max_msat": 16777215000,
"locktime": 2453,
"requested_lease_msat": 100000000,
"require_confirmed_inputs": false
}
}
```

View file

@ -42,6 +42,7 @@ On success, an object is returned, containing:
- **psbt** (string): the (incomplete) PSBT of the RBF transaction
- **commitments\_secured** (boolean): whether the *psbt* is complete (always *false*)
- **funding\_serial** (u64): the serial\_id of the funding output in the *psbt*
- **requires\_confirmed\_inputs** (boolean, optional): Does peer require confirmed inputs in psbt?
[comment]: # (GENERATE-FROM-SCHEMA-END)
@ -82,4 +83,4 @@ RESOURCES
Main web site: <https://github.com/ElementsProject/lightning>
[comment]: # ( SHA256STAMP:ed3aa14a604515d218f9a15dd02997a055effc5cb38b52a111466fb44ab06198)
[comment]: # ( SHA256STAMP:b70ef93977f0316da57fcecdfe1337f810f391afb00be1d0523dd00e178b19b5)

View file

@ -57,6 +57,7 @@ On success, an object is returned, containing:
- **psbt** (string): the (incomplete) PSBT of the funding transaction
- **commitments\_secured** (boolean): whether the *psbt* is complete (always *false*)
- **funding\_serial** (u64): the serial\_id of the funding output in the *psbt*
- **requires\_confirmed\_inputs** (boolean, optional): Does peer require confirmed inputs in psbt?
[comment]: # (GENERATE-FROM-SCHEMA-END)
@ -104,4 +105,4 @@ RESOURCES
Main web site: <https://github.com/ElementsProject/lightning>
[comment]: # ( SHA256STAMP:d957b5bb745977f93805ddd65943e74acbdc68b01ebd5bb2f13ef2b24463b859)
[comment]: # ( SHA256STAMP:40121e2e7b0db8c99de12b4fd086f58f63e0d6643b9da1c1697a34dd5057454e)

View file

@ -36,6 +36,7 @@ On success, an object is returned, containing:
- **commitments\_secured** (boolean): whether the *psbt* is complete (if true, sign *psbt* and call `openchannel_signed` to complete the channel open)
- **funding\_outnum** (u32): The index of the funding output in the psbt
- **close\_to** (hex, optional): scriptPubkey which we have to close to if we mutual close
- **requires\_confirmed\_inputs** (boolean, optional): Does peer require confirmed inputs in psbt?
[comment]: # (GENERATE-FROM-SCHEMA-END)
@ -73,4 +74,4 @@ RESOURCES
Main web site: <https://github.com/ElementsProject/lightning>
[comment]: # ( SHA256STAMP:11e23b688eb714707cf3203397761454b140a96ab5d7512208013700227aff4c)
[comment]: # ( SHA256STAMP:8916c7600248fc14275508962f9ea09c55d43157f525a4bbe385b621074384e6)

View file

@ -29,6 +29,10 @@
"funding_serial": {
"type": "u64",
"description": "the serial_id of the funding output in the *psbt*"
},
"requires_confirmed_inputs": {
"type": "boolean",
"description": "Does peer require confirmed inputs in psbt?"
}
}
}

View file

@ -29,6 +29,10 @@
"funding_serial": {
"type": "u64",
"description": "the serial_id of the funding output in the *psbt*"
},
"requires_confirmed_inputs": {
"type": "boolean",
"description": "Does peer require confirmed inputs in psbt?"
}
}
}

View file

@ -30,6 +30,10 @@
"close_to": {
"type": "hex",
"description": "scriptPubkey which we have to close to if we mutual close"
},
"requires_confirmed_inputs": {
"type": "boolean",
"description": "Does peer require confirmed inputs in psbt?"
}
}
}

View file

@ -185,6 +185,7 @@ struct rbf_channel_payload {
struct amount_sat our_last_funding;
u32 funding_feerate_per_kw;
u32 locktime;
bool req_confirmed_ins;
/* General info */
u32 feerate_our_max;
@ -228,6 +229,8 @@ static void rbf_channel_hook_serialize(struct rbf_channel_payload *payload,
if (payload->requested_lease_amt)
json_add_amount_sat_msat(stream, "requested_lease_msat",
*payload->requested_lease_amt);
json_add_bool(stream, "require_confirmed_inputs",
payload->req_confirmed_ins);
json_object_end(stream);
}
@ -270,6 +273,7 @@ struct openchannel2_payload {
struct amount_sat *requested_lease_amt;
u32 lease_blockheight_start;
u32 node_blockheight;
bool req_confirmed_ins;
struct amount_sat accepter_funding;
struct wally_psbt *psbt;
@ -319,6 +323,8 @@ static void openchannel2_hook_serialize(struct openchannel2_payload *payload,
json_add_num(stream, "node_blockheight",
payload->node_blockheight);
}
json_add_bool(stream, "require_confirmed_inputs",
payload->req_confirmed_ins);
json_object_end(stream);
}
@ -339,6 +345,8 @@ openchannel2_changed_hook_serialize(struct openchannel2_psbt_payload *payload,
json_add_string(stream, "channel_id",
type_to_string(tmpctx, struct channel_id,
&payload->channel->cid));
json_add_bool(stream, "require_confirmed_inputs",
payload->channel->req_confirmed_ins);
json_object_end(stream);
}
@ -692,6 +700,7 @@ openchannel2_hook_cb(struct openchannel2_payload *payload STEALS)
channel->cid = payload->channel_id;
channel->opener = REMOTE;
channel->open_attempt = new_channel_open_attempt(channel);
channel->req_confirmed_ins = payload->req_confirmed_ins;
msg = towire_dualopend_got_offer_reply(NULL,
payload->accepter_funding,
payload->psbt,
@ -1876,6 +1885,7 @@ static void rbf_got_offer(struct subd *dualopend, const u8 *msg)
payload->peer_id = channel->peer->id;
payload->feerate_our_max = feerate_max(dualopend->ld, NULL);
payload->feerate_our_min = feerate_min(dualopend->ld, NULL);
payload->req_confirmed_ins = channel->req_confirmed_ins;
payload->psbt = NULL;
@ -1930,7 +1940,8 @@ static void accepter_got_offer(struct subd *dualopend,
&payload->locktime,
&payload->shutdown_scriptpubkey,
&payload->requested_lease_amt,
&payload->lease_blockheight_start)) {
&payload->lease_blockheight_start,
&payload->req_confirmed_ins)) {
channel_internal_error(channel, "Bad DUALOPEND_GOT_OFFER: %s",
tal_hex(tmpctx, msg));
return;
@ -2963,6 +2974,7 @@ static void handle_psbt_changed(struct subd *dualopend,
if (!fromwire_dualopend_psbt_changed(tmpctx, msg,
&cid,
&channel->req_confirmed_ins,
&funding_serial,
&psbt)) {
channel_internal_error(channel,
@ -2990,6 +3002,8 @@ static void handle_psbt_changed(struct subd *dualopend,
json_add_psbt(response, "psbt", psbt);
json_add_bool(response, "commitments_secured", false);
json_add_u64(response, "funding_serial", funding_serial);
json_add_bool(response, "requires_confirmed_inputs",
channel->req_confirmed_ins);
oa->cmd = NULL;
was_pending(command_success(cmd, response));

View file

@ -216,6 +216,9 @@ struct state {
/* Amount of leased sats requested, persisted across
* RBF attempts, so we know when we've messed up lol */
struct amount_sat *requested_lease;
/* Does this negotation require confirmed inputs? */
bool require_confirmed_inputs;
};
/* psbt_changeset_get_next - Get next message to send
@ -1133,6 +1136,7 @@ fetch_psbt_changes(struct state *state,
/* Go ask lightningd what other changes we've got */
msg = towire_dualopend_psbt_changed(NULL, &state->channel_id,
state->require_confirmed_inputs,
tx_state->funding_serial,
psbt);
@ -2203,6 +2207,8 @@ static void accepter_start(struct state *state, const u8 *oc2_msg)
open_err_fatal(state, "Parsing open_channel2 %s",
tal_hex(tmpctx, oc2_msg));
state->require_confirmed_inputs = open_tlv->require_confirmed_inputs != NULL;
if (open_tlv->upfront_shutdown_script)
set_remote_upfront_shutdown(state, open_tlv->upfront_shutdown_script);
else
@ -2319,7 +2325,8 @@ static void accepter_start(struct state *state, const u8 *oc2_msg)
tx_state->tx_locktime,
state->upfront_shutdown_script[REMOTE],
state->requested_lease,
tx_state->blockheight);
tx_state->blockheight,
state->require_confirmed_inputs);
wire_sync_write(REQ_FD, take(msg));
msg = wire_sync_read(tmpctx, REQ_FD);
@ -2989,6 +2996,9 @@ static void opener_start(struct state *state, u8 *msg)
}
}
/* Set the require confirms from peer's TLVs */
state->require_confirmed_inputs = a_tlv->require_confirmed_inputs != NULL;
if (a_tlv->upfront_shutdown_script)
set_remote_upfront_shutdown(state, a_tlv->upfront_shutdown_script);
else

View file

@ -89,6 +89,7 @@ msgdata,dualopend_got_offer,shutdown_len,u16,
msgdata,dualopend_got_offer,shutdown_scriptpubkey,u8,shutdown_len
msgdata,dualopend_got_offer,requested_amt,?amount_sat,
msgdata,dualopend_got_offer,lease_blockheight_start,u32,
msgdata,dualopend_got_offer,require_confirmed_inputs,bool,
# master->dualopend: reply back with our first funding info/contribs
msgtype,dualopend_got_offer_reply,7105
@ -164,6 +165,7 @@ msgdata,dualopend_commit_rcvd,channel_type,channel_type,
# dualopend->master: peer updated the psbt
msgtype,dualopend_psbt_changed,7107
msgdata,dualopend_psbt_changed,channel_id,channel_id,
msgdata,dualopend_psbt_changed,requires_confirmed_inputs,bool,
msgdata,dualopend_psbt_changed,funding_serial,u64,
msgdata,dualopend_psbt_changed,psbt,wally_psbt,

Can't render this file because it has a wrong number of fields in line 16.

View file

@ -657,13 +657,14 @@ def test_openchannel_hook(node_factory, bitcoind):
# openchannel2 var checks
expected.update({
'channel_id': '.*',
'channel_max_msat': 16777215000,
'commitment_feerate_per_kw': '7500',
'funding_feerate_per_kw': '7500',
'feerate_our_max': '150000',
'feerate_our_min': '1875',
'locktime': '.*',
'require_confirmed_inputs': False,
'their_funding_msat': 100000000,
'channel_max_msat': 16777215000,
})
else:
expected.update({