Merge pull request #5475 from dasrun-fadben/bitcoin-compact-size

bitcoin-utils: Fix parsing of of CompactSize integers
This commit is contained in:
Ted Blackman 2022-11-27 14:11:06 -06:00 committed by GitHub
commit 08c95f2b6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -143,6 +143,7 @@
|= a=@ |= a=@
^- hexb ^- hexb
=/ l=@ (met 3 a) =/ l=@ (met 3 a)
?: =(l 0) 1^a
?: =(l 1) 1^a ?: =(l 1) 1^a
?: =(l 2) (cat:byt ~[1^0xfd (flip:byt 2^a)]) ?: =(l 2) (cat:byt ~[1^0xfd (flip:byt 2^a)])
?: (lte l 4) (cat:byt ~[1^0xfe (flip:byt 4^a)]) ?: (lte l 4) (cat:byt ~[1^0xfe (flip:byt 4^a)])
@ -162,7 +163,7 @@
%0xfe 2 %0xfe 2
%0xff 3 %0xff 3
== ==
:_ (drop:byt (add 1 len) h) :_ (drop:byt (add 1 (bex len)) h)
%- flip:byt %- flip:byt
(take:byt (bex len) (drop:byt 1 h)) (take:byt (bex len) (drop:byt 1 h))
:: +dea: atom instead of hexb for parsed CompactSize :: +dea: atom instead of hexb for parsed CompactSize