| 14 | } |
| 15 | |
| 16 | void 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 | |
| 42 | bool lease_rates_calc_fee(const struct lease_rates *rates, |
| 43 | struct amount_sat accept_funding_sats, |