Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: kristiano92 on July 31, 2020, 12:40:23 PM



Title: Bitcoin-etl transactions.json parameters explanation
Post by: kristiano92 on July 31, 2020, 12:40:23 PM
Hi,

I use bitcoinetl to download data from bitcoin blockchain.
For example:
Code:
{
  "hash": "412910031c9677c24d08a27034c994564ca0801a7817b4fa0e6d38ab425508cc",
  "size": 223,
  "virtual_size": 223,
  "version": 1,
  "lock_time": 0,
  "block_number": 641225,
  "block_hash": "00000000000000000001c40a6317eec0cdd1b669a237bf1e049d7f70d56a8345",
  "block_timestamp": 1595969476,
  "is_coinbase": false,
  "index": 379,
  "inputs": [
    {
      "index": 0,
      "spent_transaction_hash": "1ad97eaf9013507e0f2ae8f42a4381adf2141b45ca874c5e0b1956c60854f4ec",
      "spent_output_index": 2,
      "script_asm": "30440220357d50e85dd29c52e54bc14dde809956abe1ac691a5fb6ffc46f79ace749b2bd02201447841e72078f0b2f9b512bea3d91e2b787ef6f3318c4c0192a4266f0d6d7ac[ALL] 0292423edb90a4b950ecf25bc0b76173ebea211bb56c5f7d05518bd02603b97ded",
      "script_hex": "4730440220357d50e85dd29c52e54bc14dde809956abe1ac691a5fb6ffc46f79ace749b2bd02201447841e72078f0b2f9b512bea3d91e2b787ef6f3318c4c0192a4266f0d6d7ac01210292423edb90a4b950ecf25bc0b76173ebea211bb56c5f7d05518bd02603b97ded",
      "sequence": 4294967295,
      "required_signatures": 1,
      "type": "pubkeyhash",
      "addresses": [
        "13yQitAQzggzTr6dw7Qe5PZnGhsoMxjrEM"
      ],
      "value": 59822256
    }
  ],
  "outputs": [
    {
      "index": 0,
      "script_asm": "OP_HASH160 8f7c778eb3d10e78f19e42c4e810c0c4748cd15c OP_EQUAL",
      "script_hex": "a9148f7c778eb3d10e78f19e42c4e810c0c4748cd15c87",
      "required_signatures": 1,
      "type": "scripthash",
      "addresses": [
        "3Emhf6WMZSgqZorB2SeymSE55XeL3JLcqa"
      ],
      "value": 3636800
    },
    {
      "index": 1,
      "script_asm": "OP_DUP OP_HASH160 3948bdcd3ae6de4ced68de778bbd88c27b18e75f OP_EQUALVERIFY OP_CHECKSIG",
      "script_hex": "76a9143948bdcd3ae6de4ced68de778bbd88c27b18e75f88ac",
      "required_signatures": 1,
      "type": "pubkeyhash",
      "addresses": [
        "16Dtf6axb6BYXXmMmdhTNuqHFSePDg1654"
      ],
      "value": 56153138
    }
  ],
  "input_count": 1,
  "output_count": 2,
  "input_value": 59822256,
  "output_value": 59789938,
  "fee": 32318
}

I don't know what this parameter mean "index: 379". Could anyone explain me ?


Title: Re: Bitcoin-etl transactions.json what index mean ?
Post by: A-Bolt on July 31, 2020, 06:52:55 PM
what this parameter mean "index: 379"

It's tx index in a block.


Title: Re: Bitcoin-etl transactions.json what index mean ?
Post by: HeRetiK on August 01, 2020, 03:32:59 PM
Usually transactions are stored in a list as part of a block, which means each transaction is indexed.

I haven't used bitcoinetl before, but I presume since bitcoinetl splits this data into the blocks.json and transactions.json schemas, the index needs to be stored explicitely as part of the transaction data, hence the transaction index. This enables you -- in theory -- to rebuild and verify the original block data as stored on the Bitcoin blockchain. Without the transaction index this would not be possible as no ordering information would be available.


Title: Re: Bitcoin-etl transactions.json what index mean ?
Post by: kristiano92 on August 03, 2020, 11:30:12 AM
Thank you for explanation :)


Title: Re: Bitcoin-etl transactions.json what index mean ?
Post by: kristiano92 on October 01, 2020, 12:00:18 PM
Is "required_signatures" parameter always be "1" ?


Title: Re: Bitcoin-etl transactions.json what index mean ?
Post by: HeRetiK on October 01, 2020, 01:41:15 PM
Is "required_signatures" parameter always be "1" ?


Not always:

Code:
            {
                "name": "required_signatures",
                "type": "INT64",
                "description": "The number of signatures required to authorize spending of this output"
            },


There's multisig transactions that require n-of-m signatures so according to the above the value of "required_signatures" will depend on whether it's a multisig transaction or a regular one with only a single required signature.


Title: Re: Bitcoin-etl transactions.json what index mean ?
Post by: kristiano92 on October 04, 2020, 03:41:37 PM
Is "required_signatures" parameter always be "1" ?


Not always:

Code:
            {
                "name": "required_signatures",
                "type": "INT64",
                "description": "The number of signatures required to authorize spending of this output"
            },


There's multisig transactions that require n-of-m signatures so according to the above the value of "required_signatures" will depend on whether it's a multisig transaction or a regular one with only a single required signature.

Ok, thanks :) When it comes to outputs, can they be always "1" ? I haven't found any ouput > 1


Title: Re: Bitcoin-etl transactions.json what index mean ?
Post by: PrimeNumber7 on October 04, 2020, 10:35:39 PM
Ok, thanks :) When it comes to outputs, can they be always "1" ? I haven't found any ouput > 1
The transaction you referenced in the OP has two outputs.

It is very common for an individual to have transactions that have exactly two outputs, one to the person/enttity they are sending coin to and one change (https://en.bitcoin.it/wiki/Change) output.

Many businesses who send many transactions per day will consolidate transactions such that they send coin to many individuals/entities in a single transaction.

Here is an example (https://btc.com/617892b0df5e051e0108e5bc9e5a35b1442079c2ba59e67ff5ca206094fdd8b2) of a recent transaction that has more than two outputs.


Title: Re: Bitcoin-etl transactions.json what index mean ?
Post by: kristiano92 on October 06, 2020, 04:17:34 PM
Ok, thanks :) When it comes to outputs, can they be always "1" ? I haven't found any ouput > 1
The transaction you referenced in the OP has two outputs.

It is very common for an individual to have transactions that have exactly two outputs, one to the person/enttity they are sending coin to and one change (https://en.bitcoin.it/wiki/Change) output.

Many businesses who send many transactions per day will consolidate transactions such that they send coin to many individuals/entities in a single transaction.

Here is an example (https://btc.com/617892b0df5e051e0108e5bc9e5a35b1442079c2ba59e67ff5ca206094fdd8b2) of a recent transaction that has more than two outputs.


I thought about required_signatures parameter for outputs. This parameter doesn't include P2SH Multisig. It shows "1" for multisigs addresses. I am right?


Title: Re: Bitcoin-etl transactions.json what index mean ?
Post by: PrimeNumber7 on October 06, 2020, 07:21:44 PM
Ok, thanks :) When it comes to outputs, can they be always "1" ? I haven't found any ouput > 1
The transaction you referenced in the OP has two outputs.

It is very common for an individual to have transactions that have exactly two outputs, one to the person/enttity they are sending coin to and one change (https://en.bitcoin.it/wiki/Change) output.

Many businesses who send many transactions per day will consolidate transactions such that they send coin to many individuals/entities in a single transaction.

Here is an example (https://btc.com/617892b0df5e051e0108e5bc9e5a35b1442079c2ba59e67ff5ca206094fdd8b2) of a recent transaction that has more than two outputs.


I thought about required_signatures parameter for outputs. This parameter doesn't include P2SH Multisig. It shows "1" for multisigs addresses. I am right?
You cannot tell if an output needs to be signed by more than one private key.

The only exception to the above is if that address has previously signed a transaction that you can review.


Title: Re: Bitcoin-etl transactions.json parameters explanation
Post by: kristiano92 on October 08, 2020, 09:35:14 AM
Ok, thanks :) When it comes to outputs, can they be always "1" ? I haven't found any ouput > 1
The transaction you referenced in the OP has two outputs.

It is very common for an individual to have transactions that have exactly two outputs, one to the person/enttity they are sending coin to and one change (https://en.bitcoin.it/wiki/Change) output.

Many businesses who send many transactions per day will consolidate transactions such that they send coin to many individuals/entities in a single transaction.

Here is an example (https://btc.com/617892b0df5e051e0108e5bc9e5a35b1442079c2ba59e67ff5ca206094fdd8b2) of a recent transaction that has more than two outputs.


I thought about required_signatures parameter for outputs. This parameter doesn't include P2SH Multisig. It shows "1" for multisigs addresses. I am right?
You cannot tell if an output needs to be signed by more than one private key.

The only exception to the above is if that address has previously signed a transaction that you can review.

Do you mean that is it possible only when I have input ?


I have one more question about bitcoin-etl. What is the best way to recognize witness transactions ? What parameters should be used ? Addresses , which starts with 3.. could be segwit or non-segwit (multisig)