Bitcoin Forum
May 11, 2024, 09:00:12 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How parse multisig transactions?  (Read 529 times)
Frodek (OP)
Member
**
Offline Offline

Activity: 138
Merit: 25


View Profile
January 11, 2017, 11:37:07 AM
Merited by ABCbits (1)
 #1

Is transaction in block 387773 : https://blockchain.info/tx/67fd12e0965a36af70133a38238d0fd383b4087598f763aa0a41655cfb9bed3e
There is one usual script:
Code:
OP_DUP OP_HASH160 7e78ee4ad5245f4d7b045526855bcb27f0e6798f OP_EQUALVERIFY OP_CHECKSIG 
but is also
Code:
OP_1 024d75b5b6baa5f862eab12310b0554e584c364d927496502a4a05cf48e080b543 0314eeb131f579774c4c7d5120e0b0d62ca9d8e7c810a6e258eb67991b4b367e17 038c6e56b627e7ca073c6391828e399d3d9ecb90baddf5f2cb2e9bbd29151d9716 OP_3 OP_CHECKMULTISIG 
These addresses are not parsed by blockchain.info. These addreses I can get from
  • 024d75b5b6baa5f862eab12310b0554e584c364d927496502a4a05cf48e080b543
  • 0314eeb131f579774c4c7d5120e0b0d62ca9d8e7c810a6e258eb67991b4b367e17
  • 038c6e56b627e7ca073c6391828e399d3d9ecb90baddf5f2cb2e9bbd29151d9716
lengths = 33 bytes per address?
How I guest that are 3*33 bytes? First opcode is OP_1, but last is OP_3, but it is after three addreses. How works stack?
I need general algorithm for 99.9% transactions
1715418012
Hero Member
*
Offline Offline

Posts: 1715418012

View Profile Personal Message (Offline)

Ignore
1715418012
Reply with quote  #2

1715418012
Report to moderator
1715418012
Hero Member
*
Offline Offline

Posts: 1715418012

View Profile Personal Message (Offline)

Ignore
1715418012
Reply with quote  #2

1715418012
Report to moderator
1715418012
Hero Member
*
Offline Offline

Posts: 1715418012

View Profile Personal Message (Offline)

Ignore
1715418012
Reply with quote  #2

1715418012
Report to moderator
"With e-currency based on cryptographic proof, without the need to trust a third party middleman, money can be secure and transactions effortless." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715418012
Hero Member
*
Offline Offline

Posts: 1715418012

View Profile Personal Message (Offline)

Ignore
1715418012
Reply with quote  #2

1715418012
Report to moderator
1715418012
Hero Member
*
Offline Offline

Posts: 1715418012

View Profile Personal Message (Offline)

Ignore
1715418012
Reply with quote  #2

1715418012
Report to moderator
mocacinno
Legendary
*
Offline Offline

Activity: 3388
Merit: 4922


https://merel.mobi => buy facemasks with BTC/LTC


View Profile WWW
January 11, 2017, 11:53:57 AM
Merited by ABCbits (3)
 #2

Here you go, just decoded the hex of the above transaction:

Code:
{
    "addresses": [
        "4QiogzmMMeatiJE7QCvzz7Rf86euJC6NFp",
        "1CXj1bLMekh5XQJt9pygt6xkXVGWtKW3QW",
        "4DhpuqdUF3dwQJQh4AmR5tDhKLpNHExNmj"
    ],
    "block_height": -1,
    "block_index": -1,
    "confirmations": 0,
    "double_spend": false,
    "fees": 10000,
    "hash": "67fd12e0965a36af70133a38238d0fd383b4087598f763aa0a41655cfb9bed3e",
    "inputs": [
        {
            "addresses": [
                "1CXj1bLMekh5XQJt9pygt6xkXVGWtKW3QW"
            ],
            "output_index": 2,
            "output_value": 40582730,
            "prev_hash": "4e98e2c3dc30a588bd55b6dafffa7e7a14ba44e5c5b02f6f1475a34724546a7d",
            "script": "47304402202830f0177874af11c2e7c5d8e026e9e98b689ecf65702406e2e65363a51027fb0220501c1ef7217dcb5d4e73392797f12a21743c2885a5d665f7eb91fee2012f8c5a0121038c6e56b627e7ca073c6391828e399d3d9ecb90baddf5f2cb2e9bbd29151d9716",
            "script_type": "pay-to-pubkey-hash",
            "sequence": 4294967295
        }
    ],
    "lock_time": 0,
    "outputs": [
        {
            "addresses": [
                "4DhpuqdUF3dwQJQh4AmR5tDhKLpNHExNmj"
            ],
            "script": "5121037d75b5b6baa5f862ea9f4963cb3b4e584c36ccd51996502a4a05cf48e081b5d6210314eeb131f579774c57053250ced3b945c7bc86ac74dfcc318448ca5409732c9221038c6e56b627e7ca073c6391828e399d3d9ecb90baddf5f2cb2e9bbd29151d971653ae",
            "script_type": "pay-to-multi-pubkey-hash",
            "value": 7800
        },
        {
            "addresses": [
                "4QiogzmMMeatiJE7QCvzz7Rf86euJC6NFp"
            ],
            "script": "5121024d75b5b6baa5f862eab12310b0554e584c364d927496502a4a05cf48e080b543210314eeb131f579774c4c7d5120e0b0d62ca9d8e7c810a6e258eb67991b4b367e1721038c6e56b627e7ca073c6391828e399d3d9ecb90baddf5f2cb2e9bbd29151d971653ae",
            "script_type": "pay-to-multi-pubkey-hash",
            "value": 7800
        },
        {
            "addresses": [
                "1CXj1bLMekh5XQJt9pygt6xkXVGWtKW3QW"
            ],
            "script": "76a9147e78ee4ad5245f4d7b045526855bcb27f0e6798f88ac",
            "script_type": "pay-to-pubkey-hash",
            "value": 40557130
        }
    ],
    "preference": "medium",
    "received": "2017-01-11T11:53:40.18000422Z",
    "relayed_by": "54.159.220.113",
    "size": 419,
    "total": 40572730,
    "ver": 1,
    "vin_sz": 1,
    "vout_sz": 3
}

How to do it yourself?

bitcoin-cli getrawtransaction 67fd12e0965a36af70133a38238d0fd383b4087598f763aa0a41655cfb9bed3e

bitcoin-cli decoderawtransaction 01000000017d6a542447a375146f2fb0c5e544ba147a7efaffdab655bd88a530dcc3e2984e02000 0006a47304402202830f0177874af11c2e7c5d8e026e9e98b689ecf65702406e2e65363a51027fb 0220501c1ef7217dcb5d4e73392797f12a21743c2885a5d665f7eb91fee2012f8c5a0121038c6e5 6b627e7ca073c6391828e399d3d9ecb90baddf5f2cb2e9bbd29151d9716ffffffff03781e000000 000000695121037d75b5b6baa5f862ea9f4963cb3b4e584c36ccd51996502a4a05cf48e081b5d62 10314eeb131f579774c57053250ced3b945c7bc86ac74dfcc318448ca5409732c9221038c6e56b6 27e7ca073c6391828e399d3d9ecb90baddf5f2cb2e9bbd29151d971653ae781e000000000000695 121024d75b5b6baa5f862eab12310b0554e584c364d927496502a4a05cf48e080b543210314eeb1 31f579774c4c7d5120e0b0d62ca9d8e7c810a6e258eb67991b4b367e1721038c6e56b627e7ca073 c6391828e399d3d9ecb90baddf5f2cb2e9bbd29151d971653ae4ada6a02000000001976a9147e78 ee4ad5245f4d7b045526855bcb27f0e6798f88ac00000000


OR... In one go:
bitcoin-cli decoderawtransaction $(bitcoin-cli getrawtransaction 67fd12e0965a36af70133a38238d0fd383b4087598f763aa0a41655cfb9bed3e)


OR... Place ?format=hex * after the blockchain.info url, copy the hex, paste it in https://live.blockcypher.com/btc/decodetx/ and look at the output Wink

* https://blockchain.info/tx/67fd12e0965a36af70133a38238d0fd383b4087598f763aa0a41655cfb9bed3e?format=hex

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
Frodek (OP)
Member
**
Offline Offline

Activity: 138
Merit: 25


View Profile
January 11, 2017, 12:01:54 PM
 #3

It is important information that addresses are:
  • "4QiogzmMMeatiJE7QCvzz7Rf86euJC6NFp"
  • "1CXj1bLMekh5XQJt9pygt6xkXVGWtKW3QW"
  • "4DhpuqdUF3dwQJQh4AmR5tDhKLpNHExNmj
but I wanna not use bitcoin-cli because I must fast parse all >400'000 blocks and millions (billions?) transactions.

mocacinno
Legendary
*
Offline Offline

Activity: 3388
Merit: 4922


https://merel.mobi => buy facemasks with BTC/LTC


View Profile WWW
January 11, 2017, 12:04:56 PM
 #4

It is important information that addresses are:
  • "4QiogzmMMeatiJE7QCvzz7Rf86euJC6NFp"
  • "1CXj1bLMekh5XQJt9pygt6xkXVGWtKW3QW"
  • "4DhpuqdUF3dwQJQh4AmR5tDhKLpNHExNmj
but I wanna not use bitcoin-cli because I must fast parse all >400'000 blocks and millions (billions?) transactions.



You can use bitcoind's json-rpc to script this process... Other than that: you do need to get the raw transaction data from somewhere. As soon as you have the raw transaction data, you could use several different tools to decode this data... For example, python has some very nice tools for this job... But you still need a source of the raw data. You could either use your node for this, or an API, altough i seriously doubt you'd be able to find an API that will allow you to fetch billions of transactions.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3388
Merit: 6635


Just writing some code


View Profile WWW
January 11, 2017, 03:52:23 PM
 #5

These addresses are not parsed by blockchain.info. These addreses I can get from
  • 024d75b5b6baa5f862eab12310b0554e584c364d927496502a4a05cf48e080b543
  • 0314eeb131f579774c4c7d5120e0b0d62ca9d8e7c810a6e258eb67991b4b367e17
  • 038c6e56b627e7ca073c6391828e399d3d9ecb90baddf5f2cb2e9bbd29151d9716
lengths = 33 bytes per address?
How I guest that are 3*33 bytes? First opcode is OP_1, but last is OP_3, but it is after three addreses. How works stack?
I need general algorithm for 99.9% transactions
No, these are not addresses. These are public keys. Multisig redeemscripts contain public keys, not addresses.

To convert these to addresses, first you must hash them with sha256, then the result with ripemd160 and then perform base58check encoding on the hash in order to get the address.

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!