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

Function derive_tmp_channel_id

common/channel_id.c:51–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51void derive_tmp_channel_id(struct channel_id *channel_id,
52 const struct pubkey *opener_basepoint)
53{
54 struct sha256 sha;
55
56 /* BOLT-f53ca2301232db780843e894f55d95d512f297f9 #2:
57 * If the peer's revocation basepoint is unknown
58 * (e.g. `open_channel2`), a temporary `channel_id` should be
59 * found by using a zeroed out basepoint for the unknown peer.
60 */
61 u8 der_keys[PUBKEY_CMPR_LEN * 2];
62 memset(der_keys, 0, PUBKEY_CMPR_LEN);
63 pubkey_to_der(der_keys + PUBKEY_CMPR_LEN, opener_basepoint);
64 sha256(&sha, der_keys, sizeof(der_keys));
65 BUILD_ASSERT(sizeof(*channel_id) == sizeof(sha));
66 memcpy(channel_id, &sha, sizeof(*channel_id));
67}
68
69/* BOLT #2:
70 *

Callers 4

json_openchannel_initFunction · 0.85
json_queryratesFunction · 0.85
accepter_startFunction · 0.85
opener_startFunction · 0.85

Calls 2

sha256Class · 0.70
pubkey_to_derFunction · 0.50

Tested by

no test coverage detected