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

Function unmask_commit_number

onchaind/onchaind.c:812–838  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

810}
811
812static u64 unmask_commit_number(const struct tx_parts *tx,
813 uint32_t locktime,
814 enum side opener,
815 const struct pubkey *local_payment_basepoint,
816 const struct pubkey *remote_payment_basepoint)
817{
818 u64 obscurer;
819 const struct pubkey *keys[NUM_SIDES];
820 keys[LOCAL] = local_payment_basepoint;
821 keys[REMOTE] = remote_payment_basepoint;
822
823 /* BOLT #3:
824 *
825 * The 48-bit commitment number is obscured by `XOR` with the lower 48 bits of...
826 */
827 obscurer = commit_number_obscurer(keys[opener], keys[!opener]);
828
829 /* BOLT #3:
830 *
831 * * locktime: upper 8 bits are 0x20, lower 24 bits are the lower 24 bits of the obscured commitment number
832 *...
833 * * `txin[0]` sequence: upper 8 bits are 0x80, lower 24 bits are upper 24 bits of the obscured commitment number
834 */
835 return ((locktime & 0x00FFFFFF)
836 | (tx->inputs[0]->sequence & (u64)0x00FFFFFF) << 24)
837 ^ obscurer;
838}
839
840static bool is_mutual_close(const struct tx_parts *tx,
841 const u8 *local_scriptpubkey,

Callers 1

mainFunction · 0.85

Calls 1

commit_number_obscurerFunction · 0.50

Tested by

no test coverage detected