-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: OracleAttestationV0Pre167 calculation of deserializedBytes durin…
…g deserialization --wip-- [skip ci]
- Loading branch information
Maxime Suard
committed
Aug 25, 2023
1 parent
55e7831
commit 567d0e0
Showing
2 changed files
with
26 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// BigSize integers are deserialized using @node-lightning/bufio BufferReader.readBigSize() | ||
// Refer to https://github.com/node-lightning/node-lightning/blob/e9b349b200997b8c5e46751ae6eb13a283323f5b/packages/bufio/lib/BufferReader.ts#L194 | ||
|
||
/** | ||
* Extract the size of a deserialized bigSize integer | ||
* @param val | ||
* @returns The size in bytes of the value parameter | ||
*/ | ||
|
||
export const getBigSizeBytesLength = (val: bigint): number => { | ||
if (val < BigInt('0xfd')) return 1; | ||
if (val < BigInt('0x10000')) return 3; | ||
if (val < BigInt('0x100000000')) return 5; | ||
return 9; | ||
}; |