Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: s.o. on April 22, 2018, 09:03:59 PM



Title: ....................
Post by: s.o. on April 22, 2018, 09:03:59 PM
.........................................


Title: Re: script.bin
Post by: jackg on April 22, 2018, 09:18:57 PM
The script?

It's the binary of the script as far as I can gather (the script is the field above).


Title: Re: script.bin
Post by: jackg on April 22, 2018, 10:08:02 PM
The script?

It's the binary of the script as far as I can gather (the script is the field above).


i mean this

v� H�' !�E l;O�q "��


well.. i have something like this and i want to convert it to base64..

how can i do it ?

You can't I don't think. As far as I know "�" is a wildcard that is used when a program can't understand stuff so that might make it impossible to convert it.

Where is your string stored that you want to convert, what is it? Can you send it me.

I can write a quick program to convert something like that if you're interested. You just need to convert every character to string and understand that every character takes up 128 bits and make a string from there.

For example, a simple string like ABC.
Would make A=65, B=66, C=67.
This could then be converted to a long string of:
01000001    01000010    01000011

This would apparently give a decimal value of: 4276803 ("apparently" - because I used an online converter instead).


Title: Re: script.bin
Post by: achow101 on April 22, 2018, 10:13:25 PM
A script is a sequence of bytes that gives instructions to the script interpreter. It is not human readable data and attempting to interpret the raw bytes as text as you have done will result in garbage (which is what you are seeing). Typically people examine scripts encoded in hexadecimal or they decode the script into text that represent the opcodes and data provided in the script. The data is usually in hex.

What are you trying to do with the script?


Title: Re: script.bin
Post by: Xynerise on April 23, 2018, 12:05:44 AM
.

What are you trying to do with the script?
The blockchair.com explorer does that by default.

@OP:
It tries to convert hash160 of bitcoin addresses to ASCII string for cases where people encode data in the blockchain by using "fake" bitcoin addresses.
For example if you view this 'fake' address 17xws5ASGc1dpKYB6jBRnRJGEKEQ4Xq7fy on Blockchair block explorer  (https://blockchair.com/bitcoin/address/17xws5ASGc1dpKYB6jBRnRJGEKEQ4Xq7fy) it will automatically convert the hash160 of the address 4c656e20776173206f757220667269656e642e20 to
Quote
Len was our friend

If it tries to decode that of a "real" bitcoin address then it will rightly output gibberish, as you can see in your address.


Title: Re: script.bin
Post by: starmyc on April 23, 2018, 05:02:30 AM
i mean this

v� H�' !�E l;O�q "��

well.. i have something like this and i want to convert it to base64..
how can i do it ?


This is the transaction output script, which is given in its humanly readable format as well on the same page:

Quote
OP_DUP OP_HASH160 489ac8dd2713218545056c3b4fb0710522aeee0d OP_EQUALVERIFY OP_CHECKSIG

In its hex form:

Quote
76 a9 489ac8dd2713218545056c3b4fb0710522aeee0d 88 ac
(Values taken from https://en.bitcoin.it/wiki/Script (https://en.bitcoin.it/wiki/Script)

Why would you want to convert it in base64 ?

By the way:

Code:
$ echo -n "76a9489ac8dd2713218545056c3b4fb0710522aeee0d88ac" | xxd -r -p | base64
dqlImsjdJxMhhUUFbDtPsHEFIq7uDYis

$ echo -n dqlImsjdJxMhhUUFbDtPsHEFIq7uDYis | base64 -d | xxd
00000000: 76a9 489a c8dd 2713 2185 4505 6c3b 4fb0  v.H...'.!.E.l;O.
00000010: 7105 22ae ee0d 88ac                      q.".....