Bit-Wasp / bitcoin-php

Bitcoin implementation in PHP
The Unlicense
1.05k stars 419 forks source link

How to get address from scriptSig data in getrawtransaction #889

Open jackyxie opened 3 years ago

jackyxie commented 3 years ago

such as txid: 892f506a224d04000aaa87cca90d0e9d3be8958ff7168c19a16b03dce3c9381a How can I convert the scriptSig data to address like the block explorer shows.

{
    "result": {
        "txid": "892f506a224d04000aaa87cca90d0e9d3be8958ff7168c19a16b03dce3c9381a",
        "hash": "892f506a224d04000aaa87cca90d0e9d3be8958ff7168c19a16b03dce3c9381a",
        "version": 1,
        "size": 257,
        "vsize": 257,
        "weight": 1028,
        "locktime": 0,
        "vin": [
            {
                "txid": "46555568e7020bbf7c1ca9180aab7ead7c18cee600c2009ba079229e10369d0f",
                "vout": 0,
                "scriptSig": {
                    "asm": "304402200ddd807f06cb31c0e4d37aacfd3b0ad833ac75291421b8592f651698e56127480220770489c88f5dfb3bbc6e7b9745bfc83296e7e58212bf68116cd1e62490c0e269[ALL] 0417633315d55d0187cba7dd7ca9acd41e3116e857e7f8073130963ba8cbf3bada8717160ce04274049de6b68823e883933e9332261fdc429b38ae43d1051b719b",
                    "hex": "47304402200ddd807f06cb31c0e4d37aacfd3b0ad833ac75291421b8592f651698e56127480220770489c88f5dfb3bbc6e7b9745bfc83296e7e58212bf68116cd1e62490c0e26901410417633315d55d0187cba7dd7ca9acd41e3116e857e7f8073130963ba8cbf3bada8717160ce04274049de6b68823e883933e9332261fdc429b38ae43d1051b719b"
                },
                "sequence": 4294967295
            }
        ],
        "vout": [
            {
                "value": 13.80000000,
                "n": 0,
                "scriptPubKey": {
                    "asm": "OP_DUP OP_HASH160 d3d426c3052e594cf2b241488bb71ca191a1c2bf OP_EQUALVERIFY OP_CHECKSIG",
                    "hex": "76a914d3d426c3052e594cf2b241488bb71ca191a1c2bf88ac",
                    "address": "1LK3j1rtrDLga88dzcPDUnhTTVvnhCHwi8",
                    "type": "pubkeyhash"
                }
            },
            {
                "value": 0.05000000,
                "n": 1,
                "scriptPubKey": {
                    "asm": "OP_DUP OP_HASH160 c3aa92015399ab7f29fa52046d58887cbdb386ce OP_EQUALVERIFY OP_CHECKSIG",
                    "hex": "76a914c3aa92015399ab7f29fa52046d58887cbdb386ce88ac",
                    "address": "1Jqb6qoYCnrT3tCCTw4fD9tXyKDdvm4GvE",
                    "type": "pubkeyhash"
                }
            }
        ],
        "hex": "01000000010f9d36109e2279a09b00c200e6ce187cad7eab0a18a91c7cbf0b02e768555546000000008a47304402200ddd807f06cb31c0e4d37aacfd3b0ad833ac75291421b8592f651698e56127480220770489c88f5dfb3bbc6e7b9745bfc83296e7e58212bf68116cd1e62490c0e26901410417633315d55d0187cba7dd7ca9acd41e3116e857e7f8073130963ba8cbf3bada8717160ce04274049de6b68823e883933e9332261fdc429b38ae43d1051b719bffffffff0200214152000000001976a914d3d426c3052e594cf2b241488bb71ca191a1c2bf88ac404b4c00000000001976a914c3aa92015399ab7f29fa52046d58887cbdb386ce88ac00000000",
        "blockhash": "000000000007339320664d21f36b7aae86e93802b39903dc699e70758c66b190",
        "confirmations": 637756,
        "time": 1280435130,
        "blocktime": 1280435130
    },
    "error": null,
    "id": "curltest"
}