Post
Topic
Board Development & Technical Discussion
Re: bitcoind/bitcoin-qt find source address of input
by
xblitz
on 04/10/2012, 23:40:00 UTC
Ok from the help of the people on freenode/bitcoin-dev I was able to resolve the addresses from the inputs of a transaction using the vin.prevout

so just for other people to know...  exmaple to find out the first input's address

Code:
CWalletTx wtx;
pwalletMain->GetTransaction(uint256(txid), wtx);     // get current transaction
CTxIn vin = wtx.vin[0];                                        //get first input
CWalletTx wtxPrev;                                     
pwalletMain->GetTransaction(vin.prevout.hash, wtxPrev);    // get the vin's previous transaction
CTxDestination source;
ExtractDestination(wtxPrev.vout[vin.prevout.n].scriptPubKey, source);  // extract the destination of the previous transaction's vout[n]
CBitcoinAddress addressSource(source);                // convert this to an address

print addressSource.ToString() // might as well print it!