3

I'm trying to get the senders address using the Bitcoin JSON RPC in C#. So I GetRawTransaction and then use the DecodeRawTransaction method to return my JSON object. I can see in the 'vout' of this the receiver addresses but I cannot see the sender addresses in the 'vin'.

Can anyone help? I may have phrased the question poorly so please ask if you need any more informations. Thanks.

1

The quote below is taken from my answer to How to implement a game like SatoshiDice? What you are looking for is addressed in this portion of my answer below.

Get the customer amount and payment address

  1. Call bitcoind getrawtransaction [The incoming transaction ID] 1. The 1 at the end will return the data in "verbose mode", which essentially the raw data in JSON format.

  2. From the raw transaction details, take the txid and vout from the vin object. With this transaction, again call bitcoind getrawtransaction on the txid.

  3. From these raw transaction details find the vout object, referenced by the vout index from step #2. Within this vout object, there should be a list of payment recipient addresses. Take and store the first address.

It is worth mentioning that a received payment can be a summation of numerous, former transactions to multiple recipient addresses. Getting an originators address isn't always straight-forward because the original payment could consist of multiple payments, from multiple sending addresses.

This is why that in my response to the SatoshiDice question I mention taking the first address from the second vout result.

You can safely assume that if someone sends you a payment originating from multiple accounts, they control all accounts. Ergo, picking the first in the list will give you correct address.

1

You can use BitcoinLib's GetTransactionSenderAddress method, however it is important that you understand that this is a hack, as bitcoin's protocol doesn't support a "sender's address", and will only work for fat clients such as bitcoin-core etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.