Bitcoin Stack Exchange is a question and answer site for Bitcoin crypto-currency enthusiasts. It only takes a minute to sign up.
Sign up to join this communityAnybody can ask a question
Anybody can answer
The best answers are voted up and rise to the top
Testnet transaction c474c67cabc13f74c65e7cf503db971d5ba176794bff7de36f46d51ca675cf3a
locked 0.0005BTC with a simple math script:
OP_2DUP OP_ADD 5102 OP_EQUALVERIFY OP_SUB 230d OP_EQUAL
Transaction b6714e05dd014cc92de09271886e62d85e7d41dd44fad417c520eb51d57f94c0
spent that output with the sigscript:
ba07 6985
I can't see how (ba07 + 6985) == 5102
or (ba07 - 6985) == 230d
.
What am I missing about Bitcoin script, integers, and math?
For mathematical operations, Bitcoin treats byte vectors as signed (signed magnitude) little endian values. So let's look what the numbers are then:
- The byte vector
ba07
is the hexadecimal number (0)7ba. - The byte vector
6985
is8569
in big endian. Since the highest bit is set the number is negative. So the hexadecimal number is -(0)569. - The byte vector
5102
is the hexadecimal number (0)251. - The byte vector
0d23
is the hexadecimal number (0)23d.
Therefore we end up with the two statements 7ba+(-569)=251
and 7ba-(-569)=d23
which are true.
You can get bonuses upto $100 FREE BONUS when you:
💰 Install these recommended apps:
💲 SocialGood - 100% Crypto Back on Everyday Shopping
💲 xPortal - The DeFi For The Next Billion
💲 CryptoTab Browser - Lightweight, fast, and ready to mine!
💰 Register on these recommended exchanges:
🟡 Binance🟡 Bitfinex🟡 Bitmart🟡 Bittrex🟡 Bitget
🟡 CoinEx🟡 Crypto.com🟡 Gate.io🟡 Huobi🟡 Kucoin.
Comments