Bitcoin Forum
May 11, 2024, 05:29:58 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: [SOLVED] Clarifications on this tx  (Read 900 times)
supermoney (OP)
Legendary
*
Offline Offline

Activity: 1161
Merit: 1004



View Profile
January 14, 2016, 04:07:42 PM
Last edit: January 14, 2016, 11:13:17 PM by supermoney
 #1

I coded my own algorithm for retrieving fee from a received tx (through getrawtransaction command).
By doing some stress tests I encountered the following tx: ab6a33a6281bb9d9a98949e50ac875f1d550e02e030e28a8800f280e2192ac51 (open with blockr.io or blocktrail.com)

0.51796901 (inputs) - 0.51740385 (output spent) = 0.00056516 (fee)
Sounds ok according to the shown inputs and outputs on blockr.io and blocktrail.

BUT...
My own script reports the following: tx-result (values got fetched from bitcoind)
There are no inputs with 0.51596901 and only got an input with 0.001, so where the hell did block explorers get those numbers? What's the algorithm? I can't figure it out and started to get mad...

By the way, my script successfully calculated the correct fee of the following txs:
ad560632ae5956088611fd029f7cd992e913b19e8a57ae2c2443db11a41cb99c
9afe2bf122e4ec26cff427015ea680f4e03877077376d1d9b1c6d6f63563acc7
c359b19f23e0e66dd98cf983269817513f540f23af4b5bbb56833dd22acf10b0
bd2f097ec1d1ca40d3032177d699c002f6e31fe93305de785c6db8816dbc488e
5ec8c58046e2afc01fe671d4b304fa2e5ec0530a63628e79a64d6cbfdd90a052
...and many others with multiple inputs and outputs.

UPDATE: added full txinfo from bitcoind -> tx-full

SOLVED: read last post I wrote.
1715448598
Hero Member
*
Offline Offline

Posts: 1715448598

View Profile Personal Message (Offline)

Ignore
1715448598
Reply with quote  #2

1715448598
Report to moderator
1715448598
Hero Member
*
Offline Offline

Posts: 1715448598

View Profile Personal Message (Offline)

Ignore
1715448598
Reply with quote  #2

1715448598
Report to moderator
"Governments are good at cutting off the heads of a centrally controlled networks like Napster, but pure P2P networks like Gnutella and Tor seem to be holding their own." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715448598
Hero Member
*
Offline Offline

Posts: 1715448598

View Profile Personal Message (Offline)

Ignore
1715448598
Reply with quote  #2

1715448598
Report to moderator
1715448598
Hero Member
*
Offline Offline

Posts: 1715448598

View Profile Personal Message (Offline)

Ignore
1715448598
Reply with quote  #2

1715448598
Report to moderator
1715448598
Hero Member
*
Offline Offline

Posts: 1715448598

View Profile Personal Message (Offline)

Ignore
1715448598
Reply with quote  #2

1715448598
Report to moderator
DannyHamilton
Legendary
*
Offline Offline

Activity: 3388
Merit: 4653



View Profile
January 14, 2016, 05:23:19 PM
 #2

Looking at the transaction:
http://tbtc.blockr.io/api/v1/tx/raw/ab6a33a6281bb9d9a98949e50ac875f1d550e02e030e28a8800f280e2192ac51
Code:
{
    "status":"success",
    "data":{
        "tx":{
            "hex":"...",
            "version":1,
            "locktime":0,
            "vin":[
                {
                    "txid":"8589f593e1f9da61004a87e7dd6fc2c873cf9124edc90a91ee9f74528aadd236",
                    "vout":1,
                    "scriptSig":{"asm":"..."},
                    "sequence":4294967295
                },{
                    "txid":"0ac8a4f8e7df98544e0bb4f39bf3916ca9b14dae17d3d5c5a02540002fc5376b",
                    "vout":0,
                    "scriptSig":{"asm":"..."},
                    "sequence":4294967295
                },{
                    "txid":"0ac8a4f8e7df98544e0bb4f39bf3916ca9b14dae17d3d5c5a02540002fc5376b",
                    "vout":1,
                    "scriptSig":{"asm":"..."},
                    "sequence":4294967295
                }
            ],
            "vout":[
                {
                    "value":0.51540385,
                    "n":0,
                    "scriptPubKey":{
                        "asm":"...",
                        "hex":"...",
                        "reqSigs":1,
                        "type":"scripthash",
                        "addresses":["2MyRyi1EzM3onzv99gNLWqscQBzmPdd9qKy"]
                    }
                },{
                    "value":0.002,
                    "n":1,
                    "scriptPubKey":{
                        "asm":"...",
                        "hex":"...",
                        "reqSigs":1,
                        "type":"scripthash",
                        "addresses":["2Mxh7iZ4QtajmS5zKtvwUVrJt9sajW2aMpS"]
                    }
                }
            ],
            "blockhash":"...",
            "confirmations":458,
            "time":1452645488,
            "blocktime":1452645488
        }
    },
    "code":200,
    "message":""
}

It looks like your transaction has 2 outputs:
  • 0.51540385 sent to 2MyRyi1EzM3onzv99gNLWqscQBzmPdd9qKy
  • 0.002 sent to 2Mxh7iZ4QtajmS5zKtvwUVrJt9sajW2aMpS

0.51540385 + 0.002 = total outputs 0.51740385

It looks like your transaction has 3 inputs:
  • Output number 1 from transaction 8589f593e1f9da61004a87e7dd6fc2c873cf9124edc90a91ee9f74528aadd236
  • Output number 0 from transaction 0ac8a4f8e7df98544e0bb4f39bf3916ca9b14dae17d3d5c5a02540002fc5376b
  • Output number 1 from transaction 0ac8a4f8e7df98544e0bb4f39bf3916ca9b14dae17d3d5c5a02540002fc5376b

Lets look at those three transaction outputs:

http://tbtc.blockr.io/api/v1/tx/raw/8589f593e1f9da61004a87e7dd6fc2c873cf9124edc90a91ee9f74528aadd236
Code:
- snip -
"vout":[
    - snip -
    {
        "value":0.001,
        "n":1,
        - snip -
        "addresses":["2N9yqoWM7epwB1QftTy7aFG7nvqJLv6cy5X"]
    }
]
- snip -
That looks like a 0.001 input.

http://tbtc.blockr.io/api/v1/tx/raw/0ac8a4f8e7df98544e0bb4f39bf3916ca9b14dae17d3d5c5a02540002fc5376b
Code:
- snip -
"vout":[
    {
        "value":0.001,
        "n":0,
        - snip -
        "addresses":["2MxbJa5LG6FrHDzVjnYmSnFJ1Zn93wdAubf"]
    },{
        "value":0.51596901,
        "n":1,
        - snip -
        "addresses":["2NB9X4bd8dGRnqqzxrhR973U9dZWwfteqvv"]
    }
]
- snip -

That looks like 2 outputs, one for 0.001 BTC and one for 0.51596901

0.001 + 0.001 + 0.51596901 = total inputs 0.51796901
supermoney (OP)
Legendary
*
Offline Offline

Activity: 1161
Merit: 1004



View Profile
January 14, 2016, 05:39:46 PM
Last edit: January 14, 2016, 05:57:41 PM by supermoney
 #3

- snip -

It would be great if my bitcoind would get the same input values as the block explorer.
The following result contains outputs of ab6a33a6281bb9d9a98949e50ac875f1d550e02e030e28a8800f280e2192ac51 and inputs of 8589f593e1f9da61004a87e7dd6fc2c873cf9124edc90a91ee9f74528aadd236: tx-result
Raw transaction from bitcoind: tx-full
As you can see inputs are different.

EDIT: I got the problem and figured it out... There are 3 inputs to calculate instead of 1 only as I used to do. Thanks for your time  Cheesy
supermoney (OP)
Legendary
*
Offline Offline

Activity: 1161
Merit: 1004



View Profile
January 14, 2016, 11:13:21 PM
 #4

Thank you DannyHamilton for helping me to figure out that my script was reading first input's value only.
I've updated my script with four nested foreach loops storing in a multidimensional array all values from each vout array of each vin of the original tx. The algorithm I studied and applied till now seems it didn't change hopefully.

Working script result: tx-result

#closed.
Pages: [1]
  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!