Skip to content

Commit 03ad3b7

Browse files
committed
rebase fixes 2021-09-07
1 parent 25a5146 commit 03ad3b7

File tree

14 files changed

+395
-185
lines changed

14 files changed

+395
-185
lines changed

channeld/commit_tx.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ struct bitcoin_tx *commit_tx(const tal_t *ctx,
272272
* `dust_limit_satoshis`, add a [`to_remote`
273273
* output](#to_remote-output).
274274
*/
275+
const u8 *redeem = NULL;
275276
if (amount_msat_greater_eq_sat(other_pay, dust_limit)) {
276277
struct amount_sat amount = amount_msat_to_sat_round_down(other_pay);
277278
u8 *scriptpubkey;
@@ -290,11 +291,10 @@ struct bitcoin_tx *commit_tx(const tal_t *ctx,
290291
* Otherwise, this output is a simple P2WPKH to `remotepubkey`.
291292
*/
292293
if (option_anchor_outputs) {
293-
const u8 *redeem
294-
= anchor_to_remote_redeem(tmpctx,
295-
&keyset->other_payment_key,
296-
(!side) == lessor ?
297-
csv_lock : 1);
294+
redeem = anchor_to_remote_redeem(tmpctx,
295+
&keyset->other_payment_key,
296+
(!side) == lessor ?
297+
csv_lock : 1);
298298
/* BOLT- #3:
299299
* ##### Leased channel (`option_will_fund`)
300300
*
@@ -312,7 +312,7 @@ struct bitcoin_tx *commit_tx(const tal_t *ctx,
312312
scriptpubkey = scriptpubkey_p2wpkh(tmpctx,
313313
&keyset->other_payment_key);
314314
}
315-
pos = bitcoin_tx_add_output(tx, scriptpubkey, redeem, amount);
315+
pos = bitcoin_tx_add_output(tx, scriptpubkey, (u8 *) redeem, amount);
316316
assert(pos == n);
317317
(*htlcmap)[n] = direct_outputs ? dummy_to_remote : NULL;
318318
/* We don't assign cltvs[n]: if we use it, order doesn't matter.

closingd/closingd.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,9 @@ static size_t closing_tx_weight_estimate(u8 *scriptpubkey[NUM_SIDES],
508508
const u8 *funding_wscript,
509509
const struct amount_sat *out,
510510
struct amount_sat funding,
511-
struct amount_sat dust_limit)
511+
struct amount_sat dust_limit,
512+
u32 local_wallet_index,
513+
const struct ext_key *local_wallet_ext_key)
512514
{
513515
/* We create a dummy close */
514516
struct bitcoin_tx *tx;
@@ -520,6 +522,7 @@ static size_t closing_tx_weight_estimate(u8 *scriptpubkey[NUM_SIDES],
520522

521523
memset(&dummy_txid, 0, sizeof(dummy_txid));
522524
tx = create_close_tx(tmpctx, chainparams,
525+
local_wallet_index, local_wallet_ext_key,
523526
scriptpubkey[LOCAL], scriptpubkey[REMOTE],
524527
funding_wscript,
525528
&dummy_txid, 0,
@@ -623,7 +626,7 @@ int main(int argc, char *argv[])
623626
&out[LOCAL],
624627
&out[REMOTE],
625628
&our_dust_limit,
626-
&min_fee_to_accept, &initial_feerate,
629+
&min_feerate, &initial_feerate,
627630
&commitment_fee,
628631
&local_wallet_index,
629632
&local_wallet_ext_key,
@@ -645,7 +648,9 @@ int main(int argc, char *argv[])
645648
/* Start at what we consider a reasonable feerate for this tx. */
646649
calc_fee_bounds(closing_tx_weight_estimate(scriptpubkey,
647650
funding_wscript,
648-
out, funding, our_dust_limit),
651+
out, funding, our_dust_limit,
652+
local_wallet_index,
653+
&local_wallet_ext_key),
649654
min_feerate, initial_feerate, commitment_fee,
650655
&min_fee_to_accept, &offer[LOCAL]);
651656

closingd/closingd_wire.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ msgdata,closingd_init,our_dust_limit,amount_sat,
2121
msgdata,closingd_init,min_feerate_perksipa,u32,
2222
msgdata,closingd_init,preferred_feerate_perksipa,u32,
2323
msgdata,closingd_init,fee_limit_satoshi,amount_sat,
24-
msgdata,closingd_init,initial_fee_satoshi,amount_sat,
2524
msgdata,closingd_init,local_wallet_index,u32,
2625
msgdata,closingd_init,local_wallet_ext_key,ext_key,
2726
msgdata,closingd_init,local_scriptpubkey_len,u16,

closingd/closingd_wiregen.c

Lines changed: 7 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

closingd/closingd_wiregen.h

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/initial_commit_tx.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,19 +246,19 @@ struct bitcoin_tx *initial_commit_tx(const tal_t *ctx,
246246
*/
247247
u8 *scriptpubkey;
248248
int pos;
249+
const u8 *redeem = NULL;
249250

250251
amount = amount_msat_to_sat_round_down(other_pay);
251252
if (option_anchor_outputs) {
252-
const u8 *redeem
253-
= anchor_to_remote_redeem(tmpctx,
253+
redeem = anchor_to_remote_redeem(tmpctx,
254254
&keyset->other_payment_key,
255255
(!side) == lessor ? csv_lock : 1);
256256
scriptpubkey = scriptpubkey_p2wsh(tmpctx, redeem);
257257
} else {
258258
scriptpubkey = scriptpubkey_p2wpkh(tmpctx,
259259
&keyset->other_payment_key);
260260
}
261-
pos = bitcoin_tx_add_output(tx, scriptpubkey, redeem, amount);
261+
pos = bitcoin_tx_add_output(tx, scriptpubkey, (u8 *) redeem, amount);
262262
assert(pos == n);
263263
output_order[n] = dummy_remote;
264264
n++;

contrib/remote_hsmd/hsmd.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,6 +1581,28 @@ static struct io_plan *handle_sign_message(struct io_conn *conn,
15811581
take(towire_hsmd_sign_message_reply(NULL, &rsig)));
15821582
}
15831583

1584+
/*~ lightningd asks us to sign a liquidity ad offer */
1585+
static struct io_plan *handle_sign_option_will_fund_offer(struct io_conn *conn,
1586+
struct client *c,
1587+
const u8 *msg_in)
1588+
{
1589+
struct pubkey funding_pubkey;
1590+
u32 lease_expiry, channel_fee_base_max_msat;
1591+
u16 channel_fee_max_ppt;
1592+
1593+
if (!fromwire_hsmd_sign_option_will_fund_offer(msg_in,
1594+
&funding_pubkey,
1595+
&lease_expiry,
1596+
&channel_fee_base_max_msat,
1597+
&channel_fee_max_ppt))
1598+
return bad_req(conn, c, msg_in);
1599+
1600+
status_failed(STATUS_FAIL_INTERNAL_ERROR,
1601+
"handle_sign_option_will_fund_offer unimplemented");
1602+
return bad_req_fmt(conn, c, msg_in,
1603+
"handle_sign_option_will_fund_offer unimplemented");
1604+
}
1605+
15841606
/*~ lightningd asks us to sign a bolt12 (e.g. offer). */
15851607
static struct io_plan *handle_sign_bolt12(struct io_conn *conn,
15861608
struct client *c,
@@ -1676,6 +1698,9 @@ static bool check_client_capabilities(struct client *client,
16761698
case WIRE_HSMD_SIGN_MUTUAL_CLOSE_TX:
16771699
return (client->capabilities & HSM_CAP_SIGN_CLOSING_TX) != 0;
16781700

1701+
case WIRE_HSMD_SIGN_OPTION_WILL_FUND_OFFER:
1702+
return (client->capabilities & HSM_CAP_SIGN_WILL_FUND_OFFER) != 0;
1703+
16791704
case WIRE_HSMD_INIT:
16801705
case WIRE_HSMD_NEW_CHANNEL:
16811706
case WIRE_HSMD_CLIENT_HSMFD:
@@ -1707,6 +1732,7 @@ static bool check_client_capabilities(struct client *client,
17071732
case WIRE_HSMD_VALIDATE_COMMITMENT_TX_REPLY:
17081733
case WIRE_HSMD_VALIDATE_REVOCATION_REPLY:
17091734
case WIRE_HSMD_SIGN_TX_REPLY:
1735+
case WIRE_HSMD_SIGN_OPTION_WILL_FUND_OFFER_REPLY:
17101736
case WIRE_HSMD_GET_PER_COMMITMENT_POINT_REPLY:
17111737
case WIRE_HSMD_CHECK_FUTURE_SECRET_REPLY:
17121738
case WIRE_HSMD_GET_CHANNEL_BASEPOINTS_REPLY:
@@ -1818,6 +1844,9 @@ static struct io_plan *handle_client(struct io_conn *conn, struct client *c)
18181844
case WIRE_HSMD_SIGN_MESSAGE:
18191845
return handle_sign_message(conn, c, c->msg_in);
18201846

1847+
case WIRE_HSMD_SIGN_OPTION_WILL_FUND_OFFER:
1848+
return handle_sign_option_will_fund_offer(conn, c, c->msg_in);
1849+
18211850
case WIRE_HSMD_SIGN_BOLT12:
18221851
return handle_sign_bolt12(conn, c, c->msg_in);
18231852
#if DEVELOPER
@@ -1841,6 +1870,7 @@ static struct io_plan *handle_client(struct io_conn *conn, struct client *c)
18411870
case WIRE_HSMD_VALIDATE_COMMITMENT_TX_REPLY:
18421871
case WIRE_HSMD_VALIDATE_REVOCATION_REPLY:
18431872
case WIRE_HSMD_SIGN_TX_REPLY:
1873+
case WIRE_HSMD_SIGN_OPTION_WILL_FUND_OFFER_REPLY:
18441874
case WIRE_HSMD_GET_PER_COMMITMENT_POINT_REPLY:
18451875
case WIRE_HSMD_CHECK_FUTURE_SECRET_REPLY:
18461876
case WIRE_HSMD_GET_CHANNEL_BASEPOINTS_REPLY:

0 commit comments

Comments
 (0)