Title: How do you get the SENDING address with PHP? Post by: c789 on September 24, 2012, 02:59:24 AM I've been using the guide at https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list, which has been very helpful, but it says nothing about getting the sending address.
Title: Re: How do you get the SENDING address with PHP? Post by: Stephen Gornick on September 24, 2012, 03:09:00 AM I've been using the guide at https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list, which has been very helpful, but it says nothing about getting the sending address. It is in there ... getrawtransaction - http://en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list - http://en.bitcoin.it/wiki/Raw_Transactions Title: Re: How do you get the SENDING address with PHP? Post by: c789 on September 24, 2012, 03:30:05 AM I must be doing something wrong. I can't see the sending address, which is known to me, anywhere.
$txid is the transaction id, which is known. Quote $txfr = $bitcoin->getrawtransaction($txid,1); print_r(array_values($txfr)); Title: Re: How do you get the SENDING address with PHP? Post by: c789 on September 24, 2012, 05:12:43 AM Using 0.7 version of bitcoind, and the JSON-RPC PHP API.
Title: Re: How do you get the SENDING address with PHP? Post by: c789 on September 24, 2012, 06:53:32 PM No errors. Now I get a paragraph of output, starting with:
Quote array(10) { ["hex"]=> string(678) ...and so on."01000000024b32b25694be1b455df8bb4d565696effa1 I don't see the sending address in it. Do you know the name of the key I should be looking for? Thanks for your help! Title: Re: How do you get the SENDING address with PHP? Post by: c789 on September 24, 2012, 07:28:08 PM Hmmm. Would it be ok to msg you the full output, and if you can show me the sending address (the txid will be supplied), I'll send you 0.1BTC?
Title: Re: How do you get the SENDING address with PHP? Post by: c789 on September 24, 2012, 11:40:06 PM Some helpful tips so far, but if anyone knows of a way to get the sender's address of a payment that I've received, using PHP, I'd love to see it.
Title: Re: How do you get the SENDING address with PHP? Post by: kjj on September 25, 2012, 12:59:32 AM Your call to getrawtransaction just returns a huge hex string. You can feed that back into the decoderawtransaction RPC call to decode it.
From there, you have an array of transaction objects in vin. Each vin object has a member named txid, those are the transaction IDs of the transactions that were redeemed. You can take each of them and run them through getrawtransaction and then decoderawtransaction. That should give you the last address that had control of (some of) the coins that were sent to you. Please note that there is absolutely positively no such concept of "sending address" in bitcoin. If you use the addresses that you coax out of the raw transaction API and send money to them, you are doing it wrong, and you will surely be sending coins to random people before long. Title: Re: How do you get the SENDING address with PHP? Post by: c789 on September 25, 2012, 03:58:00 AM What you're saying makes a lot of sense and explains why I couldn't locate an easy answer. So, how do places like BitLotto operate? From what I can tell, a person sends Bitlotto a BitLotto-generated address for a particular draw. If the person wins, how would BitLotto know who to pay? BitLotto (and other online transaction sites) must have some way of knowing the source of funds.
Title: Re: How do you get the SENDING address with PHP? Post by: kjj on September 25, 2012, 04:23:16 AM What you're saying makes a lot of sense and explains why I couldn't locate an easy answer. So, how do places like BitLotto operate? From what I can tell, a person sends Bitlotto a BitLotto-generated address for a particular draw. If the person wins, how would BitLotto know who to pay? BitLotto (and other online transaction sites) must have some way of knowing the source of funds. They are probably doing something like what you are doing (more likely by reading the block chain directly, instead of making a ton of RPC calls). But please don't. Title: Re: How do you get the SENDING address with PHP? Post by: mem on September 25, 2012, 05:45:45 AM What you're saying makes a lot of sense and explains why I couldn't locate an easy answer. So, how do places like BitLotto operate? From what I can tell, a person sends Bitlotto a BitLotto-generated address for a particular draw. If the person wins, how would BitLotto know who to pay? BitLotto (and other online transaction sites) must have some way of knowing the source of funds. Its not hard, its just not easy. Some devs loathe Satoshidice and wrongly call it blockchain spam (as if increased use is a bad thing). So there is a fair bit of misinformation and obfuscation of how to achieve this. Writing a gambling site hey ? :) We are seeing more and more of these instant payout games. Satoshidice (http://Satoshidice.com) being the most popular currently (uses ABE i suspect). SatoshiRoulette (http://SatoshiRoulette.com) did a clean room implementation (apparently) of satoshidices payment system. FlipBitcoin (http://flipbitcoin.com/) - Same system. BitcoinLotto (http://www.bitlotto.com/) Same system (may still use ABE). BTCDice is another but I cannot endorse them currently. Im not sure if they would help the competition but it would not hurt dropping them an email ;) I believe SD and Bitcoinlotto previously used a local copy of ABE, but as you can now achieve the same using api calls Id expect they would drop the heavy ABE in favor of much lighter API calls. I am obviously biased on this topic, but here is my stance regardless:
Title: Re: How do you get the SENDING address with PHP? Post by: c789 on September 25, 2012, 06:46:20 AM The more I learn about Bitcoin, the more I am impressed with its genius. This is an amazing system: transparent and verifiable, yet anonymous to a large degree if so wanted; pretty much cheat-proof; mathematically sound...I could go on but I'm pretty tired.
This presents some challenges for me, but I think I can still do what I need to do by invoking some programming kung-fu. We'll see. I love a good puzzle/challenge. Thanks to all for their input :) Title: Re: How do you get the SENDING address with PHP? Post by: mem on September 25, 2012, 07:24:32 AM The more I learn about Bitcoin, the more I am impressed with its genius. This is an amazing system: transparent and verifiable, yet anonymous to a large degree if so wanted; pretty much cheat-proof; mathematically sound...I could go on but I'm pretty tired. This presents some challenges for me, but I think I can still do what I need to do by invoking some programming kung-fu. We'll see. I love a good puzzle/challenge. Thanks to all for their input :) All the info you need is on the wiki, study this page: https://en.bitcoin.it/wiki/Transaction If anyone is interested I can sell my coinflip.pl code I wrote several months ago ;) pm me offers. It does senders address look up ala SD style. Title: Re: How do you get the SENDING address with PHP? Post by: Greedi on September 25, 2012, 02:08:04 PM What you're saying makes a lot of sense and explains why I couldn't locate an easy answer. So, how do places like BitLotto operate? From what I can tell, a person sends Bitlotto a BitLotto-generated address for a particular draw. If the person wins, how would BitLotto know who to pay? BitLotto (and other online transaction sites) must have some way of knowing the source of funds. Its not hard, its just not easy. Some devs loathe Satoshidice and wrongly call it blockchain spam (as if increased use is a bad thing). So there is a fair bit of misinformation and obfuscation of how to achieve this. Writing a gambling site hey ? :) We are seeing more and more of these instant payout games. Satoshidice (http://Satoshidice.com) being the most popular currently (uses ABE i suspect). SatoshiRoulette (http://SatoshiRoulette.com) did a clean room implementation (apparently) of satoshidices payment system. FlipBitcoin (http://flipbitcoin.com/) - Same system. BitcoinLotto (http://www.bitlotto.com/) Same system (may still use ABE). BTCDice is another but I cannot endorse them currently. Im not sure if they would help the competition but it would not hurt dropping them an email ;) I believe SD and Bitcoinlotto previously used a local copy of ABE, but as you can now achieve the same using api calls Id expect they would drop the heavy ABE in favor of much lighter API calls. I am obviously biased on this topic, but here is my stance regardless:
LTCDice.net is using perl to read the blockchain from litecoind ( have also abe setup as a second read database if litecoind crash ) the perl script read ALL Tx that come thu litecoind, and if it see one of the LTCDIce addy in the tx it read it to find the sender addy to give the payout |