Bitcoin Forum
May 21, 2024, 11:51:23 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: 1 2 [All]
  Print  
Author Topic: understanding transactions  (Read 2446 times)
konradp (OP)
Full Member
***
Offline Offline

Activity: 129
Merit: 100



View Profile
August 06, 2014, 12:04:05 PM
Last edit: August 06, 2014, 02:50:15 PM by konradp
 #1

Hi,

I'm trying to understand transactions, so I'm playing with raw transactions in bitcoin-qt on testnet.

I'm not sure about a few things, even after reading https://en.bitcoin.it/wiki/Transactions (I supposed I missed something)

After listunspent I have this transaction among others:

{
"txid" : "d8e5db107f5dbd3b74b454a4ba2566277894199a836d9982a255a61f2b10d0a8",
"vout" : 1,
"address" : "msmhYhrXtYAxerUCNfDAXu97xwaZ3JqxH6",
"scriptPubKey" : "76a914866b70364391e0ba5514cc30cb45f12291bc6cf788ac",
"amount" : 0.33900000,
"confirmations" : 65
},

I want to send 0.02 BTC, So I do:
createrawtransaction [{\"txid\":\"d8e5db107f5dbd3b74b454a4ba2566277894199a836d9982a255a61f2b10d0a8\",\"vout\":1}] {\"mxHgEstqwqYtVrDP3LsjS9WWAeWHQyatck\":0.02}

(mxHgEstqwqYtVrDP3LsjS9WWAeWHQyatck is another address of mine)

Is that OK?

Result is:

0100000001a8d0102b1fa655a282996d839a199478276625baa454b4743bbd5d7f10dbe5d801000 00000ffffffff0180841e00000000001976a914b7f7543883c4fd010aeb1ef63b5e888487dd08ae 88ac00000000


After decoding it at https://blockchain.info/decode-tx I have (questions inside):
{
   "lock_time":0,
   "inputs":[
      {
         "prev_out":{
            "index":1,
            "hash":"d8e5db107f5dbd3b74b454a4ba2566277894199a836d9982a255a61f2b10d0a8"
         },
         "script":"" //question 0: This is scriptSig right? It's empty because I haven't signed the transfer yes?
      }
   ],
   "vout_sz":1,//question 1: What is it?
   "hash":"d231eab0bcee0ab3e2e2c08aa9f2eefa4f2e0d42ce225540fd2287ade62e0cdb",
   "vin_sz":1,//question 2: What is it?
   "out":[
      {
         "address":"1Hmiwpos8p7dijjmKmuMcEJBJeuaQzY3Mv",//question 3: is this a receiving address created by the wallet? Or something else?
         "script_string":"OP_DUP OP_HASH160 b7f7543883c4fd010aeb1ef63b5e888487dd08ae OP_EQUALVERIFY OP_CHECKSIG",//question 4: where did this b7f7543883... come from?
         "value":2000000,
         "script":"76a914b7f7543883c4fd010aeb1ef63b5e888487dd08ae88ac"
      }
   ],
   "size":85,
   "version":1
}

I will soon sign the transfer, but can you answer the questions above first please?

btw. should I ask these kind of questions here or in Development & Technical Discussion maybe?
amaclin
Legendary
*
Offline Offline

Activity: 1260
Merit: 1019


View Profile
August 06, 2014, 12:20:39 PM
 #2

Quote
(mxHgEstqwqYtVrDP3LsjS9WWAeWHQyatck is another address of mine)
Is that OK?
Yes

Quote
"script":"" //question 0: This is scriptSig right? It's empty because I haven't signed the transfer yes?
Yes

Quote
"vout_sz":1,//question 1: What is it?
This is the number of outputs (vector-output-size?). You can send to several "addresses" your funds. This transaction sends to one address.

Quote
  "vin_sz":1,//question 2: What is it?
This is the number of inputs. You can spend several inputs in one transaction. Your particular transaction spends only one

Quote
  "address":"1Hmiwpos8p7dijjmKmuMcEJBJeuaQzY3Mv",//question 3: is this a receiving address created by the wallet? Or something else?
Yes. But why does it starts with "1" Huh Seems to me thay you have decoded your transaction for mainnet, not for testnet! Be careful!

Quote
"script_string":"OP_DUP OP_HASH160 b7f7543883c4fd010aeb1ef63b5e888487dd08ae OP_EQUALVERIFY OP_CHECKSIG",//question 4: where did this b7f7543883... came from?
         "value":2000000,
         "script":"76a914b7f7543883c4fd010aeb1ef63b5e888487dd08ae88ac"
This is another representation of your destination address
http://test.webbtc.com/address/mxHgEstqwqYtVrDP3LsjS9WWAeWHQyatck
konradp (OP)
Full Member
***
Offline Offline

Activity: 129
Merit: 100



View Profile
August 06, 2014, 12:36:15 PM
Last edit: August 06, 2014, 12:57:33 PM by konradp
 #3

Thank you!

Quote
Quote
 "address":"1Hmiwpos8p7dijjmKmuMcEJBJeuaQzY3Mv",//question 3: is this a receiving address created by the wallet? Or something else?
Yes. But why does it starts with "1" Huh Seems to me thay you have decoded your transaction for mainnet, not for testnet! Be careful!

Well, I have no idea. I'm working entirely in testnet mode. I did run mainnet before but it's closed now. Do you have an idea?

Quote
Quote
"script_string":"OP_DUP OP_HASH160 b7f7543883c4fd010aeb1ef63b5e888487dd08ae OP_EQUALVERIFY OP_CHECKSIG",//question 4: where did this b7f7543883... came from?
         "value":2000000,
         "script":"76a914b7f7543883c4fd010aeb1ef63b5e888487dd08ae88ac"
This is another representation of your destination address

I found out that this "hash160" is a ripemd160(sha256(address)) is this correct? Because when I do this I get a completely different result... even considering this endianness craziness it doesn't match.


amaclin
Legendary
*
Offline Offline

Activity: 1260
Merit: 1019


View Profile
August 06, 2014, 01:07:15 PM
 #4

Quote
Well, I have no idea. I'm working entirely in testnet mode. I did run mainnet before but it's closed now. Do you have an idea?
Of course. You have said above:
Quote
After decoding it at https://blockchain.info/decode-tx I have (questions inside):
Blockchain.info site decodes this transaction as for mainnet.

Quote
I found out that this "hash160" is a ripemd160(sha256(address)) is this correct?
No.
Your public key is long array of bytes (64 bytes to be correct)
It is too long to be used as an address and it does not have checksums for error handling
So, there is a hash function which converts public key to 20 bytes (there are 2 ways to do it)
b7f7543883c4fd010aeb1ef63b5e888487dd08ae - is the result of this written in hex digits
This line is also bad for using as your address - it is still too long and also does not have error-cheching
So, there is base58check function which converts 20 bytes to bitcoin address

read this
https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addresses
https://en.bitcoin.it/wiki/Base58Check_encoding

Bitcoin Town
Newbie
*
Offline Offline

Activity: 13
Merit: 0


View Profile
August 06, 2014, 01:12:19 PM
 #5

i dont know about thats maybe some error system on it .
 Huh Huh
konradp (OP)
Full Member
***
Offline Offline

Activity: 129
Merit: 100



View Profile
August 06, 2014, 01:21:56 PM
 #6

Quote
Well, I have no idea. I'm working entirely in testnet mode. I did run mainnet before but it's closed now. Do you have an idea?
Of course. You have said above:
Quote
After decoding it at https://blockchain.info/decode-tx I have (questions inside):
Blockchain.info site decodes this transaction as for mainnet.

Quote
I found out that this "hash160" is a ripemd160(sha256(address)) is this correct?
No.
Your public key is long array of bytes (64 bytes to be correct)
It is too long to be used as an address and it does not have checksums for error handling
So, there is a hash function which converts public key to 20 bytes (there are 2 ways to do it)
b7f7543883c4fd010aeb1ef63b5e888487dd08ae - is the result of this written in hex digits
This line is also bad for using as your address - it is still too long and also does not have error-cheching
So, there is base58check function which converts 20 bytes to bitcoin address

read this
https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addresses
https://en.bitcoin.it/wiki/Base58Check_encoding



Thanks. I was going to ask you if I also have to fully understand addresses to understand transactions, then I saw last two lines of your answer:)

So thanks. I'll read it.

Quote
Blockchain.info site decodes this transaction as for mainnet.
Ouch Embarrassed But can I assume that everything except for this receiving address is OK?
amaclin
Legendary
*
Offline Offline

Activity: 1260
Merit: 1019


View Profile
August 06, 2014, 01:26:09 PM
 #7

Quote
Quote
Blockchain.info site decodes this transaction as for mainnet.
Ouch Embarrassed But can I assume that everything except for this receiving address is OK?
Yes
konradp (OP)
Full Member
***
Offline Offline

Activity: 129
Merit: 100



View Profile
August 06, 2014, 01:56:50 PM
 #8

Thanks!

So I'm signing the transaction:

signrawtransaction 0100000001a8d0102b1fa655a282996d839a199478276625baa454b4743bbd5d7f10dbe5d801000 00000ffffffff0180841e00000000001976a914b7f7543883c4fd010aeb1ef63b5e888487dd08ae 88ac00000000

result is OK, and after decoding I have:

{
   "lock_time":0,
   "inputs":[
      {
         "prev_out":{
            "index":1,
            "hash":"d8e5db107f5dbd3b74b454a4ba2566277894199a836d9982a255a61f2b10d0a8"
         },
         "script":"473044022031e60b2d340e350d871809492f3d0b4d7dda2eae11c4e729be648a9c87b2fc1802207 bd0fbd9614dc08f14b9092559de106417373a8a1d9353767874a95aa302973b012102d9c1d8bc28 62f6946ea055743551abb385492069da38bdc0ec8e3e875ec87875" //question 0: this is again scriptSig, this time signed, right? But why can't be it "decoded" just like scriptPubKey below?
      }
   ],
   "vout_sz":1,
   "hash":"7f850e2a177fb494492d3ad7707cceaa410106b3c6ce0385f876d24acad653ab",//question 1: I thought this is transaction ID, then why did it change after signing it?
   "vin_sz":1,
   "out":[
      {
         "address":"1Hmiwpos8p7dijjmKmuMcEJBJeuaQzY3Mv",
         "script_string":"OP_DUP OP_HASH160 b7f7543883c4fd010aeb1ef63b5e888487dd08ae OP_EQUALVERIFY OP_CHECKSIG",//question 3: this is the same as in above, but I forgot to ask, this is the scriptPubKey, right?
         "value":2000000,
         "script":"76a914b7f7543883c4fd010aeb1ef63b5e888487dd08ae88ac"
      }
   ],
   "size":191,
   "version":1
}
amaclin
Legendary
*
Offline Offline

Activity: 1260
Merit: 1019


View Profile
August 06, 2014, 02:29:28 PM
 #9

Quote
"script":"473...c87875" //question 0: this is again scriptSig, this time signed, right? But why can't be it "decoded" just like scriptPubKey below?
There is nothing interesting in scriptSig - there are two <push> operations. Signature and publicKey

Quote
  "hash":"7f850e2a177fb494492d3ad7707cceaa410106b3c6ce0385f876d24acad653ab",//question 1: I thought this is transaction ID, then why did it change after signing it?
There is no "ID" field in transaction itself. Transaction ID is a hash of its contents. Contents was changed. So the hash will be different

Quote
"script_string":"OP_DUP OP_HASH160 b7f7543883c4fd010aeb1ef63b5e888487dd08ae OP_EQUALVERIFY OP_CHECKSIG",//question 3: this is the same as in above, but I forgot to ask, this is the scriptPubKey, right?
Yes
konradp (OP)
Full Member
***
Offline Offline

Activity: 129
Merit: 100



View Profile
August 06, 2014, 02:37:28 PM
Last edit: August 06, 2014, 02:55:16 PM by konradp
 #10

Thank you, you're a nice guy!

So now I'm trying to send it:

sendrawtransaction 0100000001a8d0102b1fa655a282996d839a199478276625baa454b4743bbd5d7f10dbe5d801000 0006a473044022031e60b2d340e350d871809492f3d0b4d7dda2eae11c4e729be648a9c87b2fc18 02207bd0fbd9614dc08f14b9092559de106417373a8a1d9353767874a95aa302973b012102d9c1d 8bc2862f6946ea055743551abb385492069da38bdc0ec8e3e875ec87875ffffffff0180841e0000 0000001976a914b7f7543883c4fd010aeb1ef63b5e888487dd08ae88ac00000000

result (error):
(code -25)

Debug log doesn't say anything. Actually, it looks like it stopped logging things an hour ago...
And google doesn't help either.

Update, was that an error? Because I've just received those 0.02 btc, transaction hash is OK:
7f850e2a177fb494492d3ad7707cceaa410106b3c6ce0385f876d24acad653ab

So, why was it in red, and this minus sign before...
amaclin
Legendary
*
Offline Offline

Activity: 1260
Merit: 1019


View Profile
August 06, 2014, 02:55:22 PM
 #11

Quote
result (error):
(code -25)

I've pushed your transaction via http://test.webbtc.com/relay_tx
So it is (it was) correct

Update: now it is confirmed http://test.webbtc.com/tx/7f850e2a177fb494492d3ad7707cceaa410106b3c6ce0385f876d24acad653ab
konradp (OP)
Full Member
***
Offline Offline

Activity: 129
Merit: 100



View Profile
August 06, 2014, 02:56:57 PM
 #12

Ha, yes, I've just received it, thanks.

But then why bitcoin-qt said code: -25 (in red) ?

Edit:

OK, I need to go home now. *Big* thank you for your help amaclin! Tomorrow I'll have to wrap my head around it all over again:)
amaclin
Legendary
*
Offline Offline

Activity: 1260
Merit: 1019


View Profile
August 06, 2014, 03:03:47 PM
 #13

Quote
But then why bitcoin-qt said code: -25 (in red) ?

Something was wrong while sending. I have sources for bitcoin 0.8.x version. There is no -25 error code there.
Are you using v0.9? Have a look into bitcoinrpc.h file
p2pbucks
Hero Member
*****
Offline Offline

Activity: 642
Merit: 500


Evolution is the only way to survive


View Profile
August 06, 2014, 03:37:54 PM
 #14

./bitcoind getrawtransaction d8e5db107f5dbd3b74b454a4ba2566277894199a836d9982a255a61f2b10d0a8  and then decoderawtransaction first, make sure you have set the right vout
amaclin
Legendary
*
Offline Offline

Activity: 1260
Merit: 1019


View Profile
August 06, 2014, 03:57:11 PM
 #15

Quote
OK, I need to go home now. *Big* thank you for your help amaclin! Tomorrow I'll have to wrap my head around it all over again:)

By the way: do not forget about "change" output and fees working with mainnet.
Bungeebones
Full Member
***
Offline Offline

Activity: 178
Merit: 100



View Profile
August 06, 2014, 04:14:51 PM
 #16

I want to say "thanks" to both the OP and Amaclin for this post. It is great when someone posts really concise, step by step and intelligent questions and then another replies with equally concise, step by step and intelligent answers. I, myself, am just starting to delve into understanding transactions so I have bookmarked this baby.

Thank you both!
21M Bitcoin
Newbie
*
Offline Offline

Activity: 15
Merit: 0


View Profile
August 06, 2014, 05:58:45 PM
 #17

I want to say "thanks" to both the OP and Amaclin for this post. It is great when someone posts really concise, step by step and intelligent questions and then another replies with equally concise, step by step and intelligent answers. I, myself, am just starting to delve into understanding transactions so I have bookmarked this baby.

Thank you both!

he is real hero . thats full and easy step from him
what a amazing man wiiith brightshine .
amaclin
Legendary
*
Offline Offline

Activity: 1260
Merit: 1019


View Profile
August 06, 2014, 06:55:52 PM
 #18

wow  Grin should i put my address into the signature for donations?
coynbyer123
Newbie
*
Offline Offline

Activity: 43
Merit: 0


View Profile
August 06, 2014, 07:49:36 PM
 #19


After listunspent I have this transaction among others:

{
"txid" : "d8e5db107f5dbd3b74b454a4ba2566277894199a836d9982a255a61f2b10d0a8",
"vout" : 1,
"address" : "msmhYhrXtYAxerUCNfDAXu97xwaZ3JqxH6",
"scriptPubKey" : "76a914866b70364391e0ba5514cc30cb45f12291bc6cf788ac",
"amount" : 0.33900000,
"confirmations" : 65
},

I want to send 0.02 BTC, So I do:
createrawtransaction [{\"txid\":\"d8e5db107f5dbd3b74b454a4ba2566277894199a836d9982a255a61f2b10d0a8\",\"vout\":1}] {\"mxHgEstqwqYtVrDP3LsjS9WWAeWHQyatck\":0.02}

(mxHgEstqwqYtVrDP3LsjS9WWAeWHQyatck is another address of mine)

Is that OK?

0.339 - 0.2 = 0.319

u paying 0.319 BTC transaction fee

is what u want to do?

if no then createrawtransaction need 2nd output to address from u wallet.
amaclin
Legendary
*
Offline Offline

Activity: 1260
Merit: 1019


View Profile
August 06, 2014, 07:54:38 PM
 #20

Quote
is what u want to do?

This is not a problem on testnet. Let him to make this mistake before teaching him.

By the way. I have a lot of testnet coins. Who wants them? PM me your testnet address
konradp (OP)
Full Member
***
Offline Offline

Activity: 129
Merit: 100



View Profile
August 07, 2014, 05:57:45 AM
 #21

wow  Grin should i put my address into the signature for donations?

You definitely should:) I bookmarked this thread and as soon as I'll get some btc I'll surely send you something.

Thank you again for everything!

Newar
Legendary
*
Offline Offline

Activity: 1358
Merit: 1001


https://gliph.me/hUF


View Profile
August 08, 2014, 03:24:15 AM
Last edit: August 08, 2014, 09:57:13 AM by Newar
 #22

[...] Who wants them? [...]

Send them to the faucets.

OTC rating | GPG keyid 1DC91318EE785FDE | Gliph: lightning bicycle tree music | Mycelium, a swift & secure Bitcoin client for Android | LocalBitcoins
Mental Fight
Newbie
*
Offline Offline

Activity: 15
Merit: 0


View Profile
August 08, 2014, 07:32:53 AM
 #23

this all for set on website . for any transaction will be made?
amaclin
Legendary
*
Offline Offline

Activity: 1260
Merit: 1019


View Profile
August 08, 2014, 07:39:58 AM
 #24

Quote
Send them to the faucets.

sent 66.0 testcoins to msj42CCGruhRsFrGATiUuh25dtxYtnpbTx ( http://tpfaucet.appspot.com/ )
sent 66.0 testcoins to mrPGg2i9fccYZKnL2np1WhYSy7HpCEgFMQ ( http://faucet.xeno-genesis.com/ )
sent 66.0 testcoins to mo2f3N8WRVQ2kG6Y3j4UFHMzN9eS8BpK3E ( http://testnet.bitcoin.peercoinfaucet.com/ )

in transaction http://test.webbtc.com/tx/bc8150e5b50685747337c0f9f697aa2a0c3c1b6056e0b2bc06c933571d1cf0ff

PS. syncing testnet is so slow... voting for restarting testnet3 to testnet4
konradp (OP)
Full Member
***
Offline Offline

Activity: 129
Merit: 100



View Profile
August 08, 2014, 07:44:07 AM
 #25

Quote
PS. syncing testnet is so slow... voting for restarting testnet3 to testnet4

IMHO syncing is the smallest problem, difficulty is the problem. On my machine it would take ~45 days to solve a block. Which I would like to do someday:) People are using ASICs on testnet probably.

I already asked it somewhere, but without a reply. Why not many testnets? Then all these people with ASIC's would split on them, and I would be able to choose a testnet with the lowest difficulty. Why not?
amaclin
Legendary
*
Offline Offline

Activity: 1260
Merit: 1019


View Profile
August 08, 2014, 07:46:38 AM
 #26

Quote
I already asked it somewhere, but without a reply. Why not many testnets? Then all these people with ASIC's would split on them, and I would be able to choose a testnet with the lowest difficulty. Why not?

The answer is: use testnet-in-a-box
(I tried to use it at my very early steps to bitcoin without success)
konradp (OP)
Full Member
***
Offline Offline

Activity: 129
Merit: 100



View Profile
August 08, 2014, 07:50:49 AM
 #27

Quote
I already asked it somewhere, but without a reply. Why not many testnets? Then all these people with ASIC's would split on them, and I would be able to choose a testnet with the lowest difficulty. Why not?

The answer is: use testnet-in-a-box
(I tried to use it at my very early steps to bitcoin without success)

Yes, I know about it, but I'm technically disabled:) (If this is correct in english:))

From what I know it just doesn't work well in Windows, and I have it in my job.
igorp73
Newbie
*
Offline Offline

Activity: 2
Merit: 0


View Profile
November 14, 2014, 08:37:09 PM
 #28

HELP

my auto withdraw of Hirocoin (HIRO) still pending more than 3 days.

1582.00775202   HD2HUMnqeGPaKnjXpyEM9H4YX7nNnp78X7 (igorp73)
TxID: Status: Pending


 coinmine.pw user name= skywalker_70
thanks
Pages: 1 2 [All]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!