Post
Topic
Board Development & Technical Discussion
Re: bitcoind/bitcoin-qt find source address of input
by
xblitz
on 04/10/2012, 22:12:18 UTC
Im trying to find the input address of a transaction but i can't seem to find out how..  anyone ?

Transactions do not have an input address.

They have one or more inputs, which may or may not correspond to one or more addresses.

If you have a CScript, then you can call:
Code:
bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet);
bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, std::vector& addressRet, int& nRequiredRet);

What are you trying to do?


Im just trying to output more info on the getrawtransaction rpc command for my personal bitcoins ...

lets say i have this transaction output (testnet):
Code:
{
    "hex" : "0100000001241514a48241f8af8abde6e6e3a657a6ff67beb2febdd5c1f4c62a71a1fb81c3000000008b483045022100a84c1b1a89938c4b16ec7749e9afc16f1a5ec26ddbb16e44739818f4bb85b74c02205d5ce610e0b9d80a373f305dbe67d7347d47470e4b3f6bd98e670ae511d98b920141043ac715efdea8815afc64d7441549e9114ba5d2658f0dcc1a75a8420e8af4791ad8ac46b2eec0463bc54946662e860717d92afe137f0a9fb1b7e1eea812487285ffffffff0200a3e111000000001976a9144988abbeb751dcd6e9f4ec40d50b84c99ed1426d88ac00c2eb0b000000001976a914539862a4bc81786df288265752e12bd7c0c0a6c488ac00000000",
    "txid" : "6aeb3de625830fcc45f675042e1ed98d2c08af72119f81a6e7819d55a6f8ab83",
    "version" : 1,
    "locktime" : 0,
    "vin" : [
        {
            "txid" : "c381fba1712ac6f4c1d5bdfeb2be67ffa657a6e3e6e6bd8aaff84182a4141524",
            "vout" : 0,
            "scriptSig" : {
                "asm" : "3045022100a84c1b1a89938c4b16ec7749e9afc16f1a5ec26ddbb16e44739818f4bb85b74c02205d5ce610e0b9d80a373f305dbe67d7347d47470e4b3f6bd98e670ae511d98b9201 043ac715efdea8815afc64d7441549e9114ba5d2658f0dcc1a75a8420e8af4791ad8ac46b2eec0463bc54946662e860717d92afe137f0a9fb1b7e1eea812487285",
                "hex" : "483045022100a84c1b1a89938c4b16ec7749e9afc16f1a5ec26ddbb16e44739818f4bb85b74c02205d5ce610e0b9d80a373f305dbe67d7347d47470e4b3f6bd98e670ae511d98b920141043ac715efdea8815afc64d7441549e9114ba5d2658f0dcc1a75a8420e8af4791ad8ac46b2eec0463bc54946662e860717d92afe137f0a9fb1b7e1eea812487285"
            },
            "sequence" : 4294967295
        }
    ],
    "vout" : [
        {
            "value" : 3.00000000,
            "n" : 0,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 4988abbeb751dcd6e9f4ec40d50b84c99ed1426d OP_EQUALVERIFY OP_CHECKSIG",
                "hex" : "76a9144988abbeb751dcd6e9f4ec40d50b84c99ed1426d88ac",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "mnDmM7j73HEqo746F1cLQZXwTXNPzLxc3W"
                ]
            }
        },
        {
            "value" : 2.00000000,
            "n" : 1,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 539862a4bc81786df288265752e12bd7c0c0a6c4 OP_EQUALVERIFY OP_CHECKSIG",
                "hex" : "76a914539862a4bc81786df288265752e12bd7c0c0a6c488ac",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "mo8xvtom7uyCwjh3MHzjdc8ZtWqAQp6xW7"
                ]
            }
        }
    ],
    "blockhash" : "00000000235841896dc9856e8a3ef214df8f5e4f2127e534ff18199616f8da00",
    "confirmations" : 103,
    "time" : 1349331390,
    "blocktime" : 1349331390
}

well i would like it to display the vin's address ... a bit like what blockchain.info displays!