mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
liquidity-ad: fill in acceptance response
Asks HSMD for signed lease termsheet, fills in the details to the accept_channel2 TLV
This commit is contained in:
parent
9ad40f2544
commit
334ec0084b
@ -2893,7 +2893,8 @@ static void start_fresh_dualopend(struct peer *peer,
|
|||||||
|
|
||||||
hsmfd = hsm_get_client_fd(peer->ld, &peer->id, channel->unsaved_dbid,
|
hsmfd = hsm_get_client_fd(peer->ld, &peer->id, channel->unsaved_dbid,
|
||||||
HSM_CAP_COMMITMENT_POINT
|
HSM_CAP_COMMITMENT_POINT
|
||||||
| HSM_CAP_SIGN_REMOTE_TX);
|
| HSM_CAP_SIGN_REMOTE_TX
|
||||||
|
| HSM_CAP_SIGN_WILL_FUND_OFFER);
|
||||||
|
|
||||||
channel->owner = new_channel_subd(peer->ld,
|
channel->owner = new_channel_subd(peer->ld,
|
||||||
"lightning_dualopend",
|
"lightning_dualopend",
|
||||||
@ -2959,7 +2960,8 @@ void peer_restart_dualopend(struct peer *peer,
|
|||||||
}
|
}
|
||||||
hsmfd = hsm_get_client_fd(peer->ld, &peer->id, channel->dbid,
|
hsmfd = hsm_get_client_fd(peer->ld, &peer->id, channel->dbid,
|
||||||
HSM_CAP_COMMITMENT_POINT
|
HSM_CAP_COMMITMENT_POINT
|
||||||
| HSM_CAP_SIGN_REMOTE_TX);
|
| HSM_CAP_SIGN_REMOTE_TX
|
||||||
|
| HSM_CAP_SIGN_WILL_FUND_OFFER);
|
||||||
|
|
||||||
channel_set_owner(channel,
|
channel_set_owner(channel,
|
||||||
new_channel_subd(peer->ld, "lightning_dualopend",
|
new_channel_subd(peer->ld, "lightning_dualopend",
|
||||||
|
@ -1904,6 +1904,51 @@ static u8 *accepter_commits(struct state *state,
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void accept_tlv_add_offer(struct tlv_accept_tlvs *a_tlv,
|
||||||
|
struct lease_rates *rates,
|
||||||
|
struct pubkey funding_pubkey,
|
||||||
|
u32 blockheight)
|
||||||
|
{
|
||||||
|
secp256k1_ecdsa_signature ad_sig;
|
||||||
|
u8 *msg;
|
||||||
|
|
||||||
|
/* Go get the signature for this lease offer from HSMD */
|
||||||
|
msg = towire_hsmd_sign_option_will_fund_offer(NULL,
|
||||||
|
&funding_pubkey,
|
||||||
|
blockheight,
|
||||||
|
rates->channel_fee_max_base_msat,
|
||||||
|
rates->channel_fee_max_proportional_thousandths);
|
||||||
|
if (!wire_sync_write(HSM_FD, take(msg)))
|
||||||
|
status_failed(STATUS_FAIL_HSM_IO,
|
||||||
|
"Could not write to HSM: %s",
|
||||||
|
strerror(errno));
|
||||||
|
msg = wire_sync_read(tmpctx, HSM_FD);
|
||||||
|
if (!fromwire_hsmd_sign_option_will_fund_offer_reply(msg, &ad_sig))
|
||||||
|
status_failed(STATUS_FAIL_HSM_IO,
|
||||||
|
"Bad sign_option_will_fund_offer_reply %s",
|
||||||
|
tal_hex(tmpctx, msg));
|
||||||
|
|
||||||
|
/* BOLT- #2:
|
||||||
|
* The accepting node:
|
||||||
|
* ...
|
||||||
|
* - MUST set `funding_fee_base_sat` to the base fee
|
||||||
|
* (in satoshi) it will charge for the `funding_satoshis`
|
||||||
|
* - MUST set `funding_fee_proportional_basis` to the amount
|
||||||
|
* (in thousandths of satoshi) it will charge per `funding_satoshi`
|
||||||
|
* - MUST set `funding_weight` to the weight they
|
||||||
|
* will contribute to this channel, to fund the request.
|
||||||
|
* - MUST set `channel_fee_base_max_msat` to the base fee
|
||||||
|
* (in millisatoshi) it will charge for any HTLC on this channel
|
||||||
|
* during the funding period.
|
||||||
|
* - MUST set `channel_fee_proportional_basis_max` to the amount
|
||||||
|
* (in thousandths of a satoshi) it will charge per transferred
|
||||||
|
* satoshi during the funding period.
|
||||||
|
*/
|
||||||
|
a_tlv->will_fund = tal(a_tlv, struct tlv_accept_tlvs_will_fund);
|
||||||
|
a_tlv->will_fund->lease_rates = *rates;
|
||||||
|
a_tlv->will_fund->signature = ad_sig;
|
||||||
|
}
|
||||||
|
|
||||||
static void accepter_start(struct state *state, const u8 *oc2_msg)
|
static void accepter_start(struct state *state, const u8 *oc2_msg)
|
||||||
{
|
{
|
||||||
struct bitcoin_blkid chain_hash;
|
struct bitcoin_blkid chain_hash;
|
||||||
@ -2128,6 +2173,18 @@ static void accepter_start(struct state *state, const u8 *oc2_msg)
|
|||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* BOLT- #2:
|
||||||
|
* The accepting node:
|
||||||
|
* ...
|
||||||
|
* - if the `option_will_fund` tlv was sent in `open_channel2`:
|
||||||
|
* - if they decide to accept the offer:
|
||||||
|
* - MUST include a `will_fund` tlv
|
||||||
|
*/
|
||||||
|
if (open_tlv->request_funds && tx_state->rates)
|
||||||
|
accept_tlv_add_offer(a_tlv, tx_state->rates,
|
||||||
|
state->our_funding_pubkey,
|
||||||
|
lease_blockheight_start);
|
||||||
|
|
||||||
msg = towire_accept_channel2(tmpctx, &state->channel_id,
|
msg = towire_accept_channel2(tmpctx, &state->channel_id,
|
||||||
tx_state->accepter_funding,
|
tx_state->accepter_funding,
|
||||||
tx_state->localconf.dust_limit,
|
tx_state->localconf.dust_limit,
|
||||||
|
Loading…
Reference in New Issue
Block a user