MCPcopy Create free account
hub / github.com/ElementsProject/lightning / lease_rates_get_commitment

Function lease_rates_get_commitment

common/lease_rates.c:16–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14}
15
16void lease_rates_get_commitment(const struct pubkey *pubkey,
17 u32 lease_expiry,
18 u32 chan_fee_msat,
19 u16 chan_fee_ppt,
20 struct sha256 *sha)
21{
22 struct sha256_ctx sctx = SHA256_INIT;
23 u8 der[PUBKEY_CMPR_LEN];
24 /* BOLT- #2:
25 * - MUST set `signature` to the ECDSA signature of
26 * SHA256("option_will_fund"
27 * || `funding_pubkey`
28 * || `blockheight` + 4032
29 * || `channel_fee_max_base_msat`
30 * || `channel_fee_max_proportional_thousandths`)
31 * using the node_id key.
32 */
33 pubkey_to_der(der, pubkey);
34 sha256_update(&sctx, "option_will_fund", strlen("option_will_fund"));
35 sha256_update(&sctx, der, PUBKEY_CMPR_LEN);
36 sha256_be32(&sctx, lease_expiry);
37 sha256_be32(&sctx, chan_fee_msat);
38 sha256_be16(&sctx, chan_fee_ppt);
39 sha256_done(&sctx, sha);
40}
41
42bool lease_rates_calc_fee(const struct lease_rates *rates,
43 struct amount_sat accept_funding_sats,

Calls 5

sha256_updateFunction · 0.85
sha256_be32Function · 0.85
sha256_be16Function · 0.85
sha256_doneFunction · 0.85
pubkey_to_derFunction · 0.50

Tested by 1