Pages:
Author

Topic: Get the address sent from (Read 2405 times)

sr. member
Activity: 440
Merit: 250
November 10, 2012, 01:15:13 PM
#27
Ah, you can also get the BTC amount associated with each "sending" address. Substitute the printf command with:

printf "Input address: ",rawtxdec_in['outputs'][vout_number]['destination_address'], "Amount: ", rawtxdec_in['outputs'][vout_number]['amount']

Or something similar. You'll have to read the documentation to find out the precise syntax, structure, and array keys.
sr. member
Activity: 440
Merit: 250
November 10, 2012, 09:06:16 AM
#26
You can get the previous addresses.  The transaction structure contains a list of prior transaction outputs which it is redeeming and which, necessarily, have never been spent before.  We get the list of those (txids,vout) pairs and find which address is associated with each output.  What about something like this pseudocode, where tx0 is the transaction which gave coins to your address:

%START PSEUDOCODE
rawtx = getrawtransaction(tx0)
rawtxdec = decoderawtransaction(rawtx)
for (input in rawtxdec['inputs'])    %LOOP OVER ALL INPUTS
   {
   tx_in=input.txid
   vout_number=input.vout
   rawtx_in = getrawtransaction(tx_in)
   rawtxdec_in = decoderawtransaction(rawtx_in)
   printf "Input address: ",rawtxdec_in['outputs'][vout_number]['destination_address']
   }
%ENDPSEUDOCODE

rawtxdec['inputs'] is an array of transaction inputs, each element of which contains the TXID and VOUT of prior outputs it is redeeming.
rawtxdec['outputs'] is an array of transaction outputs.
rawtxdec['outputs'][vout_number] is a single transaction output we are interested in.
rawtxdec['outputs'][vout_number]['destination_address'] is the address of that output.

I understand that the sender of the transaction might not know anything about the sending address (it could be change from a previous tx), and they might be using a web wallet and so not even have that address in their own personal wallet.
hero member
Activity: 740
Merit: 501
November 10, 2012, 08:34:50 AM
#25
I have an address in bitcoind and I would like to receive the first address that bitcoins were sent from in Bitcoin.net.

For example if I have an address 37muSN5ZrukVTvyVh3mT5Zc5ew9L9CBare with a balance of 9.5 coins, I would like to receive the address those coins were sent from. This is a problem since I will have multiple addresses each with a couple of coins and I want to get the addresses the coins were sent from for each address.

The Raw Transactions API will give you this info.


Filter the results of listunspent for the output address to learn the transaction ids.  Then get each transaction and pull the first input for each.

use:
getrawtransaction
then for the output of that,
decoderawtransaction

 - http://en.bitcoin.it/wiki/Raw_Transactions

[Edit: See the next few posts to tell you why there is no "from" addresses with Bitcoin.   The right way to know what invoice a payment is for (or what customer sent the payment) is to give out a new address for each transaction.]

I list the transactions:
[
  {
    "account": "testacc",
    "address": "18LaYLjk4ktP5PvHZ9X2afBW1uoJxhBZWN",
    "category": "receive",
    "amount": 5E-05,
    "confirmations": 213,
    "blockhash": "00000000000002ab8a627d4d88385a1c8b11b5bcc1de1ebee90a747e15ed87
d4",
    "blockindex": 171,
    "blocktime": 1352434315,
    "txid": "0601b1b121e2b8c7db0ab57620c97f3a8cefefa626a1838718baa8154f9fea84",
    "time": 1352434315,
    "timereceived": 1352550740
  },
  {
    "account": "testacc",
    "address": "18LaYLjk4ktP5PvHZ9X2afBW1uoJxhBZWN",
    "category": "receive",
    "amount": 5E-05,
    "confirmations": 180,
    "blockhash": "000000000000002afc8044a5b98e2634b8058e90e4ee9e22ebd722566c24bf
28",
    "blockindex": 268,
    "blocktime": 1352457915,
    "txid": "b57619177c9cb1031e9e867246751e810593ef1b9520e70de50f09ebb6503b7c",
    "time": 1352457915,
    "timereceived": 1352551000
  }
]
Then I pull a transaction:
{
  "amount": 5E-05,
  "confirmations": 213,
  "blockhash": "00000000000002ab8a627d4d88385a1c8b11b5bcc1de1ebee90a747e15ed87d4
",
  "blockindex": 171,
  "blocktime": 1352434315,
  "txid": "0601b1b121e2b8c7db0ab57620c97f3a8cefefa626a1838718baa8154f9fea84",
  "time": 1352434315,
  "timereceived": 1352550740,
  "details": [
    {
      "account": "testacc",
      "address": "18LaYLjk4ktP5PvHZ9X2afBW1uoJxhBZWN",
      "category": "receive",
      "amount": 5E-05
    }
  ]
}
Still no relevant information about where did it came from?
kjj
legendary
Activity: 1302
Merit: 1026
November 07, 2012, 03:36:47 PM
#24
How do I send back coins like satosh dice?

You were already given the answer both in general terms and with the exact RPC call?  I mean kjj gave you exactly the answer you were asking for (even though it is advised not to use it)

https://bitcointalksearch.org/topic/m.1322012


Bitcoin .NET C# doesn't contain these functions.

Ahh, I think you might need to do some reading on what the RPC API is, and how to use it.  I suggest starting with the link I posted earlier.

Are you wondering how to use the RPC service from .net?
hero member
Activity: 740
Merit: 501
November 07, 2012, 01:21:13 PM
#23
How do I send back coins like satosh dice?

You were already given the answer both in general terms and with the exact RPC call?  I mean kjj gave you exactly the answer you were asking for (even though it is advised not to use it)

https://bitcointalksearch.org/topic/m.1322012


Bitcoin .NET C# doesn't contain these functions.
donator
Activity: 1218
Merit: 1079
Gerald Davis
November 07, 2012, 12:45:57 PM
#22
How do I send back coins like satosh dice?

You were already given the answer both in general terms and with the exact RPC call?  I mean kjj gave you exactly the answer you were asking for (even though it is advised not to use it)

https://bitcointalksearch.org/topic/m.1322012
hero member
Activity: 740
Merit: 501
November 07, 2012, 12:07:44 PM
#21
I already got it 100 times by now, I undestand that it isn't the most reliable method, what code would I use to get this address?

The correct answer to your question is mu (please read G.E.B. to find out exactly what that means - and I hope you enjoy the experience as much as I did as it is IMHO one of the best books ever written).

Smiley

For the lazy:

Quote
2. /moo/ The correct answer to the classic trick question "Have you stopped beating your wife yet?". Assuming that you have no wife or you have never beaten your wife, the answer "yes" is wrong because it implies that you used to beat your wife and then stopped, but "no" is worse because it suggests that you have one and are still beating her. According to various Discordians and Douglas Hofstadter the correct answer is usually "mu", a Japanese word alleged to mean "Your question cannot be answered because it depends on incorrect assumptions".


How do I send back coins like satosh dice?
legendary
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
November 07, 2012, 10:43:33 AM
#20
I already got it 100 times by now, I undestand that it isn't the most reliable method, what code would I use to get this address?

The correct answer to your question is mu (please read G.E.B. to find out exactly what that means - and I hope you enjoy the experience as much as I did as it is IMHO one of the best books ever written).

Smiley

For the lazy:

Quote
2. /moo/ The correct answer to the classic trick question "Have you stopped beating your wife yet?". Assuming that you have no wife or you have never beaten your wife, the answer "yes" is wrong because it implies that you used to beat your wife and then stopped, but "no" is worse because it suggests that you have one and are still beating her. According to various Discordians and Douglas Hofstadter the correct answer is usually "mu", a Japanese word alleged to mean "Your question cannot be answered because it depends on incorrect assumptions".
legendary
Activity: 3472
Merit: 4801
November 07, 2012, 10:25:49 AM
#19
As I stated if the coins came from "coinbase" then there simply *is no return address* - do you get it now?

(also as was pointed out previously if the user was using a web-wallet service or some sort of "mixer" service the input address can in no way be reliably used to send coins back to the original sender - hence the warnings given to people wanting to play with satosh dice)


I already got it 100 times by now, I undestand that it isn't the most reliable method, what code would I use to get this address?

By now I'd think you would have noticed that you are getting a lot of responses saying that you can't get what you are asking for, and very few (any?) responses offering exactly what you are asking for.

I'd think this would seem to indicate one of the following:

  • The entire bitcoin community is having fun at your expense by withholding from you the information you are asking for
  • The entire bitcoin community is misunderstanding what you are asking for, perhaps you should try explaining it better.
  • You aren't understanding what you are asking for, perhaps you should think about it a bit and try explaining it better
  • You are asking for something that isn't available, perhaps you should consider a better way to accomplish your goal

Are there other possibilities here I haven't thought of?  Which of the above do you think is most likely?
hero member
Activity: 740
Merit: 501
November 07, 2012, 10:17:41 AM
#18
As I stated if the coins came from "coinbase" then there simply *is no return address* - do you get it now?

(also as was pointed out previously if the user was using a web-wallet service or some sort of "mixer" service the input address can in no way be reliably used to send coins back to the original sender - hence the warnings given to people wanting to play with satosh dice)


I already got it 100 times by now, I undestand that it isn't the most reliable method, what code would I use to get this address?
legendary
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
November 07, 2012, 09:45:13 AM
#17
As I stated if the coins came from "coinbase" then there simply *is no return address* - do you get it now?

(also as was pointed out previously if the user was using a web-wallet service or some sort of "mixer" service the input address can in no way be reliably used to send coins back to the original sender - hence the warnings given to people wanting to play with satosh dice)
hero member
Activity: 740
Merit: 501
November 07, 2012, 09:35:45 AM
#16
I understand all this, it's still irrelevant for what I want to use it, I just need it.

I think we have already explained that what you think you need simply does not exist - so can you now try once again to explain what you actually need (without re-stating what is in the thread title)?


The address the coins were last owned by, return address, you get the point.
legendary
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
November 07, 2012, 09:11:07 AM
#15
I understand all this, it's still irrelevant for what I want to use it, I just need it.

I think we have already explained that what you think you need simply does not exist - so can you now try once again to explain what you actually need (without re-stating what is in the thread title)?
kjj
legendary
Activity: 1302
Merit: 1026
November 07, 2012, 09:03:18 AM
#14
The answers are in this thread already.  What are you having problems with?

Are you wondering how to use the RPC service from .net?

Yes, I am wondering what calls to make.

The Raw Transactions API will give you this info.

Filter the results of listunspent for the output address to learn the transaction ids.  Then get each transaction and pull the first input for each.

use:
getrawtransaction
then for the output of that,
decoderawtransaction

 - http://en.bitcoin.it/wiki/Raw_Transactions
hero member
Activity: 740
Merit: 501
November 07, 2012, 08:55:29 AM
#13
I understand that the last address received from may not be the correct one and if you send there they might be lost but I still need it.

Perhaps it would help if you could tell us what exactly you need this for?

Also I hope you realise that it is even possible that funds could be sent to you from "coinbase" (e.g. if a miner were offering this as some kind of anonymising service) in which case there are no real inputs to tie your output to (apart from those of every tx that paid any fees in the entire block if that's of any use at all).


I understand all this, it's still irrelevant for what I want to use it, I just need it.

The answers are in this thread already.  What are you having problems with?

Are you wondering how to use the RPC service from .net?

Yes, I am wondering what calls to make.
legendary
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
November 07, 2012, 08:16:17 AM
#12
I understand that the last address received from may not be the correct one and if you send there they might be lost but I still need it.

Perhaps it would help if you could tell us what exactly you need this for?

Also I hope you realise that it is even possible that funds could be sent to you from "coinbase" (e.g. if a miner were offering this as some kind of anonymising service) in which case there are no real inputs to tie your output to (apart from those of every tx that paid any fees in the entire block if that's of any use at all).
kjj
legendary
Activity: 1302
Merit: 1026
November 07, 2012, 07:18:34 AM
#11
The answers are in this thread already.  What are you having problems with?

Are you wondering how to use the RPC service from .net?
hero member
Activity: 740
Merit: 501
November 07, 2012, 06:04:54 AM
#10
*bump*
hero member
Activity: 740
Merit: 501
November 06, 2012, 04:52:29 AM
#9
Anyone? I am still looking for how to do it
hero member
Activity: 740
Merit: 501
November 05, 2012, 04:24:01 PM
#8
Look at the transaction that you got.  The input part of that transaction will have a list of transaction outputs redeemed.  For each of them, look up the transaction and check the scriptpubkey part of that output.

But you really should figure out a way to do whatever you are doing that doesn't require that, because no matter how much you think you need it, the system totally doesn't work that way.  Transactions do not have From: addresses.

Is there any way to do it with Bitcoin .NET C#? I have been trying but can't seem to figure it out
Pages:
Jump to: