Show Posts
|
Pages: [1]
|
I know the P2SH calculation, as follow, 1:Hash1 = sha256(public key);
No, it is the hash of the redeemscript, not any of the public keys. In this case, the redeemscript starts with 0x52 and goes to the end. yeah, you are correct. Thank you very much.
|
|
|
Now, I analysis the block information, and I don't know how to get the wallet address which first character is “3”. the tx in script is as follow. Tx In Script: 0x00, 0x47, 0x30,0x44,0x02,0x20, 0x0c,0xf1,0x83,0x78,0x7d,0x2f,0x7e,0xf3,0x87,0xe1,0x40,0x46,0xe7,0xf3,0x8d,0x94,0x42,0xb3,0x16,0xd6,0x90,0xb3,0x11,0x6d,0xa6,0xc6,0x0d,0x4b,0x8d,0x1b,0xb5,0x43, 0x02,0x20,0x30,0x16,0x93,0xba,0x31,0xb5,0xaa,0xd8,0xd7,0x54,0x2a,0x67,0x3e,0x6b,0x96,0xf4,0x83,0x01,0x52,0xec,0x6d,0x26,0xf3,0xa8,0xbf,0x1d,0x37,0x76,0xf3,0x9d,0xe5,0x1d,0x01, 0x48, 0x30,0x45,0x02,0x21, 0x00,0x9c,0xd1,0xc1,0xb3,0xe1,0xec,0x93,0xcd,0x58,0x52,0xb4,0x2f,0xa5,0x6b,0x6a,0xf7,0x06,0xa0,0x9b,0x00,0xe0,0x56,0xd1,0xfd,0x13,0x13,0xfa,0xb4,0x23,0xbb,0x79,0x43, 0x02,0x20,0x13,0x27,0x34,0x7f,0x6c,0x9b,0xc8,0x10,0x6d,0xca,0x4e,0xb8,0x4d,0xe3,0x6b,0xd2,0x42,0xf0,0x97,0x03,0x88,0xab,0x7c,0xd5,0x86,0xe1,0x84,0x3b,0x84,0xb0,0x45,0x20, 0x01, 0x47, 0x52,0x21, 0x02,0x30,0x9d,0x6a,0x9d,0x97,0xa3,0xe8,0x14,0x24,0x7d,0x47,0x1d,0xdc,0x2c,0x47,0x6c,0x04,0x6f,0x9c,0x07,0xd9,0x80,0x79,0xd8,0x61,0xe3,0x44,0x79,0xc1,0x94,0x97,0xea,//public key 1 0x21, 0x03,0xc5,0x11,0xb8,0xfe,0x3a,0x5e,0x60,0xad,0x16,0xbb,0x14,0xb0,0x86,0x5f,0x8a,0x3f,0x19,0x2d,0xdb,0x38,0x6c,0x4f,0x8d,0x23,0xf7,0x2e,0xdd,0x24,0x76,0x4e,0x0e,0x23,//public key 2 0x52, 0xae,
I know the P2SH calculation, as follow, 1:Hash1 = sha256(public key); 2:Hash2 = RIPEMD160(Hash1), Then, get first 20 hex; 3:get check code, sha256(sha256(0x05 or 0x00 + first 20 hex)), and get first 4 hex as the check code; 4:put the check code to the end of first 20 hex; 5:address, Encode(0x00 or 0x05 + first 20 hex + 4 hex check code);
according the script, there are two public keys in the script, so I don't know which public key to use or these is other calculation .
Thank you for your help.
|
|
|
Thank you very much. it's very explicit。 The last question: how to get the block heigth number? Thank you.
You don't. There actually is no way to request a block by height over p2p in Bitcoin. In order to do so, you need to somehow get the hash. Really the only way is to start from the genesis block and start requesting every block and keeping count of what height you are at. Understand. Thank you very much.
|
|
|
Thank your answer, according your answer, i get what i want. i have other question, memkleblock: i know , when i send "getdata" message to node, and node maybe reply the "memkleblock". but , i don't know how to set inv data struct in "getdata" message, 1, type, I set 2 or 3? 2 means MSG_BLOCK, 3 means MSG_FILTERED_BLOCK;
You need to set inv type 3, MSG_FILTERED_BLOCK. But in order to do so, you first must set a bloom filter using filterload. 2, hash, I set block hash or memkle hash?
Block Hash. the whole stage of "memkleblock" as follow: "?" -> "inv"-> "getdata"->"memkleblock". when start, what message should I send to node?
You first do the handshake with the version messages. Then you have to set a bloom filter using filterload. Then you send a getblocks message and the node returns you an inv. Then you can send a getdata and you will get a merkleblock in response. BTW, it's merkleblock and merkle root, not memkle. Thank you very much. it's very explicit。 The last question: how to get the block heigth number? Thank you.
|
|
|
I want to use "getblock" msg to get someone block information.
That should work fine as long as you know the block hash. If you only know the block index, then you'll need to run getblockhash first. but the tx information in block only don't contain the tx hash,
Yes, it does. getblock returns the block header and a list of all the transaction hashes of all the transactions in the block. the hash in tx is the previous transaction hash.
I think you are mistaken. The list of transactions hashes provided by getblock are the hashes of the transactions that are included in that block. So, how can I get the current hash code of the block?
If you are using getblock, then you already have the hash of the current block. If you don't have the hash of the block then you'll need to know the index (the height of the block). Then you can use getblockhash. If you don't know the index or the hash, then how do you know which block you want to get? Then, in blockchain(link:www.blockchain.info), each transaction contain the in and out bitcoin address, can I get these addresses in block?
Once you have the transaction hash, you can get the details of the transaction with getrawtransaction (if you have txindex=1 in your bitcoin.conf) The transaction outputs will have the address (if any) as well as the scriptPubKey so you can handle transaction outputs that do not have addresses. The transaction inputs will have the index of the output and the transaction hash that identifies the output that is being spent. You can use getrawtransaction on that transaction hash and look at the indicated output to find the address (if any) as well as the scriptPubKey so you can handle transaction outputs that do not have addresses. Thank your answer, according your answer, i get what i want. i have other question, memkleblock: i know , when i send "getdata" message to node, and node maybe reply the "memkleblock". but , i don't know how to set inv data struct in "getdata" message, 1, type, I set 2 or 3? 2 means MSG_BLOCK, 3 means MSG_FILTERED_BLOCK; 2, hash, I set block hash or memkle hash? the whole stage of "memkleblock" as follow: "?" -> "inv"-> "getdata"->"memkleblock". when start, what message should I send to node? Thank you !
|
|
|
Thank you very much. I mean to get these information by protocal command in developer-reference, such as "getblocks", "getheaders".
|
|
|
I want to use "getblock" msg to get someone block information. but the tx information in block only don't contain the tx hash, the hash in tx is the previous transaction hash. So, how can I get the current hash code of the block? Then, in blockchain(link:www.blockchain.info), each transaction contain the in and out bitcoin address, can I get these addresses in block? which message can I use to get these? ![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fblockchain.info%2Ftx%2F836bd0af24d9a00d916b8bd2a98df8ac7aac2fedae7de793d6a70f2d750dd7d8&t=663&c=asdGPcILuxoivg) thank you!
|
|
|
Thanks for your detail answer。 1, My steps to complete the handshake as follow, but hash the hex maybe wrong. Is the checksum hash256 the payload twice?
You have to sha256 hash the sha256 hash (so two hashes) of the payload. This is all done as binary data, not as a hex string. step me node 1 version --> 2 <-- version 3 <-- verack 4 verack --> if the node send ping, I reply pong, the payload is the same as ping.
but some nodes don't care your reply, they only send "version", "verack", "ping", "addr" message orderly. I am sure when i connect these node, i follow the steps to complete the handshake.
Interesting. Can you provide the user agent strings of those boxes? If you don't send a version message, then verack should not be sent. If you haven't sent a verack, ping and addr should not be sent. 2, In the version message, there are three sections of services, “services", "addr_recv services", and "addr_trans services". which is the services you refer to?
Thanks a lot.
"services". It refers to the services that the sending node is advertising, which is what you want to know. my version message: sendMsg len:131 0xf9, 0xbe, 0xb4, 0xd9, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6b, 0x0, 0x0, 0x0, 0xd9, 0x9c, 0xe5, 0x9, 0x7c, 0x11, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x57, 0xa6, 0xe0, 0xe6, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xd1, 0x7e, 0x69, 0x7, 0x8d, 0x20, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0xff, 0xff, 0x3a, 0x20, 0x40, 0x9, 0x5, 0xb5, 0x25, 0x8, 0x55, 0xca, 0x19, 0xa0, 0x39, 0x5, 0x15, 0x2f, 0x62, 0x69, 0x74, 0x63, 0x6f, 0x69, 0x6e, 0x2d, 0x73, 0x65, 0x65, 0x64, 0x65, 0x72, 0x3a, 0x30, 0x2e, 0x30, 0x31, 0x2f, 0x0, 0x0, 0x0, 0x0, 0x1, send success, len:131 node version message payload msg: 0x7c 0x11 0x1 0x0 0x5 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0xd3 0xe0 0xa6 0x57 0x0 0x0 0x0 0x0 0x1 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0xff 0xff 0x3d 0xab 0x74 0x1e 0x93 0xfe 0x5 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0xff 0xff 0xd1 0x7e 0x69 0x7 0x20 0x8d 0x1b 0x8b 0x29 0x4c 0x18 0x6c 0xaa 0xdb 0x10 0x2f 0x53 0x61 0x74 0x6f 0x73 0x68 0x69 0x3a 0x30 0x2e 0x31 0x32 0x2e 0x30 0x2f 0x9a 0x78 0x6 0x0 0x1 Start Decode:version:70012 mVersion:70012 services:0x5,0x0,0x0,0x0,0x0,0x0,0x0,0x0, timeStamp:1470554323 recv services:0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0, recvIp:0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0xff,0x3d,0xab,0x74,:0x1e,0x93,0xfe, recv services:0x5,0x0,0x0,0x0,0x0,0x0,0x0,0x0, recvIp:0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0xff,0xd1,0x7e,0x69,:0x7,0x20,0x8d, nonce:0x1b,0x8b,0x29,0x4c,0x18,0x6c,0xaa,0xdb, user_agent:0x2f,0x53,0x61,0x74,0x6f,0x73,0x68,0x69,0x3a,0x30,0x2e,0x31,0x32,0x2e,0x30,0x2f,strUserAgent:/Satoshi:0.12.0/| Peer Block Height:424090 node verack message: strCommand:verack verack msg:msgLen:24 0xf9,0xbe,0xb4,0xd9,0x76,0x65,0x72,0x61,0x63,0x6b,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x5d,0xf6,0xe0,0xe2, node ping message: strCommand:ping ping msg len:32 0xf9,0xbe,0xb4,0xd9,0x70,0x69,0x6e,0x67,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x8,0x0,0x0,0x0,0x88,0xda,0x1c,0xf5,0x9b,0x13,0x28,0x99,0xf5,0x46,0x15,0x60, node addr message: msgCommand:addr addr msg:msgLen:55 0xf9,0xbe,0xb4,0xd9, 0x61,0x64,0x64,0x72,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x1f,0x0,0x0,0x0, 0xc4,0x9c,0x92,0x9a, 0x1,0xd3,0xe0,0xa6,0x57,0x5,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0xff,0xd1,0x7e,0x69,0x7,0x20,0x8d, First , after i connected, I sent "version" message, and i didn't do anything more. then, I received four messages, in this stage, i didn't send any messages. so, it is very strange.
|
|
|
Thanks a lot. yesterday, i tested many nodes, i found some nodes send "version", then "verack", then "ping", last "addr" message, after they finish to send these messages, they don't reply any kinds of messages.
I think you should use this: https://bitcoin.org/en/developer-reference#constants-and-defaults as your reference. It pretty much explains everything. Anytime you want to connect to a node, you must complete the handshake. The handshake consists of you sending the peer a version message and the peer sending you a version message. Upon you receiving the version message, you must return a verack. When the peer receives your version message, he must send a verack. Only when both peers have received verack messages in response to the version messages can any other messages be sent. Many times if you don't respond to a message even though your protocol version indicates you should, the connection will be dropped. If you receive a ping message, you must respond with a pong. but if the node can send "inv" message initiatively, it can response other message, such as "getaddr" message, the node can reply "addr" message.
It depends on the protocol and software version. IIRC Bitcoin Core 0.13+ will not allow you to request a block or transaction unsolicited unless the peer has sent you an inv first. So, i don't know which kind of nodes i can download full of blocks or headers, can I identity this node according which message in wiki protocol?
No, that is not the way to identify those services. In the version message, there is a section for the services. It is an 8 byte bitfield. If the first bit of that bitfield is set, then the node can send blocks and headers; it is a full node. If that bit is not set, then it is not a full node. Are you sure that you are sending the getheaders message correctly?
Edit: Your checksum hash is wrong. Did you do a hash of the actual bytes or did you just hash the hex string? I'm pretty sure that it should be Thanks for your detail answer。 1, My steps to complete the handshake as follow, but hash the hex maybe wrong. Is the checksum hash256 the payload twice? step me node 1 version --> 2 <-- version 3 <-- verack 4 verack --> if the node send ping, I reply pong, the payload is the same as ping. but some nodes don't care your reply, they only send "version", "verack", "ping", "addr" message orderly. I am sure when i connect these node, i follow the steps to complete the handshake. 2, In the version message, there are three sections of services, “services", "addr_recv services", and "addr_trans services". which is the services you refer to? Thanks a lot.
|
|
|
The Genesis block isn't a block that you can request, it is hard coded into the software and never enters the database. Try a different block.
I test a different hash, but the node don't reply. not only "getheaders" message, I send "getaddr" message, the node don't reply. the node only reply "version" message. i found after i send "version" message, i will recieve "version" ,"verack", "inv"......"inv", "addr" message, sometimes, i will recieve "version" ,"verack","ping", "addr" message. then, i send any type message, the node don't reply. Did you complete the handshake; it seems that you did not. You first send the version message. Then you wait for both a verack from the node and the node's version message. Then you send a verack to the node. And then you can send your other messages. Thanks a lot. yesterday, i tested many nodes, i found some nodes send "version", then "verack", then "ping", last "addr" message, after they finish to send these messages, they don't reply any kinds of messages. but if the node can send "inv" message initiatively, it can response other message, such as "getaddr" message, the node can reply "addr" message. So, i don't know which kind of nodes i can download full of blocks or headers, can I identity this node according which message in wiki protocol? wiki link: https://en.bitcoin.it/wiki/Protocol_documentation
|
|
|
The Genesis block isn't a block that you can request, it is hard coded into the software and never enters the database. Try a different block.
I test a different hash, but the node don't reply. not only "getheaders" message, I send "getaddr" message, the node don't reply. the node only reply "version" message. i found after i send "version" message, i will recieve "version" ,"verack", "inv"......"inv", "addr" message, sometimes, i will recieve "version" ,"verack","ping", "addr" message. then, i send any type message, the node don't reply.
|
|
|
These day , i want to get block header infomation, but, i don't get it success, so, I have to ask for your help. After I connect one node, my step as follow: step 1:i send "version" message to node, this step is success, i recieve "version" message from node, but , after recieve "version" message, i can recieve "verack" message, "inv" message, "addr" message, and i don't send any control message or data message. the node send these message initiatively。 step 2: after i recieve "version" message, i send "verack" message, but , the node no response. step 3: i send "getheaders" messge, but , the node no response.
The "getheaders" message payoad Field Size Description Data type Comments 4 version uint32_t the protocol version 1+ hash count var_int number of block locator hash entries 32+ block locator hashes char[32] block locator object; newest back to genesis block (dense to start, but then sparse) 32 hash_stop char[32] hash of the last desired block header; set to zero to get as many blocks as possible (2000)
version, i get the version of"version" message from node, and compare my version 70002, which is low, i use it; hash count , i set 1; block locator hashes, i choose the genesis block hash hash_stop, i set 0;
message hex: sendMsg len:93 header: 0xf9, 0xbe, 0xb4, 0xd9, 0x67, 0x65, 0x74, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0xee, 0x40, 0x68, 0xa4, payload: 0x72, 0x11, 0x01, 0x00, 0x01, 0x6f, 0xe2, 0x8c, 0x0a, 0xb6, 0xf1, 0xb3, 0x72, 0xc1, 0xa6, 0xa2, 0x46, 0xae, 0x63, 0xf7, 0x4f, 0x93, 0x1e, 0x83, 0x65, 0xe1, 0x5a, 0x08, 0x9c, 0x68, 0xd6, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
i don't understand , why node don't reply the "getheaders" message, which step i was wrong?
|
|
|
|