From 13d879ea525f4145c70a71baf8b00eb70f40209c Mon Sep 17 00:00:00 2001 From: Shannon Appelcline Date: Thu, 25 May 2017 14:00:52 -0700 Subject: [PATCH] Update 8_1_Understanding_the_Foundation_of_P2SH.md --- 8_1_Understanding_the_Foundation_of_P2SH.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/8_1_Understanding_the_Foundation_of_P2SH.md b/8_1_Understanding_the_Foundation_of_P2SH.md index 1a45e64..f3d4f37 100644 --- a/8_1_Understanding_the_Foundation_of_P2SH.md +++ b/8_1_Understanding_the_Foundation_of_P2SH.md @@ -92,7 +92,7 @@ $ hex=$(printf '%08x\n' $integer | sed 's/^\(00\)*//') $ echo $hex 5c2a7b9f ``` -Third, you need to translate the hex from big-endian (least significant digital last) to little-endian (least significant digit first). You can do this with the `tac` command (or by hand if you prefer): +Third, you need to translate the hex from big-endian (least significant byte last) to little-endian (least significant byte first). You can do this with the `tac` command (or by hand if you prefer): ``` $ lehex=$(echo $hex | tac -rs .. | echo "$(tr -d '\n')") $ echo $lehex @@ -105,7 +105,7 @@ $ echo -n $lehex | wc -c | awk '{print $1/2}' ``` With that whole rigamarole, you'd know that you could translate the integer 1546288031 into an `04` opcode (to push four bytes onto the stack) followed by 9f7b2a5c (the little-endian hex representation of 1546288031). -If you instead had a negative number, you'd need to (1) do your calculations on the absolute value of the number, then (2) bitwise-| 0x80. For example, 9f7b2a5c, which is 1546288031, would become 9f7b2adc, which is -1546288031: +If you instead had a negative number, you'd need to (1) do your calculations on the absolute value of the number, then (2) bitwise-or 0x80. For example, 9f7b2a5c, which is 1546288031, would become 9f7b2adc, which is -1546288031: ``` $ neglehex=$(printf '%x\n' $((0x$lehex | 0x80))) $ echo $neglehex