Bitcoin Forum
November 09, 2024, 12:12:09 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to know the addresses that have sent BTCs to an address?  (Read 759 times)
F-J (OP)
Newbie
*
Offline Offline

Activity: 2
Merit: 0


View Profile
December 22, 2013, 06:08:58 PM
 #1

Hi,

I need to know which BTC addresses have sent BTCs to one of my addresses.

I've googled and have saw some advices that the way to go is by the Transaction ID, but I'm not getting on how to do it.

For example, to get my last transaction, I do:
Code:
listtransactions '*' 1 0


I will get:
Code:
{
"account" : "",
"address" : "XXXXxxxXXxxxXXxxxxxxxXX",
"category" : "receive",
"amount" : 0.1111,
"confirmations" : 111,
"blockhash" : "00000000000000000000000000000000000000000000000",
"blockindex" : 111,
"blocktime" : 111111111111,
"txid" : "555555555555555555555555555555555555555555555555555",
"time" : 11111111111,
"timereceived" : 11111111111
}

I saw this example here (http://bitcoin.stackexchange.com/questions/3896/how-to-findout-the-sender-of-a-transaction):
Code:
txid = <relevant transaction id>
addresses = []
raw_tx = decoderawtransaction(getrawtransaction(txid))
for(input in raw_tx['vin']) {
  input_raw_tx = decoderawtransaction(getrawtransaction(input['txid']))
  addresses.push(input_raw_tx['vout'][input['vout']]['scriptPubKey']['addresses'][0])
}

This code above fails me in this line "input_raw_tx = decoderawtransaction(getrawtransaction(input['txid']))" when getting the "getrawtransaction(input['txid'])"

The error is code -5

Any clues on how to do this?


Thanks
michagogo
Member
**
Offline Offline

Activity: 80
Merit: 10


View Profile
December 22, 2013, 08:04:23 PM
 #2

First, there is no from address. You should just about never be using the previous address coins were sent to as anything resembling a "from" address. However, to make that code snippet work, you need to have Bitcoin's txindex option on -- and enabling that requires a reindex. If you're willing to reindex, stop bitcoind, and then start it again with -txindex and -reindex. You should only need to do this once. This makes it create an index of all transactions, rather than just unspent ones.
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!