mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
df-spec: consolidate dual-funding patches, update feerate protocol
We consolidate to the latest/singular RFC patch for dual-funding, so there's just a single patchfile for the change. Plus we move back to the opener setting the desired feerate, the accepter merely declines to participate if they disagree with the set rate.
This commit is contained in:
parent
71164799f9
commit
31e3bdb42d
@ -18,7 +18,7 @@ void derive_channel_id_v2(struct channel_id *channel_id,
|
||||
const struct pubkey *basepoint_1,
|
||||
const struct pubkey *basepoint_2)
|
||||
{
|
||||
/* BOLT-df8bb5994d99e4c78053f7cb57694795f8393dc5 #2:
|
||||
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
* `channel_id`, v2
|
||||
* For channels established using the v2 protocol, the
|
||||
* `channel_id` is the
|
||||
|
@ -67,8 +67,8 @@ psbt_to_witness_stacks(const tal_t *ctx,
|
||||
/* FIXME: throw an error ? */
|
||||
return NULL;
|
||||
|
||||
/* BOLT-78de9a79b491ae9fb84b1fdb4546bacf642dce87 #2:
|
||||
* - if is the `initiator`:
|
||||
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
* - if is the *initiator*:
|
||||
* - MUST send even `serial_id`s
|
||||
*/
|
||||
if (serial_id % 2 == side_to_stack) {
|
||||
|
@ -232,9 +232,7 @@ struct openchannel2_payload {
|
||||
struct amount_sat dust_limit_satoshis;
|
||||
struct amount_msat max_htlc_value_in_flight_msat;
|
||||
struct amount_msat htlc_minimum_msat;
|
||||
u32 funding_feerate_max;
|
||||
u32 funding_feerate_min;
|
||||
u32 funding_feerate_best;
|
||||
u32 funding_feerate_per_kw;
|
||||
u32 feerate_our_max;
|
||||
u32 feerate_our_min;
|
||||
u32 commitment_feerate_per_kw;
|
||||
@ -245,7 +243,6 @@ struct openchannel2_payload {
|
||||
u8 *shutdown_scriptpubkey;
|
||||
|
||||
struct amount_sat accepter_funding;
|
||||
u32 funding_feerate_per_kw;
|
||||
struct wally_psbt *psbt;
|
||||
const u8 *our_shutdown_scriptpubkey;
|
||||
char *err_msg;
|
||||
@ -266,18 +263,14 @@ openchannel2_hook_serialize(struct openchannel2_payload *payload,
|
||||
payload->max_htlc_value_in_flight_msat);
|
||||
json_add_amount_msat_only(stream, "htlc_minimum_msat",
|
||||
payload->htlc_minimum_msat);
|
||||
json_add_num(stream, "funding_feerate_max",
|
||||
payload->funding_feerate_max);
|
||||
json_add_num(stream, "funding_feerate_min",
|
||||
payload->funding_feerate_min);
|
||||
json_add_num(stream, "funding_feerate_best",
|
||||
payload->funding_feerate_best);
|
||||
json_add_num(stream, "funding_feerate_per_kw",
|
||||
payload->funding_feerate_per_kw);
|
||||
json_add_num(stream, "commitment_feerate_per_kw",
|
||||
payload->commitment_feerate_per_kw);
|
||||
json_add_num(stream, "feerate_our_max",
|
||||
payload->feerate_our_max);
|
||||
json_add_num(stream, "feerate_our_min",
|
||||
payload->feerate_our_min);
|
||||
json_add_num(stream, "commitment_feerate_per_kw",
|
||||
payload->commitment_feerate_per_kw);
|
||||
json_add_num(stream, "to_self_delay", payload->to_self_delay);
|
||||
json_add_num(stream, "max_accepted_htlcs", payload->max_accepted_htlcs);
|
||||
json_add_num(stream, "channel_flags", payload->channel_flags);
|
||||
@ -689,38 +682,11 @@ openchannel2_hook_cb(struct openchannel2_payload *payload STEALS)
|
||||
return subd_send_msg(dualopend, take(msg));
|
||||
}
|
||||
|
||||
/* If there's no plugin, the funding_feerate_per_kw will be zero.
|
||||
* In this case, we set the funding_feerate_per_kw to the default,
|
||||
* the 'best' */
|
||||
if (payload->funding_feerate_per_kw == 0) {
|
||||
u32 best_feerate
|
||||
= payload->funding_feerate_per_kw
|
||||
= payload->funding_feerate_best;
|
||||
|
||||
/* We use the old checks here now, against the base feerate */
|
||||
if (best_feerate < payload->feerate_our_min) {
|
||||
msg = towire_dualopend_fail(NULL, tal_fmt(tmpctx,
|
||||
"feerate_per_kw %u below"
|
||||
" minimum %u",
|
||||
best_feerate,
|
||||
payload->feerate_our_min));
|
||||
return subd_send_msg(dualopend, take(msg));
|
||||
}
|
||||
if (best_feerate > payload->feerate_our_max) {
|
||||
msg = towire_dualopend_fail(NULL, tal_fmt(tmpctx,
|
||||
"feerate_per_kw %u above"
|
||||
" maximum %u",
|
||||
best_feerate,
|
||||
payload->feerate_our_max));
|
||||
return subd_send_msg(dualopend, take(msg));
|
||||
}
|
||||
}
|
||||
|
||||
channel->cid = payload->channel_id;
|
||||
channel->opener = REMOTE;
|
||||
channel->open_attempt = new_channel_open_attempt(channel);
|
||||
msg = towire_dualopend_got_offer_reply(NULL, payload->accepter_funding,
|
||||
payload->funding_feerate_per_kw,
|
||||
msg = towire_dualopend_got_offer_reply(NULL,
|
||||
payload->accepter_funding,
|
||||
payload->psbt,
|
||||
payload->our_shutdown_scriptpubkey);
|
||||
|
||||
@ -807,26 +773,6 @@ openchannel2_hook_deserialize(struct openchannel2_payload *payload,
|
||||
&payload->accepter_funding))
|
||||
fatal("Plugin failed to supply accepter_funding_msat field");
|
||||
|
||||
const jsmntok_t *t = json_get_member(buffer, toks, "funding_feerate");
|
||||
/* If they don't return a feerate, we use the best */
|
||||
if (!t)
|
||||
payload->funding_feerate_per_kw = payload->funding_feerate_best;
|
||||
else {
|
||||
if (!json_to_number(buffer, t,
|
||||
&payload->funding_feerate_per_kw))
|
||||
fatal("Unable to parse 'funding-feerate'");
|
||||
if (payload->funding_feerate_per_kw
|
||||
< payload->funding_feerate_min
|
||||
|| payload->funding_feerate_per_kw
|
||||
> payload->funding_feerate_max)
|
||||
/* FIXME: return an error instead of failing? */
|
||||
fatal("Plugin supplied invalid funding feerate %d."
|
||||
" Outside valid range %d - %d",
|
||||
payload->funding_feerate_per_kw,
|
||||
payload->funding_feerate_min,
|
||||
payload->funding_feerate_max);
|
||||
}
|
||||
|
||||
if (!payload->psbt &&
|
||||
!amount_sat_eq(payload->accepter_funding, AMOUNT_SAT(0))) {
|
||||
/* Gotta give a PSBT if you set the accepter_funding amount */
|
||||
@ -1042,7 +988,7 @@ static struct amount_sat calculate_reserve(struct channel_config *their_config,
|
||||
{
|
||||
struct amount_sat reserve, dust_limit;
|
||||
|
||||
/* BOLT-fe0351ca2cea3105c4f2eb18c571afca9d21c85b #2
|
||||
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2
|
||||
*
|
||||
* The channel reserve is fixed at 1% of the total channel balance
|
||||
* rounded down (sum of `funding_satoshis` from `open_channel2`
|
||||
@ -1677,9 +1623,7 @@ static void accepter_got_offer(struct subd *dualopend,
|
||||
&payload->dust_limit_satoshis,
|
||||
&payload->max_htlc_value_in_flight_msat,
|
||||
&payload->htlc_minimum_msat,
|
||||
&payload->funding_feerate_max,
|
||||
&payload->funding_feerate_min,
|
||||
&payload->funding_feerate_best,
|
||||
&payload->funding_feerate_per_kw,
|
||||
&payload->commitment_feerate_per_kw,
|
||||
&payload->to_self_delay,
|
||||
&payload->max_accepted_htlcs,
|
||||
@ -1695,13 +1639,10 @@ static void accepter_got_offer(struct subd *dualopend,
|
||||
* min + max feerates. Ideally, the plugin will fail to
|
||||
* contribute funds if the peer's feerate range is outside of
|
||||
* this acceptable range, but we delegate that decision to
|
||||
* the plugin's logic */
|
||||
* the plugin */
|
||||
payload->feerate_our_min = feerate_min(dualopend->ld, NULL);
|
||||
payload->feerate_our_max = feerate_max(dualopend->ld, NULL);
|
||||
|
||||
/* Set the inital to feerate to zero, in case there is no plugin */
|
||||
payload->funding_feerate_per_kw = 0;
|
||||
|
||||
tal_add_destructor2(dualopend, openchannel2_remove_dualopend, payload);
|
||||
plugin_hook_call_openchannel2(dualopend->ld, payload);
|
||||
}
|
||||
@ -1802,9 +1743,12 @@ static void handle_validate_rbf(struct subd *dualopend,
|
||||
inputs_present = tal_arr(tmpctx, bool, candidate_psbt->num_inputs);
|
||||
memset(inputs_present, true, tal_bytelen(inputs_present));
|
||||
|
||||
/* Iterate through all previous inflights, confirm
|
||||
* that at least one input is in all proposed RBFs, including
|
||||
* this one. */
|
||||
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
* The receiving node: ...
|
||||
* - MUST fail the negotiation if: ...
|
||||
* - the transaction does not share a common input with
|
||||
* all previous funding transactions
|
||||
*/
|
||||
list_for_each(&channel->inflights, inflight, list) {
|
||||
/* Remove every non-matching input from set */
|
||||
for (size_t i = 0; i < candidate_psbt->num_inputs; i++) {
|
||||
@ -1849,13 +1793,12 @@ static void handle_validate_rbf(struct subd *dualopend,
|
||||
assert(inflight);
|
||||
last_fee = psbt_compute_fee(inflight->funding_psbt);
|
||||
|
||||
/* BOLT-8edf819f1de3b110653f0b21594a04cfd03d5240 #2:
|
||||
*
|
||||
* The receiving node:
|
||||
* - if this is an RBF attempt:
|
||||
* - MUST fail the RBF attempt if:
|
||||
* - the completed transaction's total fees paid
|
||||
* is less than the last successful funding transaction's fees.
|
||||
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
* The receiving node: ...
|
||||
* - if is an RBF attempt:
|
||||
* - MUST fail the negotiation if:
|
||||
* - the transaction's total fees is less than the last
|
||||
* successfully negotiated transaction's fees
|
||||
*/
|
||||
if (!amount_sat_greater(candidate_fee, last_fee)) {
|
||||
char *errmsg = tal_fmt(tmpctx, "Proposed funding tx fee (%s)"
|
||||
@ -2721,8 +2664,6 @@ static void start_fresh_dualopend(struct peer *peer,
|
||||
pps, &channel->local_basepoints,
|
||||
&channel->local_funding_pubkey,
|
||||
channel->minimum_depth,
|
||||
feerate_min(peer->ld, NULL),
|
||||
feerate_max(peer->ld, NULL),
|
||||
send_msg);
|
||||
subd_send_msg(channel->owner, take(msg));
|
||||
|
||||
@ -2794,8 +2735,6 @@ void peer_restart_dualopend(struct peer *peer,
|
||||
&channel->local_funding_pubkey,
|
||||
&channel->channel_info.remote_fundingkey,
|
||||
channel->minimum_depth,
|
||||
feerate_min(peer->ld, NULL),
|
||||
feerate_max(peer->ld, NULL),
|
||||
&inflight->funding->txid,
|
||||
inflight->funding->outnum,
|
||||
first_inflight->funding->feerate,
|
||||
|
@ -73,8 +73,13 @@ enum tx_msgs {
|
||||
};
|
||||
|
||||
/*
|
||||
* BOLT-544bda7144d91b3f51856189b8932610649f9e93 #2:
|
||||
- MUST NOT send more than 2^12 ... messages
|
||||
* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
* The receiving node:
|
||||
* ...
|
||||
* - MUST fail the negotiation if: ...
|
||||
* - if has received 4096 `tx_add_input` messages during this negotiation
|
||||
* ...
|
||||
* - it has received 4096 `tx_add_output` messages during this negotiation
|
||||
*/
|
||||
#define MAX_TX_MSG_RCVD (1 << 12)
|
||||
|
||||
@ -131,7 +136,6 @@ struct state {
|
||||
|
||||
/* Constraints on a channel they open. */
|
||||
u32 minimum_depth;
|
||||
u32 min_feerate, max_feerate;
|
||||
struct amount_msat min_effective_htlc_capacity;
|
||||
|
||||
/* Limits on what remote config we accept. */
|
||||
@ -436,12 +440,13 @@ static void set_reserve(struct tx_state *tx_state,
|
||||
{
|
||||
struct amount_sat reserve, dust_limit;
|
||||
|
||||
/* BOLT-fe0351ca2cea3105c4f2eb18c571afca9d21c85b #2
|
||||
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
*
|
||||
* The channel reserve is fixed at 1% of the total channel balance
|
||||
* rounded down (sum of `funding_satoshis` from `open_channel2`
|
||||
* and `accept_channel2`) or the `dust_limit_satoshis` from
|
||||
* `open_channel2`, whichever is greater.
|
||||
* Instead, the channel reserve is fixed at 1% of the total
|
||||
* channel balance (`open_channel2`.`funding_satoshis` +
|
||||
* `accept_channel2`.`funding_satoshis`) rounded down to the
|
||||
* nearest whole satoshi or the `dust_limit_satoshis`, whichever is
|
||||
* greater.
|
||||
*/
|
||||
reserve = amount_sat_div(funding_total, 100);
|
||||
dust_limit = our_role == TX_INITIATOR ?
|
||||
@ -459,13 +464,11 @@ static void set_reserve(struct tx_state *tx_state,
|
||||
|
||||
static bool is_openers(const struct wally_map *unknowns)
|
||||
{
|
||||
/* BOLT-fe0351ca2cea3105c4f2eb18c571afca9d21c85b #2
|
||||
* The sending node:
|
||||
* ...
|
||||
* - if is the `initiator`:
|
||||
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
* The sending node: ...
|
||||
* - if is the *initiator*:
|
||||
* - MUST send even `serial_id`s
|
||||
* - if is the `contributor`:
|
||||
* ...
|
||||
* - if is the *non-initiator*:
|
||||
* - MUST send odd `serial_id`s
|
||||
*/
|
||||
u64 serial_id;
|
||||
@ -487,7 +490,8 @@ static size_t psbt_input_weight(struct wally_psbt *psbt,
|
||||
(psbt->inputs[in].redeem_script_len +
|
||||
(varint_t) varint_size(psbt->inputs[in].redeem_script_len)) * 4;
|
||||
|
||||
/* BOLT-78de9a79b491ae9fb84b1fdb4546bacf642dce87 #2
|
||||
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #3:
|
||||
*
|
||||
* The minimum witness weight for an input is 110.
|
||||
*/
|
||||
weight += 110;
|
||||
@ -530,10 +534,10 @@ static char *check_balances(const tal_t *ctx,
|
||||
size_t accepter_weight = 0;
|
||||
|
||||
|
||||
/* BOLT-78de9a79b491ae9fb84b1fdb4546bacf642dce87 #2:
|
||||
* The initiator is responsible for paying the fees
|
||||
* for the following fields, to be referred to as
|
||||
* the `common fields`.
|
||||
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
*
|
||||
* The *initiator* is responsible for paying the fees for the
|
||||
* following fields, to be referred to as the `common fields`.
|
||||
* - version
|
||||
* - segwit marker + flag
|
||||
* - input count
|
||||
@ -562,12 +566,15 @@ static char *check_balances(const tal_t *ctx,
|
||||
return "overflow adding desired funding";
|
||||
}
|
||||
|
||||
/* BOLT-78de9a79b491ae9fb84b1fdb4546bacf642dce87 #2:
|
||||
* The receiving node:
|
||||
* ...
|
||||
* - MUST fail the channel if:
|
||||
* ...
|
||||
* - the value of the funding output is incorrect
|
||||
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
*
|
||||
* Upon receipt of consecutive `tx_complete`s, the receiving
|
||||
* node:
|
||||
* - if is the *accepter*:
|
||||
* - MUST fail the negotiation if: ...
|
||||
* - the value of the funding output is not equal to the
|
||||
* sum of `open_channel2`.`funding_satoshis`
|
||||
* and `accept_channel2`. `funding_satoshis`
|
||||
*/
|
||||
if (!amount_sat_eq(total_funding, output_val)) {
|
||||
return tal_fmt(tmpctx, "total desired funding %s != "
|
||||
@ -580,13 +587,14 @@ static char *check_balances(const tal_t *ctx,
|
||||
&output_val));
|
||||
}
|
||||
|
||||
/* BOLT-78de9a79b491ae9fb84b1fdb4546bacf642dce87 #2:
|
||||
* The receiving node:
|
||||
* ...
|
||||
* - MUST fail the channel if:
|
||||
* ...
|
||||
* - if the `funding_output` of the resulting
|
||||
* transaction is less than the `dust_limit`
|
||||
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
*
|
||||
* Upon receipt of consecutive `tx_complete`s, the receiving
|
||||
* node:
|
||||
* - if is the *accepter*:
|
||||
* - MUST fail the negotiation if: ...
|
||||
* - the value of the funding output is
|
||||
* less than the `dust_limit`
|
||||
*/
|
||||
if (!amount_sat_greater(output_val,
|
||||
tx_state->remoteconf.dust_limit) ||
|
||||
@ -595,12 +603,13 @@ static char *check_balances(const tal_t *ctx,
|
||||
return "funding output is dust";
|
||||
}
|
||||
} else {
|
||||
/* BOLT-78de9a79b491ae9fb84b1fdb4546bacf642dce87 #2:
|
||||
* The receiving node:
|
||||
* ...
|
||||
* - MUST fail the channel if:
|
||||
* - no funding output is received, identified by
|
||||
* the `script`
|
||||
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
*
|
||||
* Upon receipt of consecutive `tx_complete`s, the receiving
|
||||
* node:
|
||||
* - if is the *accepter*:
|
||||
* - MUST fail the negotiation if:
|
||||
* - no funding output was received
|
||||
*/
|
||||
return "funding output not present";
|
||||
}
|
||||
@ -650,10 +659,13 @@ static char *check_balances(const tal_t *ctx,
|
||||
return "overflow adding output total";
|
||||
}
|
||||
|
||||
/* BOLT-78de9a79b491ae9fb84b1fdb4546bacf642dce87 #2:
|
||||
* The sending node:
|
||||
* - MUST specify a `sats` value greater
|
||||
* than the dust limit
|
||||
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
* The receiving node:
|
||||
* ...
|
||||
* - MUST fail the negotiation if:
|
||||
* ...
|
||||
* - the `sats` amount is less than or equal to
|
||||
* the `dust_limit`
|
||||
*/
|
||||
if (!amount_sat_greater(amt,
|
||||
tx_state->remoteconf.dust_limit) ||
|
||||
@ -685,25 +697,25 @@ static char *check_balances(const tal_t *ctx,
|
||||
}
|
||||
}
|
||||
|
||||
/* BOLT-78de9a79b491ae9fb84b1fdb4546bacf642dce87 #2:
|
||||
* The receiving node: ...
|
||||
* - MUST fail the channel if:
|
||||
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
* The receiving node:
|
||||
* ...
|
||||
* - the total satoshis of the inputs is less than
|
||||
* the outputs
|
||||
* - MUST fail the negotiation if:
|
||||
* ...
|
||||
* - the peer's total input satoshis is less than their outputs
|
||||
*/
|
||||
if (!amount_sat_greater_eq(tot_input_amt, tot_output_amt)) {
|
||||
return "inputs less than total outputs";
|
||||
}
|
||||
|
||||
/* BOLT-78de9a79b491ae9fb84b1fdb4546bacf642dce87 #2:
|
||||
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
* The receiving node: ...
|
||||
* - MUST fail the channel if:
|
||||
* - MUST fail the negotiation if:
|
||||
* ...
|
||||
* - the peer's paid feerate does not meet or exceed
|
||||
* the agreed `feerate`, (based on the miminum fee).
|
||||
* - the `initiator`'s fees do not cover the `common`
|
||||
* fields
|
||||
* - the peer's paid feerate does not meet or exceed the
|
||||
* agreed `feerate`, (based on the `minimum fee`).
|
||||
* - if is the *non-initiator*:
|
||||
* - the *initiator*'s fees do not cover the `common` fields
|
||||
*/
|
||||
if (!amount_sat_sub(&accepter_diff, accepter_inputs,
|
||||
accepter_outs)) {
|
||||
@ -715,10 +727,13 @@ static char *check_balances(const tal_t *ctx,
|
||||
return "initiator inputs less than outputs";
|
||||
}
|
||||
|
||||
/* BOLT-78de9a79b491ae9fb84b1fdb4546bacf642dce87 #2:
|
||||
* Each party to the transaction is responsible for
|
||||
* paying the fees for their input, output,
|
||||
* and witness at the agreed `feerate`. */
|
||||
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
* The receiving node: ...
|
||||
* - MUST fail the negotiation if:
|
||||
* ...
|
||||
* - the peer's paid feerate does not meet or exceed the
|
||||
* agreed `feerate`, (based on the `minimum fee`).
|
||||
*/
|
||||
accepter_fee = amount_tx_fee(feerate_per_kw_funding,
|
||||
accepter_weight);
|
||||
initiator_fee = amount_tx_fee(feerate_per_kw_funding,
|
||||
@ -1267,32 +1282,31 @@ static bool run_tx_interactive(struct state *state,
|
||||
check_channel_id(state, &cid, &state->channel_id);
|
||||
|
||||
/*
|
||||
* BOLT-544bda7144d91b3f51856189b8932610649f9e93 #2:
|
||||
* The receiving node:
|
||||
* - MUST fail the transaction collaboration if:
|
||||
* - it receives more than 2^12 `tx_add_input`
|
||||
* messages */
|
||||
* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
* The receiving node: ...
|
||||
* - MUST fail the negotiation if: ...
|
||||
* - if has received 4096 `tx_add_input`
|
||||
* messages during this negotiation
|
||||
*/
|
||||
if (++tx_state->tx_msg_count[TX_ADD_INPUT] > MAX_TX_MSG_RCVD)
|
||||
open_err_warn(state, "Too many `tx_add_input`s"
|
||||
" received %d", MAX_TX_MSG_RCVD);
|
||||
/*
|
||||
* BOLT-fe0351ca2cea3105c4f2eb18c571afca9d21c85b #2:
|
||||
* - if is the `initiator`:
|
||||
* - MUST send even `serial_id`s
|
||||
* - MUST fail the transaction collaboration if:
|
||||
* ...
|
||||
* - it receives a `serial_id` from the peer
|
||||
* with the incorrect parity
|
||||
* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
* The receiving node: ...
|
||||
* - MUST fail the negotiation if: ...
|
||||
* - the `serial_id` has the wrong parity
|
||||
*/
|
||||
if (serial_id % 2 == our_role)
|
||||
open_err_warn(state,
|
||||
"Invalid serial_id rcvd. %"PRIu64,
|
||||
serial_id);
|
||||
/*
|
||||
* BOLT-fe0351ca2cea3105c4f2eb18c571afca9d21c85b #2:
|
||||
* - MUST fail the transaction collaboration if:
|
||||
* ...
|
||||
* - it recieves a duplicate `serial_id`
|
||||
* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
* The receiving node: ...
|
||||
* - MUST fail the negotiation if: ...
|
||||
* - the `serial_id` is already included in
|
||||
* the transaction
|
||||
*/
|
||||
if (psbt_find_serial_input(psbt, serial_id) != -1)
|
||||
open_err_warn(state, "Duplicate serial_id rcvd."
|
||||
@ -1309,11 +1323,11 @@ static bool run_tx_interactive(struct state *state,
|
||||
"Invalid tx outnum sent. %u",
|
||||
outnum);
|
||||
/*
|
||||
* BOLT-fe0351ca2cea3105c4f2eb18c571afca9d21c85b #2:
|
||||
* - MUST fail the transaction collaboration if:
|
||||
* ...
|
||||
* - it receives an input that would create a
|
||||
* malleable transaction id (e.g. pre-Segwit)
|
||||
* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
* The receiving node: ...
|
||||
* - MUST fail the negotiation if: ...
|
||||
* - the `prevtx_out` input of `prevtx` is
|
||||
* not an `OP_0` to `OP_16` followed by a single push
|
||||
*/
|
||||
if (!is_segwit_output(&tx->wtx->outputs[outnum],
|
||||
redeemscript))
|
||||
@ -1324,14 +1338,12 @@ static bool run_tx_interactive(struct state *state,
|
||||
tx));
|
||||
|
||||
/*
|
||||
* BOLT-fe0351ca2cea3105c4f2eb18c571afca9d21c85b #2:
|
||||
* - MUST NOT re-transmit inputs it has already
|
||||
* received from the peer
|
||||
* ...
|
||||
* - MUST fail the transaction collaboration if:
|
||||
* ...
|
||||
* - it receives a duplicate input to one it
|
||||
* sent previously
|
||||
* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
* The receiving node: ...
|
||||
* - MUST fail the negotiation if:
|
||||
* - the `prevtx` and `prevtx_vout` are
|
||||
* identical to a previously added (and not
|
||||
* removed) input's
|
||||
*/
|
||||
bitcoin_txid(tx, &txid);
|
||||
if (psbt_has_input(psbt, &txid, outnum))
|
||||
@ -1344,10 +1356,9 @@ static bool run_tx_interactive(struct state *state,
|
||||
outnum);
|
||||
|
||||
/*
|
||||
* BOLT-fe0351ca2cea3105c4f2eb18c571afca9d21c85b #2:
|
||||
* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
* The receiving node:
|
||||
* - MUST add all received inputs to the funding
|
||||
* transaction
|
||||
* - MUST add all received inputs to the transaction
|
||||
*/
|
||||
struct wally_psbt_input *in =
|
||||
psbt_append_input(psbt, &txid, outnum,
|
||||
@ -1395,27 +1406,23 @@ static bool run_tx_interactive(struct state *state,
|
||||
|
||||
check_channel_id(state, &cid, &state->channel_id);
|
||||
|
||||
/*
|
||||
* BOLT-544bda7144d91b3f51856189b8932610649f9e93 #2:
|
||||
* The receiving node:
|
||||
* - MUST fail the transaction collaboration if:
|
||||
* - it receives more than 2^12 `tx_rm_input`
|
||||
* messages */
|
||||
if (++tx_state->tx_msg_count[TX_RM_INPUT] > MAX_TX_MSG_RCVD)
|
||||
open_err_warn(state,
|
||||
"Too many `tx_rm_input`s"
|
||||
" received (%d)",
|
||||
MAX_TX_MSG_RCVD);
|
||||
|
||||
/* BOLT-fe0351ca2cea3105c4f2eb18c571afca9d21c85b #2
|
||||
* The sending node:
|
||||
* - MUST NOT send a `tx_remove_input` for an
|
||||
* input which is not theirs */
|
||||
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
* The receiving node: ...
|
||||
* - MUST fail the negotiation if: ...
|
||||
* - the input or output identified by the
|
||||
* `serial_id` was not added by the sender
|
||||
*/
|
||||
if (serial_id % 2 == our_role)
|
||||
open_err_warn(state,
|
||||
"Invalid serial_id rcvd. %"PRIu64,
|
||||
serial_id);
|
||||
|
||||
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
* The receiving node: ...
|
||||
* - MUST fail the negotiation if: ...
|
||||
* - the `serial_id` does not correspond
|
||||
* to a currently added input (or output)
|
||||
*/
|
||||
input_index = psbt_find_serial_input(psbt, serial_id);
|
||||
if (input_index == -1)
|
||||
open_err_warn(state,
|
||||
@ -1439,34 +1446,46 @@ static bool run_tx_interactive(struct state *state,
|
||||
check_channel_id(state, &cid, &state->channel_id);
|
||||
|
||||
/*
|
||||
* BOLT-544bda7144d91b3f51856189b8932610649f9e93 #2:
|
||||
* The receiving node:
|
||||
* - MUST fail the transaction collaboration if:
|
||||
* - it receives more than 2^12 `tx_add_output`
|
||||
* messages */
|
||||
* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
* The receiving node: ...
|
||||
* - MUST fail the negotiation if: ...
|
||||
* - it has received 4096 `tx_add_output`
|
||||
* messages during this negotiation
|
||||
*/
|
||||
if (++tx_state->tx_msg_count[TX_ADD_OUTPUT] > MAX_TX_MSG_RCVD)
|
||||
open_err_warn(state,
|
||||
"Too many `tx_add_output`s"
|
||||
" received (%d)",
|
||||
MAX_TX_MSG_RCVD);
|
||||
|
||||
/* BOLT-fe0351ca2cea3105c4f2eb18c571afca9d21c85b #2
|
||||
* The receiving node:
|
||||
* ...
|
||||
* - MUST fail the transaction collaboration if:
|
||||
* ...
|
||||
* - it receives a `serial_id` from the peer with the
|
||||
* incorrect parity */
|
||||
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
* The receiving node: ...
|
||||
* - MUST fail the negotiation if: ...
|
||||
* - the `serial_id` has the wrong parity
|
||||
*/
|
||||
if (serial_id % 2 == our_role)
|
||||
open_err_warn(state,
|
||||
"Invalid serial_id rcvd. %"PRIu64,
|
||||
serial_id);
|
||||
|
||||
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
* The receiving node: ...
|
||||
* - MUST fail the negotiation if: ...
|
||||
* - the `serial_id` is already included
|
||||
* in the transaction */
|
||||
if (psbt_find_serial_output(psbt, serial_id) != -1)
|
||||
open_err_warn(state,
|
||||
"Duplicate serial_id rcvd."
|
||||
" %"PRIu64, serial_id);
|
||||
amt = amount_sat(value);
|
||||
|
||||
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
* The receiving node: ...
|
||||
* - MAY fail the negotiation if `script`
|
||||
* is non-standard */
|
||||
if (!is_known_scripttype(scriptpubkey))
|
||||
open_err_warn(state, "Script is not standard");
|
||||
|
||||
out = psbt_append_output(psbt, scriptpubkey, amt);
|
||||
psbt_output_set_serial_id(psbt, out, serial_id);
|
||||
break;
|
||||
@ -1481,27 +1500,23 @@ static bool run_tx_interactive(struct state *state,
|
||||
|
||||
check_channel_id(state, &cid, &state->channel_id);
|
||||
|
||||
/*
|
||||
* BOLT-544bda7144d91b3f51856189b8932610649f9e93 #2:
|
||||
* The receiving node:
|
||||
* - MUST fail the transaction collaboration if:
|
||||
* - it receives more than 2^12 `tx_rm_output`
|
||||
* messages */
|
||||
if (++tx_state->tx_msg_count[TX_RM_OUTPUT] > MAX_TX_MSG_RCVD)
|
||||
open_err_warn(state,
|
||||
"Too many `tx_rm_output`s"
|
||||
" received (%d)",
|
||||
MAX_TX_MSG_RCVD);
|
||||
|
||||
/* BOLT-fe0351ca2cea3105c4f2eb18c571afca9d21c85b #2
|
||||
* The sending node:
|
||||
* - MUST NOT send a `tx_remove_ouput` for an
|
||||
* input which is not theirs */
|
||||
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
* The receiving node: ...
|
||||
* - MUST fail the negotiation if: ...
|
||||
* - the input or output identified by the
|
||||
* `serial_id` was not added by the sender
|
||||
*/
|
||||
if (serial_id % 2 == our_role)
|
||||
open_err_warn(state,
|
||||
"Invalid serial_id rcvd."
|
||||
" %"PRIu64, serial_id);
|
||||
|
||||
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
* The receiving node: ...
|
||||
* - MUST fail the negotiation if: ...
|
||||
* - the `serial_id` does not correspond to a
|
||||
* currently added input (or output)
|
||||
*/
|
||||
output_index = psbt_find_serial_output(psbt, serial_id);
|
||||
if (output_index == -1)
|
||||
open_err_warn(state, false,
|
||||
@ -1842,7 +1857,6 @@ static void accepter_start(struct state *state, const u8 *oc2_msg)
|
||||
u8 *msg;
|
||||
struct amount_sat total;
|
||||
enum dualopend_wire msg_type;
|
||||
u32 feerate_min, feerate_max, feerate_best;
|
||||
struct tx_state *tx_state = state->tx_state;
|
||||
|
||||
state->our_role = TX_ACCEPTER;
|
||||
@ -1850,14 +1864,12 @@ static void accepter_start(struct state *state, const u8 *oc2_msg)
|
||||
|
||||
if (!fromwire_open_channel2(oc2_msg, &chain_hash,
|
||||
&state->channel_id,
|
||||
&feerate_max,
|
||||
&feerate_min,
|
||||
&feerate_best,
|
||||
&state->feerate_per_kw_funding,
|
||||
&state->feerate_per_kw_commitment,
|
||||
&tx_state->opener_funding,
|
||||
&tx_state->remoteconf.dust_limit,
|
||||
&tx_state->remoteconf.max_htlc_value_in_flight,
|
||||
&tx_state->remoteconf.htlc_minimum,
|
||||
&state->feerate_per_kw_commitment,
|
||||
&tx_state->remoteconf.to_self_delay,
|
||||
&tx_state->remoteconf.max_accepted_htlcs,
|
||||
&tx_state->tx_locktime,
|
||||
@ -1878,6 +1890,9 @@ static void accepter_start(struct state *state, const u8 *oc2_msg)
|
||||
} else
|
||||
state->upfront_shutdown_script[REMOTE] = NULL;
|
||||
|
||||
/* Save feerate on the tx_state as well */
|
||||
tx_state->feerate_per_kw_funding = state->feerate_per_kw_funding;
|
||||
|
||||
/* BOLT #2:
|
||||
*
|
||||
* The receiving node MUST fail the channel if:
|
||||
@ -1921,9 +1936,7 @@ static void accepter_start(struct state *state, const u8 *oc2_msg)
|
||||
tx_state->remoteconf.dust_limit,
|
||||
tx_state->remoteconf.max_htlc_value_in_flight,
|
||||
tx_state->remoteconf.htlc_minimum,
|
||||
feerate_max,
|
||||
feerate_min,
|
||||
feerate_best,
|
||||
state->feerate_per_kw_funding,
|
||||
state->feerate_per_kw_commitment,
|
||||
tx_state->remoteconf.to_self_delay,
|
||||
tx_state->remoteconf.max_accepted_htlcs,
|
||||
@ -1944,7 +1957,6 @@ static void accepter_start(struct state *state, const u8 *oc2_msg)
|
||||
|
||||
if (!fromwire_dualopend_got_offer_reply(state, msg,
|
||||
&tx_state->accepter_funding,
|
||||
&tx_state->feerate_per_kw_funding,
|
||||
&tx_state->psbt,
|
||||
&state->upfront_shutdown_script[LOCAL]))
|
||||
master_badmsg(WIRE_DUALOPEND_GOT_OFFER_REPLY, msg);
|
||||
@ -2026,7 +2038,6 @@ static void accepter_start(struct state *state, const u8 *oc2_msg)
|
||||
|
||||
msg = towire_accept_channel2(tmpctx, &state->channel_id,
|
||||
tx_state->accepter_funding,
|
||||
tx_state->feerate_per_kw_funding,
|
||||
tx_state->localconf.dust_limit,
|
||||
tx_state->localconf.max_htlc_value_in_flight,
|
||||
tx_state->localconf.htlc_minimum,
|
||||
@ -2326,7 +2337,6 @@ static void opener_start(struct state *state, u8 *msg)
|
||||
struct channel_id cid;
|
||||
char *err_reason;
|
||||
struct amount_sat total;
|
||||
u32 feerate_min, feerate_max, feerate_best;
|
||||
struct tx_state *tx_state = state->tx_state;
|
||||
|
||||
if (!fromwire_dualopend_opener_init(state, msg,
|
||||
@ -2334,12 +2344,13 @@ static void opener_start(struct state *state, u8 *msg)
|
||||
&tx_state->opener_funding,
|
||||
&state->upfront_shutdown_script[LOCAL],
|
||||
&state->feerate_per_kw_commitment,
|
||||
&tx_state->feerate_per_kw_funding,
|
||||
&state->feerate_per_kw_funding,
|
||||
&state->channel_flags))
|
||||
master_badmsg(WIRE_DUALOPEND_OPENER_INIT, msg);
|
||||
|
||||
state->our_role = TX_INITIATOR;
|
||||
tx_state->tx_locktime = tx_state->psbt->tx->locktime;
|
||||
tx_state->feerate_per_kw_funding = state->feerate_per_kw_funding;
|
||||
open_tlv = tlv_opening_tlvs_new(tmpctx);
|
||||
|
||||
/* Set the channel_id to a temporary id, we'll update
|
||||
@ -2348,28 +2359,6 @@ static void opener_start(struct state *state, u8 *msg)
|
||||
* understand it */
|
||||
temporary_channel_id(&state->channel_id);
|
||||
|
||||
feerate_min = state->min_feerate;
|
||||
feerate_max = state->max_feerate;
|
||||
if (tx_state->feerate_per_kw_funding > state->max_feerate) {
|
||||
status_info("Selected funding feerate %d is greater than"
|
||||
" current suggested max %d, adjusing max upwards"
|
||||
" to match.",
|
||||
tx_state->feerate_per_kw_funding,
|
||||
state->max_feerate);
|
||||
|
||||
feerate_max = tx_state->feerate_per_kw_funding;
|
||||
}
|
||||
if (tx_state->feerate_per_kw_funding < state->min_feerate) {
|
||||
status_info("Selected funding feerate %d is less than"
|
||||
" current suggested min %d, adjusing min downwards"
|
||||
" to match.",
|
||||
tx_state->feerate_per_kw_funding,
|
||||
state->min_feerate);
|
||||
|
||||
feerate_min = tx_state->feerate_per_kw_funding;
|
||||
}
|
||||
feerate_best = tx_state->feerate_per_kw_funding;
|
||||
|
||||
if (!state->upfront_shutdown_script[LOCAL])
|
||||
state->upfront_shutdown_script[LOCAL]
|
||||
= no_upfront_shutdown_script(state,
|
||||
@ -2387,14 +2376,12 @@ static void opener_start(struct state *state, u8 *msg)
|
||||
msg = towire_open_channel2(NULL,
|
||||
&chainparams->genesis_blockhash,
|
||||
&state->channel_id,
|
||||
feerate_max,
|
||||
feerate_min,
|
||||
feerate_best,
|
||||
state->feerate_per_kw_funding,
|
||||
state->feerate_per_kw_commitment,
|
||||
tx_state->opener_funding,
|
||||
tx_state->localconf.dust_limit,
|
||||
tx_state->localconf.max_htlc_value_in_flight,
|
||||
tx_state->localconf.htlc_minimum,
|
||||
state->feerate_per_kw_commitment,
|
||||
tx_state->localconf.to_self_delay,
|
||||
tx_state->localconf.max_accepted_htlcs,
|
||||
tx_state->tx_locktime,
|
||||
@ -2421,7 +2408,6 @@ static void opener_start(struct state *state, u8 *msg)
|
||||
a_tlv = notleak(tlv_accept_tlvs_new(state));
|
||||
if (!fromwire_accept_channel2(msg, &cid,
|
||||
&tx_state->accepter_funding,
|
||||
&tx_state->feerate_per_kw_funding,
|
||||
&tx_state->remoteconf.dust_limit,
|
||||
&tx_state->remoteconf.max_htlc_value_in_flight,
|
||||
&tx_state->remoteconf.htlc_minimum,
|
||||
@ -2446,10 +2432,6 @@ static void opener_start(struct state *state, u8 *msg)
|
||||
} else
|
||||
state->upfront_shutdown_script[REMOTE] = NULL;
|
||||
|
||||
/* Copy the feerate per kw into the state struct as well; this is
|
||||
* the original feerate we'll use to base RBF upgrades on */
|
||||
state->feerate_per_kw_funding = tx_state->feerate_per_kw_funding;
|
||||
|
||||
/* Now we can set the 'real channel id' */
|
||||
derive_channel_id_v2(&state->channel_id,
|
||||
&state->our_points.revocation,
|
||||
@ -2463,20 +2445,6 @@ static void opener_start(struct state *state, u8 *msg)
|
||||
&state->channel_id),
|
||||
type_to_string(msg, struct channel_id, &cid));
|
||||
|
||||
/* BOLT-5fcbda56901af9e3b1d057cc41d0c5cfa60a2b94 #2:
|
||||
* The receiving node:
|
||||
* - if the `feerate_funding` is less than the `feerate_funding_min`
|
||||
* or above the `feerate_funding_max`
|
||||
* - MUST error.
|
||||
*/
|
||||
if (feerate_min > tx_state->feerate_per_kw_funding
|
||||
|| feerate_max < tx_state->feerate_per_kw_funding)
|
||||
open_err_warn(state, "Invalid feerate %d chosen. Valid min %d,"
|
||||
" valid max %d",
|
||||
tx_state->feerate_per_kw_funding,
|
||||
feerate_min, feerate_max);
|
||||
|
||||
|
||||
/* Check that total funding doesn't overflow */
|
||||
if (!amount_sat_add(&total, tx_state->opener_funding,
|
||||
tx_state->accepter_funding))
|
||||
@ -2505,11 +2473,11 @@ static void opener_start(struct state *state, u8 *msg)
|
||||
return;
|
||||
}
|
||||
|
||||
/* BOLT-78de9a79b491ae9fb84b1fdb4546bacf642dce87 #2:
|
||||
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
* The sending node:
|
||||
* - if is the `opener`:
|
||||
* - MUST send at least one `tx_add_output`, the channel
|
||||
* funding output.
|
||||
* - if is the *opener*:
|
||||
* - MUST send at least one `tx_add_output`, which
|
||||
* contains the channel's funding output
|
||||
*/
|
||||
add_funding_output(tx_state, state, total);
|
||||
|
||||
@ -2563,12 +2531,18 @@ static bool update_feerate(struct tx_state *tx_state,
|
||||
u32 feerate = feerate_funding;
|
||||
|
||||
/*
|
||||
* BOLT-487dd4b46aad9b59f7f3480b7bdf15862b52d2f9b #2:
|
||||
* Each `fee_step` adds 1/4 (rounded down) to the initial
|
||||
* transaction feerate, i.e. if the initial `feerate_per_kw_funding`
|
||||
* was 512 satoshis per kiloweight, `fee_step` 1 is
|
||||
* 512 + 512 / 4 or 640 sat/kw, `fee_step` 2
|
||||
* is 640 + 640 / 4 or 800 sat/kw.
|
||||
* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
*
|
||||
* `fee_step` is an integer value, which specifies the
|
||||
* `feerate` for this funding transaction, as a rate of
|
||||
* increase above the `open_channel2`. `funding_feerate_perkw`.
|
||||
*
|
||||
* The effective `funding_feerate_perkw` for this RBF attempt
|
||||
* if calculated as 1.25^`fee_step` * `funding_feerate_perkw`.
|
||||
* E.g. if `feerate_per_kw_funding` is 512 and the `fee_step` is 1,
|
||||
* the effective `feerate` for this RBF attempt is 512 + 512 / 4
|
||||
* or 640 sat/kw. A `fee_step` 2 would be `1.25^2 * 512`
|
||||
* (or 640 + 640 / 4), 800 sat/kw.
|
||||
*/
|
||||
for (; fee_step > 0; fee_step--)
|
||||
feerate += feerate / 4;
|
||||
@ -2605,12 +2579,11 @@ static void rbf_wrap_up(struct state *state,
|
||||
char *err_reason;
|
||||
u8 *msg;
|
||||
|
||||
/* BOLT-78de9a79b491ae9fb84b1fdb4546bacf642dce87 #2:
|
||||
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
|
||||
* The sending node:
|
||||
* - if is the `opener`:
|
||||
* - MUST send at least one `tx_add_output`, the channel
|
||||
* funding output.
|
||||
*/
|
||||
* - if is the *opener*:
|
||||
* - MUST send at least one `tx_add_output`, which contains the
|
||||
* channel's funding output */
|
||||
if (state->our_role == TX_INITIATOR)
|
||||
add_funding_output(tx_state, state, total);
|
||||
else
|
||||
@ -3427,8 +3400,6 @@ int main(int argc, char *argv[])
|
||||
&state->our_points,
|
||||
&state->our_funding_pubkey,
|
||||
&state->minimum_depth,
|
||||
&state->min_feerate,
|
||||
&state->max_feerate,
|
||||
&inner)) {
|
||||
/*~ Initially we're not associated with a channel, but
|
||||
* handle_peer_gossip_or_error compares this. */
|
||||
@ -3463,8 +3434,6 @@ int main(int argc, char *argv[])
|
||||
&state->our_funding_pubkey,
|
||||
&state->their_funding_pubkey,
|
||||
&state->minimum_depth,
|
||||
&state->min_feerate,
|
||||
&state->max_feerate,
|
||||
&state->tx_state->funding_txid,
|
||||
&state->tx_state->funding_txout,
|
||||
&state->feerate_per_kw_funding,
|
||||
|
@ -26,8 +26,6 @@ msgdata,dualopend_init,our_basepoints,basepoints,
|
||||
msgdata,dualopend_init,our_funding_pubkey,pubkey,
|
||||
# Constraints in case the other end tries to open a channel.
|
||||
msgdata,dualopend_init,minimum_depth,u32,
|
||||
msgdata,dualopend_init,min_feerate,u32,
|
||||
msgdata,dualopend_init,max_feerate,u32,
|
||||
# Optional msg to send.
|
||||
msgdata,dualopend_init,len,u16,
|
||||
msgdata,dualopend_init,msg,u8,len
|
||||
@ -48,8 +46,6 @@ msgdata,dualopend_reinit,our_basepoints,basepoints,
|
||||
msgdata,dualopend_reinit,our_funding_pubkey,pubkey,
|
||||
msgdata,dualopend_reinit,their_funding_pubkey,pubkey,
|
||||
msgdata,dualopend_reinit,minimum_depth,u32,
|
||||
msgdata,dualopend_reinit,min_feerate,u32,
|
||||
msgdata,dualopend_reinit,max_feerate,u32,
|
||||
msgdata,dualopend_reinit,funding_txid,bitcoin_txid,
|
||||
msgdata,dualopend_reinit,funding_txout,u16,
|
||||
msgdata,dualopend_reinit,orignal_feerate_per_kw_funding,u32,
|
||||
@ -82,10 +78,8 @@ msgdata,dualopend_got_offer,opener_funding,amount_sat,
|
||||
msgdata,dualopend_got_offer,dust_limit_satoshis,amount_sat,
|
||||
msgdata,dualopend_got_offer,max_htlc_value_in_flight_msat,amount_msat,
|
||||
msgdata,dualopend_got_offer,htlc_minimum_msat,amount_msat,
|
||||
msgdata,dualopend_got_offer,feerate_funding_max,u32,
|
||||
msgdata,dualopend_got_offer,feerate_funding_min,u32,
|
||||
msgdata,dualopend_got_offer,feerate_funding_best,u32,
|
||||
msgdata,dualopend_got_offer,feerate_per_kw,u32,
|
||||
msgdata,dualopend_got_offer,feerate_per_kw_funding,u32,
|
||||
msgdata,dualopend_got_offer,feerate_per_kw_commitment,u32,
|
||||
msgdata,dualopend_got_offer,to_self_delay,u16,
|
||||
msgdata,dualopend_got_offer,max_accepted_htlcs,u16,
|
||||
msgdata,dualopend_got_offer,channel_flags,u8,
|
||||
@ -96,7 +90,6 @@ msgdata,dualopend_got_offer,shutdown_scriptpubkey,u8,shutdown_len
|
||||
# master->dualopend: reply back with our first funding info/contribs
|
||||
msgtype,dualopend_got_offer_reply,7105
|
||||
msgdata,dualopend_got_offer_reply,accepter_funding,amount_sat,
|
||||
msgdata,dualopend_got_offer_reply,feerate_funding,u32,
|
||||
msgdata,dualopend_got_offer_reply,psbt,wally_psbt,
|
||||
msgdata,dualopend_got_offer_reply,shutdown_len,u16,
|
||||
msgdata,dualopend_got_offer_reply,our_shutdown_scriptpubkey,?u8,shutdown_len
|
||||
|
Can't render this file because it has a wrong number of fields in line 13.
|
40
openingd/dualopend_wiregen.c
generated
40
openingd/dualopend_wiregen.c
generated
@ -91,7 +91,7 @@ bool dualopend_wire_is_defined(u16 type)
|
||||
|
||||
|
||||
/* WIRE: DUALOPEND_INIT */
|
||||
u8 *towire_dualopend_init(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_feature_set, const u8 *their_init_features, const struct channel_config *our_config, u32 max_to_self_delay, struct amount_msat min_effective_htlc_capacity_msat, const struct per_peer_state *pps, const struct basepoints *our_basepoints, const struct pubkey *our_funding_pubkey, u32 minimum_depth, u32 min_feerate, u32 max_feerate, const u8 *msg)
|
||||
u8 *towire_dualopend_init(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_feature_set, const u8 *their_init_features, const struct channel_config *our_config, u32 max_to_self_delay, struct amount_msat min_effective_htlc_capacity_msat, const struct per_peer_state *pps, const struct basepoints *our_basepoints, const struct pubkey *our_funding_pubkey, u32 minimum_depth, const u8 *msg)
|
||||
{
|
||||
u16 their_init_features_len = tal_count(their_init_features);
|
||||
u16 len = tal_count(msg);
|
||||
@ -113,15 +113,13 @@ u8 *towire_dualopend_init(const tal_t *ctx, const struct chainparams *chainparam
|
||||
towire_pubkey(&p, our_funding_pubkey);
|
||||
/* Constraints in case the other end tries to open a channel. */
|
||||
towire_u32(&p, minimum_depth);
|
||||
towire_u32(&p, min_feerate);
|
||||
towire_u32(&p, max_feerate);
|
||||
/* Optional msg to send. */
|
||||
towire_u16(&p, len);
|
||||
towire_u8_array(&p, msg, len);
|
||||
|
||||
return memcheck(p, tal_count(p));
|
||||
}
|
||||
bool fromwire_dualopend_init(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_feature_set, u8 **their_init_features, struct channel_config *our_config, u32 *max_to_self_delay, struct amount_msat *min_effective_htlc_capacity_msat, struct per_peer_state **pps, struct basepoints *our_basepoints, struct pubkey *our_funding_pubkey, u32 *minimum_depth, u32 *min_feerate, u32 *max_feerate, u8 **msg)
|
||||
bool fromwire_dualopend_init(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_feature_set, u8 **their_init_features, struct channel_config *our_config, u32 *max_to_self_delay, struct amount_msat *min_effective_htlc_capacity_msat, struct per_peer_state **pps, struct basepoints *our_basepoints, struct pubkey *our_funding_pubkey, u32 *minimum_depth, u8 **msg)
|
||||
{
|
||||
u16 their_init_features_len;
|
||||
u16 len;
|
||||
@ -148,8 +146,6 @@ bool fromwire_dualopend_init(const tal_t *ctx, const void *p, const struct chain
|
||||
fromwire_pubkey(&cursor, &plen, our_funding_pubkey);
|
||||
/* Constraints in case the other end tries to open a channel. */
|
||||
*minimum_depth = fromwire_u32(&cursor, &plen);
|
||||
*min_feerate = fromwire_u32(&cursor, &plen);
|
||||
*max_feerate = fromwire_u32(&cursor, &plen);
|
||||
/* Optional msg to send. */
|
||||
len = fromwire_u16(&cursor, &plen);
|
||||
// 2nd case msg
|
||||
@ -160,7 +156,7 @@ bool fromwire_dualopend_init(const tal_t *ctx, const void *p, const struct chain
|
||||
|
||||
/* WIRE: DUALOPEND_REINIT */
|
||||
/* master-dualopend: peer has reconnected */
|
||||
u8 *towire_dualopend_reinit(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_feature_set, const u8 *their_init_features, const struct channel_config *our_config, const struct channel_config *their_config, const struct channel_id *channel_id, u32 max_to_self_delay, struct amount_msat min_effective_htlc_capacity_msat, const struct per_peer_state *pps, const struct basepoints *our_basepoints, const struct pubkey *our_funding_pubkey, const struct pubkey *their_funding_pubkey, u32 minimum_depth, u32 min_feerate, u32 max_feerate, const struct bitcoin_txid *funding_txid, u16 funding_txout, u32 orignal_feerate_per_kw_funding, u32 most_recent_feerate_per_kw_funding, struct amount_sat funding_satoshi, struct amount_msat our_funding, const struct basepoints *their_basepoints, const struct pubkey *remote_per_commit, const struct wally_psbt *funding_psbt, enum side opener, bool local_funding_locked, bool remote_funding_locked, bool send_shutdown, bool remote_shutdown_received, const u8 *local_shutdown_scriptpubkey, const u8 *remote_shutdown_scriptpubkey, bool remote_funding_sigs_received, const struct fee_states *fee_states, u8 channel_flags, const u8 *msg)
|
||||
u8 *towire_dualopend_reinit(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_feature_set, const u8 *their_init_features, const struct channel_config *our_config, const struct channel_config *their_config, const struct channel_id *channel_id, u32 max_to_self_delay, struct amount_msat min_effective_htlc_capacity_msat, const struct per_peer_state *pps, const struct basepoints *our_basepoints, const struct pubkey *our_funding_pubkey, const struct pubkey *their_funding_pubkey, u32 minimum_depth, const struct bitcoin_txid *funding_txid, u16 funding_txout, u32 orignal_feerate_per_kw_funding, u32 most_recent_feerate_per_kw_funding, struct amount_sat funding_satoshi, struct amount_msat our_funding, const struct basepoints *their_basepoints, const struct pubkey *remote_per_commit, const struct wally_psbt *funding_psbt, enum side opener, bool local_funding_locked, bool remote_funding_locked, bool send_shutdown, bool remote_shutdown_received, const u8 *local_shutdown_scriptpubkey, const u8 *remote_shutdown_scriptpubkey, bool remote_funding_sigs_received, const struct fee_states *fee_states, u8 channel_flags, const u8 *msg)
|
||||
{
|
||||
u16 their_init_features_len = tal_count(their_init_features);
|
||||
u16 local_shutdown_len = tal_count(local_shutdown_scriptpubkey);
|
||||
@ -183,8 +179,6 @@ u8 *towire_dualopend_reinit(const tal_t *ctx, const struct chainparams *chainpar
|
||||
towire_pubkey(&p, our_funding_pubkey);
|
||||
towire_pubkey(&p, their_funding_pubkey);
|
||||
towire_u32(&p, minimum_depth);
|
||||
towire_u32(&p, min_feerate);
|
||||
towire_u32(&p, max_feerate);
|
||||
towire_bitcoin_txid(&p, funding_txid);
|
||||
towire_u16(&p, funding_txout);
|
||||
towire_u32(&p, orignal_feerate_per_kw_funding);
|
||||
@ -212,7 +206,7 @@ u8 *towire_dualopend_reinit(const tal_t *ctx, const struct chainparams *chainpar
|
||||
|
||||
return memcheck(p, tal_count(p));
|
||||
}
|
||||
bool fromwire_dualopend_reinit(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_feature_set, u8 **their_init_features, struct channel_config *our_config, struct channel_config *their_config, struct channel_id *channel_id, u32 *max_to_self_delay, struct amount_msat *min_effective_htlc_capacity_msat, struct per_peer_state **pps, struct basepoints *our_basepoints, struct pubkey *our_funding_pubkey, struct pubkey *their_funding_pubkey, u32 *minimum_depth, u32 *min_feerate, u32 *max_feerate, struct bitcoin_txid *funding_txid, u16 *funding_txout, u32 *orignal_feerate_per_kw_funding, u32 *most_recent_feerate_per_kw_funding, struct amount_sat *funding_satoshi, struct amount_msat *our_funding, struct basepoints *their_basepoints, struct pubkey *remote_per_commit, struct wally_psbt **funding_psbt, enum side *opener, bool *local_funding_locked, bool *remote_funding_locked, bool *send_shutdown, bool *remote_shutdown_received, u8 **local_shutdown_scriptpubkey, u8 **remote_shutdown_scriptpubkey, bool *remote_funding_sigs_received, struct fee_states **fee_states, u8 *channel_flags, u8 **msg)
|
||||
bool fromwire_dualopend_reinit(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_feature_set, u8 **their_init_features, struct channel_config *our_config, struct channel_config *their_config, struct channel_id *channel_id, u32 *max_to_self_delay, struct amount_msat *min_effective_htlc_capacity_msat, struct per_peer_state **pps, struct basepoints *our_basepoints, struct pubkey *our_funding_pubkey, struct pubkey *their_funding_pubkey, u32 *minimum_depth, struct bitcoin_txid *funding_txid, u16 *funding_txout, u32 *orignal_feerate_per_kw_funding, u32 *most_recent_feerate_per_kw_funding, struct amount_sat *funding_satoshi, struct amount_msat *our_funding, struct basepoints *their_basepoints, struct pubkey *remote_per_commit, struct wally_psbt **funding_psbt, enum side *opener, bool *local_funding_locked, bool *remote_funding_locked, bool *send_shutdown, bool *remote_shutdown_received, u8 **local_shutdown_scriptpubkey, u8 **remote_shutdown_scriptpubkey, bool *remote_funding_sigs_received, struct fee_states **fee_states, u8 *channel_flags, u8 **msg)
|
||||
{
|
||||
u16 their_init_features_len;
|
||||
u16 local_shutdown_len;
|
||||
@ -240,8 +234,6 @@ bool fromwire_dualopend_reinit(const tal_t *ctx, const void *p, const struct cha
|
||||
fromwire_pubkey(&cursor, &plen, our_funding_pubkey);
|
||||
fromwire_pubkey(&cursor, &plen, their_funding_pubkey);
|
||||
*minimum_depth = fromwire_u32(&cursor, &plen);
|
||||
*min_feerate = fromwire_u32(&cursor, &plen);
|
||||
*max_feerate = fromwire_u32(&cursor, &plen);
|
||||
fromwire_bitcoin_txid(&cursor, &plen, funding_txid);
|
||||
*funding_txout = fromwire_u16(&cursor, &plen);
|
||||
*orignal_feerate_per_kw_funding = fromwire_u32(&cursor, &plen);
|
||||
@ -277,7 +269,7 @@ bool fromwire_dualopend_reinit(const tal_t *ctx, const void *p, const struct cha
|
||||
|
||||
/* WIRE: DUALOPEND_GOT_OFFER */
|
||||
/* dualopend->master: they offered channel */
|
||||
u8 *towire_dualopend_got_offer(const tal_t *ctx, const struct channel_id *channel_id, struct amount_sat opener_funding, struct amount_sat dust_limit_satoshis, struct amount_msat max_htlc_value_in_flight_msat, struct amount_msat htlc_minimum_msat, u32 feerate_funding_max, u32 feerate_funding_min, u32 feerate_funding_best, u32 feerate_per_kw, u16 to_self_delay, u16 max_accepted_htlcs, u8 channel_flags, u32 locktime, const u8 *shutdown_scriptpubkey)
|
||||
u8 *towire_dualopend_got_offer(const tal_t *ctx, const struct channel_id *channel_id, struct amount_sat opener_funding, struct amount_sat dust_limit_satoshis, struct amount_msat max_htlc_value_in_flight_msat, struct amount_msat htlc_minimum_msat, u32 feerate_per_kw_funding, u32 feerate_per_kw_commitment, u16 to_self_delay, u16 max_accepted_htlcs, u8 channel_flags, u32 locktime, const u8 *shutdown_scriptpubkey)
|
||||
{
|
||||
u16 shutdown_len = tal_count(shutdown_scriptpubkey);
|
||||
u8 *p = tal_arr(ctx, u8, 0);
|
||||
@ -288,10 +280,8 @@ u8 *towire_dualopend_got_offer(const tal_t *ctx, const struct channel_id *channe
|
||||
towire_amount_sat(&p, dust_limit_satoshis);
|
||||
towire_amount_msat(&p, max_htlc_value_in_flight_msat);
|
||||
towire_amount_msat(&p, htlc_minimum_msat);
|
||||
towire_u32(&p, feerate_funding_max);
|
||||
towire_u32(&p, feerate_funding_min);
|
||||
towire_u32(&p, feerate_funding_best);
|
||||
towire_u32(&p, feerate_per_kw);
|
||||
towire_u32(&p, feerate_per_kw_funding);
|
||||
towire_u32(&p, feerate_per_kw_commitment);
|
||||
towire_u16(&p, to_self_delay);
|
||||
towire_u16(&p, max_accepted_htlcs);
|
||||
towire_u8(&p, channel_flags);
|
||||
@ -301,7 +291,7 @@ u8 *towire_dualopend_got_offer(const tal_t *ctx, const struct channel_id *channe
|
||||
|
||||
return memcheck(p, tal_count(p));
|
||||
}
|
||||
bool fromwire_dualopend_got_offer(const tal_t *ctx, const void *p, struct channel_id *channel_id, struct amount_sat *opener_funding, struct amount_sat *dust_limit_satoshis, struct amount_msat *max_htlc_value_in_flight_msat, struct amount_msat *htlc_minimum_msat, u32 *feerate_funding_max, u32 *feerate_funding_min, u32 *feerate_funding_best, u32 *feerate_per_kw, u16 *to_self_delay, u16 *max_accepted_htlcs, u8 *channel_flags, u32 *locktime, u8 **shutdown_scriptpubkey)
|
||||
bool fromwire_dualopend_got_offer(const tal_t *ctx, const void *p, struct channel_id *channel_id, struct amount_sat *opener_funding, struct amount_sat *dust_limit_satoshis, struct amount_msat *max_htlc_value_in_flight_msat, struct amount_msat *htlc_minimum_msat, u32 *feerate_per_kw_funding, u32 *feerate_per_kw_commitment, u16 *to_self_delay, u16 *max_accepted_htlcs, u8 *channel_flags, u32 *locktime, u8 **shutdown_scriptpubkey)
|
||||
{
|
||||
u16 shutdown_len;
|
||||
|
||||
@ -315,10 +305,8 @@ bool fromwire_dualopend_got_offer(const tal_t *ctx, const void *p, struct channe
|
||||
*dust_limit_satoshis = fromwire_amount_sat(&cursor, &plen);
|
||||
*max_htlc_value_in_flight_msat = fromwire_amount_msat(&cursor, &plen);
|
||||
*htlc_minimum_msat = fromwire_amount_msat(&cursor, &plen);
|
||||
*feerate_funding_max = fromwire_u32(&cursor, &plen);
|
||||
*feerate_funding_min = fromwire_u32(&cursor, &plen);
|
||||
*feerate_funding_best = fromwire_u32(&cursor, &plen);
|
||||
*feerate_per_kw = fromwire_u32(&cursor, &plen);
|
||||
*feerate_per_kw_funding = fromwire_u32(&cursor, &plen);
|
||||
*feerate_per_kw_commitment = fromwire_u32(&cursor, &plen);
|
||||
*to_self_delay = fromwire_u16(&cursor, &plen);
|
||||
*max_accepted_htlcs = fromwire_u16(&cursor, &plen);
|
||||
*channel_flags = fromwire_u8(&cursor, &plen);
|
||||
@ -332,21 +320,20 @@ bool fromwire_dualopend_got_offer(const tal_t *ctx, const void *p, struct channe
|
||||
|
||||
/* WIRE: DUALOPEND_GOT_OFFER_REPLY */
|
||||
/* master->dualopend: reply back with our first funding info/contribs */
|
||||
u8 *towire_dualopend_got_offer_reply(const tal_t *ctx, struct amount_sat accepter_funding, u32 feerate_funding, const struct wally_psbt *psbt, const u8 *our_shutdown_scriptpubkey)
|
||||
u8 *towire_dualopend_got_offer_reply(const tal_t *ctx, struct amount_sat accepter_funding, const struct wally_psbt *psbt, const u8 *our_shutdown_scriptpubkey)
|
||||
{
|
||||
u16 shutdown_len = tal_count(our_shutdown_scriptpubkey);
|
||||
u8 *p = tal_arr(ctx, u8, 0);
|
||||
|
||||
towire_u16(&p, WIRE_DUALOPEND_GOT_OFFER_REPLY);
|
||||
towire_amount_sat(&p, accepter_funding);
|
||||
towire_u32(&p, feerate_funding);
|
||||
towire_wally_psbt(&p, psbt);
|
||||
towire_u16(&p, shutdown_len);
|
||||
towire_u8_array(&p, our_shutdown_scriptpubkey, shutdown_len);
|
||||
|
||||
return memcheck(p, tal_count(p));
|
||||
}
|
||||
bool fromwire_dualopend_got_offer_reply(const tal_t *ctx, const void *p, struct amount_sat *accepter_funding, u32 *feerate_funding, struct wally_psbt **psbt, u8 **our_shutdown_scriptpubkey)
|
||||
bool fromwire_dualopend_got_offer_reply(const tal_t *ctx, const void *p, struct amount_sat *accepter_funding, struct wally_psbt **psbt, u8 **our_shutdown_scriptpubkey)
|
||||
{
|
||||
u16 shutdown_len;
|
||||
|
||||
@ -356,7 +343,6 @@ bool fromwire_dualopend_got_offer_reply(const tal_t *ctx, const void *p, struct
|
||||
if (fromwire_u16(&cursor, &plen) != WIRE_DUALOPEND_GOT_OFFER_REPLY)
|
||||
return false;
|
||||
*accepter_funding = fromwire_amount_sat(&cursor, &plen);
|
||||
*feerate_funding = fromwire_u32(&cursor, &plen);
|
||||
*psbt = fromwire_wally_psbt(ctx, &cursor, &plen);
|
||||
shutdown_len = fromwire_u16(&cursor, &plen);
|
||||
// 2nd case our_shutdown_scriptpubkey
|
||||
@ -946,4 +932,4 @@ bool fromwire_dualopend_dev_memleak_reply(const void *p, bool *leak)
|
||||
*leak = fromwire_bool(&cursor, &plen);
|
||||
return cursor != NULL;
|
||||
}
|
||||
// SHA256STAMP:407d42d23a8c3b4526b63fdbb572a1d8e75b4e7e390e13af018e289e5ac857cd
|
||||
// SHA256STAMP:b93c5d3aad8cc2f256ed1205341ff68ea34d5bfc4a0d05071a8fe28177186bc5
|
||||
|
18
openingd/dualopend_wiregen.h
generated
18
openingd/dualopend_wiregen.h
generated
@ -86,23 +86,23 @@ bool dualopend_wire_is_defined(u16 type);
|
||||
|
||||
|
||||
/* WIRE: DUALOPEND_INIT */
|
||||
u8 *towire_dualopend_init(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_feature_set, const u8 *their_init_features, const struct channel_config *our_config, u32 max_to_self_delay, struct amount_msat min_effective_htlc_capacity_msat, const struct per_peer_state *pps, const struct basepoints *our_basepoints, const struct pubkey *our_funding_pubkey, u32 minimum_depth, u32 min_feerate, u32 max_feerate, const u8 *msg);
|
||||
bool fromwire_dualopend_init(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_feature_set, u8 **their_init_features, struct channel_config *our_config, u32 *max_to_self_delay, struct amount_msat *min_effective_htlc_capacity_msat, struct per_peer_state **pps, struct basepoints *our_basepoints, struct pubkey *our_funding_pubkey, u32 *minimum_depth, u32 *min_feerate, u32 *max_feerate, u8 **msg);
|
||||
u8 *towire_dualopend_init(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_feature_set, const u8 *their_init_features, const struct channel_config *our_config, u32 max_to_self_delay, struct amount_msat min_effective_htlc_capacity_msat, const struct per_peer_state *pps, const struct basepoints *our_basepoints, const struct pubkey *our_funding_pubkey, u32 minimum_depth, const u8 *msg);
|
||||
bool fromwire_dualopend_init(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_feature_set, u8 **their_init_features, struct channel_config *our_config, u32 *max_to_self_delay, struct amount_msat *min_effective_htlc_capacity_msat, struct per_peer_state **pps, struct basepoints *our_basepoints, struct pubkey *our_funding_pubkey, u32 *minimum_depth, u8 **msg);
|
||||
|
||||
/* WIRE: DUALOPEND_REINIT */
|
||||
/* master-dualopend: peer has reconnected */
|
||||
u8 *towire_dualopend_reinit(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_feature_set, const u8 *their_init_features, const struct channel_config *our_config, const struct channel_config *their_config, const struct channel_id *channel_id, u32 max_to_self_delay, struct amount_msat min_effective_htlc_capacity_msat, const struct per_peer_state *pps, const struct basepoints *our_basepoints, const struct pubkey *our_funding_pubkey, const struct pubkey *their_funding_pubkey, u32 minimum_depth, u32 min_feerate, u32 max_feerate, const struct bitcoin_txid *funding_txid, u16 funding_txout, u32 orignal_feerate_per_kw_funding, u32 most_recent_feerate_per_kw_funding, struct amount_sat funding_satoshi, struct amount_msat our_funding, const struct basepoints *their_basepoints, const struct pubkey *remote_per_commit, const struct wally_psbt *funding_psbt, enum side opener, bool local_funding_locked, bool remote_funding_locked, bool send_shutdown, bool remote_shutdown_received, const u8 *local_shutdown_scriptpubkey, const u8 *remote_shutdown_scriptpubkey, bool remote_funding_sigs_received, const struct fee_states *fee_states, u8 channel_flags, const u8 *msg);
|
||||
bool fromwire_dualopend_reinit(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_feature_set, u8 **their_init_features, struct channel_config *our_config, struct channel_config *their_config, struct channel_id *channel_id, u32 *max_to_self_delay, struct amount_msat *min_effective_htlc_capacity_msat, struct per_peer_state **pps, struct basepoints *our_basepoints, struct pubkey *our_funding_pubkey, struct pubkey *their_funding_pubkey, u32 *minimum_depth, u32 *min_feerate, u32 *max_feerate, struct bitcoin_txid *funding_txid, u16 *funding_txout, u32 *orignal_feerate_per_kw_funding, u32 *most_recent_feerate_per_kw_funding, struct amount_sat *funding_satoshi, struct amount_msat *our_funding, struct basepoints *their_basepoints, struct pubkey *remote_per_commit, struct wally_psbt **funding_psbt, enum side *opener, bool *local_funding_locked, bool *remote_funding_locked, bool *send_shutdown, bool *remote_shutdown_received, u8 **local_shutdown_scriptpubkey, u8 **remote_shutdown_scriptpubkey, bool *remote_funding_sigs_received, struct fee_states **fee_states, u8 *channel_flags, u8 **msg);
|
||||
u8 *towire_dualopend_reinit(const tal_t *ctx, const struct chainparams *chainparams, const struct feature_set *our_feature_set, const u8 *their_init_features, const struct channel_config *our_config, const struct channel_config *their_config, const struct channel_id *channel_id, u32 max_to_self_delay, struct amount_msat min_effective_htlc_capacity_msat, const struct per_peer_state *pps, const struct basepoints *our_basepoints, const struct pubkey *our_funding_pubkey, const struct pubkey *their_funding_pubkey, u32 minimum_depth, const struct bitcoin_txid *funding_txid, u16 funding_txout, u32 orignal_feerate_per_kw_funding, u32 most_recent_feerate_per_kw_funding, struct amount_sat funding_satoshi, struct amount_msat our_funding, const struct basepoints *their_basepoints, const struct pubkey *remote_per_commit, const struct wally_psbt *funding_psbt, enum side opener, bool local_funding_locked, bool remote_funding_locked, bool send_shutdown, bool remote_shutdown_received, const u8 *local_shutdown_scriptpubkey, const u8 *remote_shutdown_scriptpubkey, bool remote_funding_sigs_received, const struct fee_states *fee_states, u8 channel_flags, const u8 *msg);
|
||||
bool fromwire_dualopend_reinit(const tal_t *ctx, const void *p, const struct chainparams **chainparams, struct feature_set **our_feature_set, u8 **their_init_features, struct channel_config *our_config, struct channel_config *their_config, struct channel_id *channel_id, u32 *max_to_self_delay, struct amount_msat *min_effective_htlc_capacity_msat, struct per_peer_state **pps, struct basepoints *our_basepoints, struct pubkey *our_funding_pubkey, struct pubkey *their_funding_pubkey, u32 *minimum_depth, struct bitcoin_txid *funding_txid, u16 *funding_txout, u32 *orignal_feerate_per_kw_funding, u32 *most_recent_feerate_per_kw_funding, struct amount_sat *funding_satoshi, struct amount_msat *our_funding, struct basepoints *their_basepoints, struct pubkey *remote_per_commit, struct wally_psbt **funding_psbt, enum side *opener, bool *local_funding_locked, bool *remote_funding_locked, bool *send_shutdown, bool *remote_shutdown_received, u8 **local_shutdown_scriptpubkey, u8 **remote_shutdown_scriptpubkey, bool *remote_funding_sigs_received, struct fee_states **fee_states, u8 *channel_flags, u8 **msg);
|
||||
|
||||
/* WIRE: DUALOPEND_GOT_OFFER */
|
||||
/* dualopend->master: they offered channel */
|
||||
u8 *towire_dualopend_got_offer(const tal_t *ctx, const struct channel_id *channel_id, struct amount_sat opener_funding, struct amount_sat dust_limit_satoshis, struct amount_msat max_htlc_value_in_flight_msat, struct amount_msat htlc_minimum_msat, u32 feerate_funding_max, u32 feerate_funding_min, u32 feerate_funding_best, u32 feerate_per_kw, u16 to_self_delay, u16 max_accepted_htlcs, u8 channel_flags, u32 locktime, const u8 *shutdown_scriptpubkey);
|
||||
bool fromwire_dualopend_got_offer(const tal_t *ctx, const void *p, struct channel_id *channel_id, struct amount_sat *opener_funding, struct amount_sat *dust_limit_satoshis, struct amount_msat *max_htlc_value_in_flight_msat, struct amount_msat *htlc_minimum_msat, u32 *feerate_funding_max, u32 *feerate_funding_min, u32 *feerate_funding_best, u32 *feerate_per_kw, u16 *to_self_delay, u16 *max_accepted_htlcs, u8 *channel_flags, u32 *locktime, u8 **shutdown_scriptpubkey);
|
||||
u8 *towire_dualopend_got_offer(const tal_t *ctx, const struct channel_id *channel_id, struct amount_sat opener_funding, struct amount_sat dust_limit_satoshis, struct amount_msat max_htlc_value_in_flight_msat, struct amount_msat htlc_minimum_msat, u32 feerate_per_kw_funding, u32 feerate_per_kw_commitment, u16 to_self_delay, u16 max_accepted_htlcs, u8 channel_flags, u32 locktime, const u8 *shutdown_scriptpubkey);
|
||||
bool fromwire_dualopend_got_offer(const tal_t *ctx, const void *p, struct channel_id *channel_id, struct amount_sat *opener_funding, struct amount_sat *dust_limit_satoshis, struct amount_msat *max_htlc_value_in_flight_msat, struct amount_msat *htlc_minimum_msat, u32 *feerate_per_kw_funding, u32 *feerate_per_kw_commitment, u16 *to_self_delay, u16 *max_accepted_htlcs, u8 *channel_flags, u32 *locktime, u8 **shutdown_scriptpubkey);
|
||||
|
||||
/* WIRE: DUALOPEND_GOT_OFFER_REPLY */
|
||||
/* master->dualopend: reply back with our first funding info/contribs */
|
||||
u8 *towire_dualopend_got_offer_reply(const tal_t *ctx, struct amount_sat accepter_funding, u32 feerate_funding, const struct wally_psbt *psbt, const u8 *our_shutdown_scriptpubkey);
|
||||
bool fromwire_dualopend_got_offer_reply(const tal_t *ctx, const void *p, struct amount_sat *accepter_funding, u32 *feerate_funding, struct wally_psbt **psbt, u8 **our_shutdown_scriptpubkey);
|
||||
u8 *towire_dualopend_got_offer_reply(const tal_t *ctx, struct amount_sat accepter_funding, const struct wally_psbt *psbt, const u8 *our_shutdown_scriptpubkey);
|
||||
bool fromwire_dualopend_got_offer_reply(const tal_t *ctx, const void *p, struct amount_sat *accepter_funding, struct wally_psbt **psbt, u8 **our_shutdown_scriptpubkey);
|
||||
|
||||
/* WIRE: DUALOPEND_GOT_RBF_OFFER */
|
||||
/* dualopend->master: they offered a RBF */
|
||||
@ -216,4 +216,4 @@ bool fromwire_dualopend_dev_memleak_reply(const void *p, bool *leak);
|
||||
|
||||
|
||||
#endif /* LIGHTNING_OPENINGD_DUALOPEND_WIREGEN_H */
|
||||
// SHA256STAMP:407d42d23a8c3b4526b63fdbb572a1d8e75b4e7e390e13af018e289e5ac857cd
|
||||
// SHA256STAMP:b93c5d3aad8cc2f256ed1205341ff68ea34d5bfc4a0d05071a8fe28177186bc5
|
||||
|
@ -741,7 +741,7 @@ perform_fundpsbt(struct multifundchannel_command *mfc)
|
||||
}
|
||||
|
||||
/* If we've got v2 opens, we need to use a min weight of 110. */
|
||||
/* BOLT-78de9a79b491ae9fb84b1fdb4546bacf642dce87 #2
|
||||
/* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #3:
|
||||
* The minimum witness weight for an input is 110.
|
||||
*/
|
||||
if (dest_count(mfc, OPEN_CHANNEL) > 0) {
|
||||
|
@ -13,20 +13,6 @@ from wallycore import (
|
||||
plugin = Plugin()
|
||||
|
||||
|
||||
def find_feerate(best, their_min, their_max, our_min, our_max):
|
||||
if best >= our_min and best <= our_max:
|
||||
return best
|
||||
|
||||
if their_max < our_min or their_min > our_max:
|
||||
return False
|
||||
|
||||
if best < our_min:
|
||||
return our_min
|
||||
|
||||
# best > our_max:
|
||||
return our_max
|
||||
|
||||
|
||||
def find_inputs(b64_psbt):
|
||||
serial_id_key = bytes.fromhex('fc096c696768746e696e6701')
|
||||
psbt = psbt_from_base64(b64_psbt)
|
||||
@ -106,20 +92,18 @@ def on_openchannel(openchannel2, plugin, **kwargs):
|
||||
return {'result': 'continue'}
|
||||
|
||||
# ...unless they send us totally unacceptable feerates.
|
||||
feerate = find_feerate(openchannel2['funding_feerate_best'],
|
||||
openchannel2['funding_feerate_min'],
|
||||
openchannel2['funding_feerate_max'],
|
||||
openchannel2['feerate_our_min'],
|
||||
openchannel2['feerate_our_max'])
|
||||
proposed_feerate = openchannel2['funding_feerate_per_kw']
|
||||
our_min = openchannel2['feerate_our_min']
|
||||
our_max = openchannel2['feerate_our_max']
|
||||
|
||||
# Their feerate range is out of bounds, we're not going to
|
||||
# participate.
|
||||
if not feerate:
|
||||
plugin.log("Declining to fund, no feerate found.")
|
||||
if proposed_feerate > our_max or proposed_feerate < our_min:
|
||||
plugin.log("Declining to fund, feerate unacceptable.")
|
||||
return {'result': 'continue'}
|
||||
|
||||
funding = plugin.rpc.fundpsbt(int(amount.to_satoshi()),
|
||||
'{}perkw'.format(feerate),
|
||||
'{}perkw'.format(proposed_feerate),
|
||||
0, # because we're the accepter!!
|
||||
reserve=True,
|
||||
locktime=locktime,
|
||||
@ -128,11 +112,10 @@ def on_openchannel(openchannel2, plugin, **kwargs):
|
||||
excess_as_change=True)
|
||||
add_inflight(plugin, openchannel2['id'],
|
||||
openchannel2['channel_id'], funding['psbt'])
|
||||
plugin.log("contributing {} at feerate {}".format(amount, feerate))
|
||||
plugin.log("contributing {} at feerate {}".format(amount, proposed_feerate))
|
||||
|
||||
return {'result': 'continue', 'psbt': funding['psbt'],
|
||||
'accepter_funding_msat': amount,
|
||||
'funding_feerate': feerate}
|
||||
'accepter_funding_msat': amount}
|
||||
|
||||
|
||||
@plugin.hook('openchannel2_changed')
|
||||
|
@ -1,50 +0,0 @@
|
||||
--- wire/peer_exp_wire.csv 2020-09-16 20:59:05.170975876 -0500
|
||||
+++ - 2020-10-22 16:56:33.413063210 -0500
|
||||
@@ -33,7 +33,7 @@
|
||||
tlvdata,n2,tlv2,cltv_expiry,tu32,
|
||||
msgtype,tx_add_input,66
|
||||
msgdata,tx_add_input,channel_id,channel_id,
|
||||
-msgdata,tx_add_input,serial_id,u16,
|
||||
+msgdata,tx_add_input,serial_id,u64,
|
||||
msgdata,tx_add_input,prevtx_len,u16,
|
||||
msgdata,tx_add_input,prevtx,byte,prevtx_len
|
||||
msgdata,tx_add_input,prevtx_vout,u32,
|
||||
@@ -48,16 +48,16 @@
|
||||
msgdata,tx_add_input,script,byte,redeemscript_len
|
||||
msgtype,tx_add_output,67
|
||||
msgdata,tx_add_output,channel_id,channel_id,
|
||||
-msgdata,tx_add_output,serial_id,u16,
|
||||
+msgdata,tx_add_output,serial_id,u64,
|
||||
msgdata,tx_add_output,sats,u64,
|
||||
msgdata,tx_add_output,scriptlen,u16,
|
||||
msgdata,tx_add_output,script,byte,scriptlen
|
||||
msgtype,tx_remove_input,68
|
||||
msgdata,tx_remove_input,channel_id,channel_id,
|
||||
-msgdata,tx_remove_input,serial_id,u16,
|
||||
+msgdata,tx_remove_input,serial_id,u64,
|
||||
msgtype,tx_remove_output,69
|
||||
msgdata,tx_remove_output,channel_id,channel_id,
|
||||
-msgdata,tx_remove_output,serial_id,u16,
|
||||
+msgdata,tx_remove_output,serial_id,u64,
|
||||
msgtype,tx_complete,70
|
||||
msgdata,tx_complete,channel_id,channel_id,
|
||||
msgtype,tx_signatures,71
|
||||
@@ -125,7 +125,9 @@
|
||||
msgdata,funding_locked,next_per_commitment_point,point,
|
||||
msgtype,open_channel2,64
|
||||
msgdata,open_channel2,chain_hash,chain_hash,
|
||||
-msgdata,open_channel2,feerate_per_kw_funding,u32,
|
||||
+msgdata,open_channel2,feerate_funding_max,u32,
|
||||
+msgdata,open_channel2,feerate_funding_min,u32,
|
||||
+msgdata,open_channel2,feerate_funding_best,u32,
|
||||
msgdata,open_channel2,funding_satoshis,u64,
|
||||
msgdata,open_channel2,dust_limit_satoshis,u64,
|
||||
msgdata,open_channel2,max_htlc_value_in_flight_msat,u64,
|
||||
@@ -148,6 +150,7 @@
|
||||
msgtype,accept_channel2,65
|
||||
msgdata,accept_channel2,channel_id,channel_id,
|
||||
msgdata,accept_channel2,funding_satoshis,u64,
|
||||
+msgdata,accept_channel2,feerate_funding,u32,
|
||||
msgdata,accept_channel2,dust_limit_satoshis,u64,
|
||||
msgdata,accept_channel2,max_htlc_value_in_flight_msat,u64,
|
||||
msgdata,accept_channel2,htlc_minimum_msat,u64,
|
@ -1,30 +1,30 @@
|
||||
--- wire/extracted_peer_wire_csv 2020-07-28 12:36:12.063168014 -0500
|
||||
+++ - 2020-08-31 21:00:40.856646471 -0500
|
||||
@@ -31,6 +31,40 @@
|
||||
--- wire/peer_exp_wire.csv 2021-03-03 15:46:56.845901075 -0600
|
||||
+++ - 2021-03-03 15:48:50.342984083 -0600
|
||||
@@ -35,6 +31,40 @@
|
||||
tlvdata,n2,tlv1,amount_msat,tu64,
|
||||
tlvtype,n2,tlv2,11
|
||||
tlvdata,n2,tlv2,cltv_expiry,tu32,
|
||||
+msgtype,tx_add_input,66
|
||||
+msgdata,tx_add_input,channel_id,channel_id,
|
||||
+msgdata,tx_add_input,serial_id,u16,
|
||||
+msgdata,tx_add_input,serial_id,u64,
|
||||
+msgdata,tx_add_input,prevtx_len,u16,
|
||||
+msgdata,tx_add_input,prevtx,byte,prevtx_len
|
||||
+msgdata,tx_add_input,prevtx_vout,u32,
|
||||
+msgdata,tx_add_input,sequence,u32,
|
||||
+msgdata,tx_add_input,redeemscript_len,u16,
|
||||
+msgdata,tx_add_input,script,byte,redeemscript_len
|
||||
+msgdata,tx_add_input,script_sig_len,u16,
|
||||
+msgdata,tx_add_input,script_sig,byte,script_sig_len
|
||||
+msgtype,tx_add_output,67
|
||||
+msgdata,tx_add_output,channel_id,channel_id,
|
||||
+msgdata,tx_add_output,serial_id,u16,
|
||||
+msgdata,tx_add_output,serial_id,u64,
|
||||
+msgdata,tx_add_output,sats,u64,
|
||||
+msgdata,tx_add_output,scriptlen,u16,
|
||||
+msgdata,tx_add_output,script,byte,scriptlen
|
||||
+msgtype,tx_remove_input,68
|
||||
+msgdata,tx_remove_input,channel_id,channel_id,
|
||||
+msgdata,tx_remove_input,serial_id,u16,
|
||||
+msgdata,tx_remove_input,serial_id,u64,
|
||||
+msgtype,tx_remove_output,69
|
||||
+msgdata,tx_remove_output,channel_id,channel_id,
|
||||
+msgdata,tx_remove_output,serial_id,u16,
|
||||
+msgdata,tx_remove_output,serial_id,u64,
|
||||
+msgtype,tx_complete,70
|
||||
+msgdata,tx_complete,channel_id,channel_id,
|
||||
+msgtype,tx_signatures,71
|
||||
@ -41,18 +41,19 @@
|
||||
msgtype,open_channel,32
|
||||
msgdata,open_channel,chain_hash,chain_hash,
|
||||
msgdata,open_channel,temporary_channel_id,byte,32
|
||||
@@ -82,6 +122,53 @@
|
||||
@@ -86,6 +116,56 @@
|
||||
msgtype,funding_locked,36
|
||||
msgdata,funding_locked,channel_id,channel_id,
|
||||
msgdata,funding_locked,next_per_commitment_point,point,
|
||||
+msgtype,open_channel2,64
|
||||
+msgdata,open_channel2,chain_hash,chain_hash,
|
||||
+msgdata,open_channel2,feerate_per_kw_funding,u32,
|
||||
+msgdata,open_channel2,channel_id,channel_id,
|
||||
+msgdata,open_channel2,funding_feerate_perkw,u32,
|
||||
+msgdata,open_channel2,commitment_feerate_perkw,u32,
|
||||
+msgdata,open_channel2,funding_satoshis,u64,
|
||||
+msgdata,open_channel2,dust_limit_satoshis,u64,
|
||||
+msgdata,open_channel2,max_htlc_value_in_flight_msat,u64,
|
||||
+msgdata,open_channel2,htlc_minimum_msat,u64,
|
||||
+msgdata,open_channel2,feerate_per_kw,u32,
|
||||
+msgdata,open_channel2,to_self_delay,u16,
|
||||
+msgdata,open_channel2,max_accepted_htlcs,u16,
|
||||
+msgdata,open_channel2,locktime,u32,
|
||||
@ -63,7 +64,7 @@
|
||||
+msgdata,open_channel2,htlc_basepoint,point,
|
||||
+msgdata,open_channel2,first_per_commitment_point,point,
|
||||
+msgdata,open_channel2,channel_flags,byte,
|
||||
+msgdata,open_channel2,opening_tlv,opening_tlvs,
|
||||
+msgdata,open_channel2,tlvs,opening_tlvs,
|
||||
+tlvtype,opening_tlvs,option_upfront_shutdown_script,1
|
||||
+tlvdata,opening_tlvs,option_upfront_shutdown_script,shutdown_len,u16,
|
||||
+tlvdata,opening_tlvs,option_upfront_shutdown_script,shutdown_scriptpubkey,byte,shutdown_len
|
||||
@ -82,7 +83,7 @@
|
||||
+msgdata,accept_channel2,delayed_payment_basepoint,point,
|
||||
+msgdata,accept_channel2,htlc_basepoint,point,
|
||||
+msgdata,accept_channel2,first_per_commitment_point,point,
|
||||
+msgdata,accept_channel2,accept_tlv,accept_tlvs,
|
||||
+msgdata,accept_channel2,tlvs,accept_tlvs,
|
||||
+tlvtype,accept_tlvs,option_upfront_shutdown_script,1
|
||||
+tlvdata,accept_tlvs,option_upfront_shutdown_script,shutdown_len,u16,
|
||||
+tlvdata,accept_tlvs,option_upfront_shutdown_script,shutdown_scriptpubkey,byte,shutdown_len
|
||||
@ -90,8 +91,10 @@
|
||||
+msgdata,init_rbf,channel_id,channel_id,
|
||||
+msgdata,init_rbf,funding_satoshis,u64,
|
||||
+msgdata,init_rbf,locktime,u32,
|
||||
+msgdata,init_rbf,feerate_per_kw,u32,
|
||||
+msgdata,init_rbf,fee_step,byte,
|
||||
+msgtype,ack_rbf,73
|
||||
+msgdata,ack_rbf,channel_id,channel_id,
|
||||
+msgdata,ack_rbf,funding_satoshis,u64,
|
||||
msgtype,shutdown,38
|
||||
msgdata,shutdown,channel_id,channel_id,
|
||||
msgdata,shutdown,len,u16,
|
@ -1,10 +0,0 @@
|
||||
--- wire/peer_exp_wire.csv 2020-11-19 17:11:03.375890549 -0600
|
||||
+++ - 2020-12-10 15:56:19.617197279 -0600
|
||||
@@ -124,6 +124,7 @@
|
||||
msgdata,funding_locked,next_per_commitment_point,point,
|
||||
msgtype,open_channel2,64
|
||||
msgdata,open_channel2,chain_hash,chain_hash,
|
||||
+msgdata,open_channel2,temporary_channel_id,byte,32
|
||||
msgdata,open_channel2,feerate_funding_max,u32,
|
||||
msgdata,open_channel2,feerate_funding_min,u32,
|
||||
msgdata,open_channel2,feerate_funding_best,u32,
|
@ -1,14 +0,0 @@
|
||||
--- wire/peer_exp_wire.csv 2021-01-07 19:57:53.230947150 -0600
|
||||
+++ - 2021-01-08 15:17:40.600855619 -0600
|
||||
@@ -172,8 +172,10 @@
|
||||
msgdata,init_rbf,channel_id,channel_id,
|
||||
msgdata,init_rbf,funding_satoshis,u64,
|
||||
msgdata,init_rbf,locktime,u32,
|
||||
-msgdata,init_rbf,feerate_per_kw,u32,
|
||||
msgdata,init_rbf,fee_step,byte,
|
||||
+msgtype,ack_rbf,73
|
||||
+msgdata,ack_rbf,channel_id,channel_id,
|
||||
+msgdata,ack_rbf,funding_satoshis,u64,
|
||||
msgtype,shutdown,38
|
||||
msgdata,shutdown,channel_id,channel_id,
|
||||
msgdata,shutdown,len,u16,
|
Loading…
Reference in New Issue
Block a user