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

Function unmask_commit_number

onchaind/onchaind.c:863–889  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

861}
862
863static u64 unmask_commit_number(const struct tx_parts *tx,
864 uint32_t locktime,
865 enum side opener,
866 const struct pubkey *local_payment_basepoint,
867 const struct pubkey *remote_payment_basepoint)
868{
869 u64 obscurer;
870 const struct pubkey *keys[NUM_SIDES];
871 keys[LOCAL] = local_payment_basepoint;
872 keys[REMOTE] = remote_payment_basepoint;
873
874 /* BOLT #3:
875 *
876 * The 48-bit commitment number is obscured by `XOR` with the lower 48 bits of...
877 */
878 obscurer = commit_number_obscurer(keys[opener], keys[!opener]);
879
880 /* BOLT #3:
881 *
882 * * locktime: upper 8 bits are 0x20, lower 24 bits are the lower 24 bits of the obscured commitment number
883 *...
884 * * `txin[0]` sequence: upper 8 bits are 0x80, lower 24 bits are upper 24 bits of the obscured commitment number
885 */
886 return ((locktime & 0x00FFFFFF)
887 | (tx->inputs[0]->sequence & (u64)0x00FFFFFF) << 24)
888 ^ obscurer;
889}
890
891static bool is_mutual_close(const struct tx_parts *tx,
892 uint32_t locktime,

Callers 1

mainFunction · 0.85

Calls 1

commit_number_obscurerFunction · 0.50

Tested by

no test coverage detected