Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: Chida on January 13, 2014, 06:17:41 PM



Title: get sender address from RPC api
Post by: Chida on January 13, 2014, 06:17:41 PM
hi and sorry,

i try to understand this world and i try to crate a game/services.

My program in c# .net call the wallet by RPC, but how i can get sender address ?

for now i can get the transaction on specific account by listtransactions, i try getrawtransaction verbose or decoderawtransaction, but i can't get the address of sender.

Can you help me?


Title: Re: c# get sender address from RPC api
Post by: DBordello on January 13, 2014, 06:37:26 PM
This is a dangerous way to do things.  There isn't really a "sender address".  There are just previous outputs that are used as inputs. 

Additionally, people using online wallets, such as Mt.Gox, do not necessarily get credited for transactions that go back to the "sender address".


Title: Re: c# get sender address from RPC api
Post by: Chida on January 13, 2014, 07:15:39 PM
This is a dangerous way to do things.  There isn't really a "sender address".  There are just previous outputs that are used as inputs. 

Additionally, people using online wallets, such as Mt.Gox, do not necessarily get credited for transactions that go back to the "sender address".

but for betting or dice game is perfect.

and for service i think is possible use signed message.

even with the difficulty of the case and imperfections, I want to create services without user db.
I want to create services where you just have a wallet


Title: Re: get sender address from RPC api
Post by: Chida on January 14, 2014, 05:48:12 PM
From same code on github I understand that is possible or necessary analize all blockchain for get the sender address because is necessary analise all out address.
May be sufficient the single raw transaction?


Title: Re: get sender address from RPC api
Post by: DannyHamilton on January 14, 2014, 09:50:40 PM
I have a MUCH better idea!

Ask your users what address they would like to use for receiving payment!

Brilliant!  Each user can tell you where they want their payments sent.  You can store this in a database, and when you need to send a payment to your users, you can send it to the address that THEY TOLD YOU THEY WANT IT SENT TO.

This way you don't have to try and guess what address they want the bitcoins sent to.  Guessing is a bad idea.  It will result in you guessing incorrectly sometimes and will cause problems for you and for your users.  Since there is a very simple solution that does not involve guessing, why would you want to take the risks that are associated with the possibility of guessing incorrectly?


Title: Re: get sender address from RPC api
Post by: Chida on January 14, 2014, 10:06:12 PM
I have a MUCH better idea!

Ask your users what address they would like to use for receiving payment!

Brialliant!  Each user can tell you where they want their payments sent.  You can store this in a database, and when you need to send a payment to your users, you can send it to the address that THEY TOLD YOU THEY WANT IT SENT TO.

This way you don't have to try and guess what address they want the bitcoins sent to.  Guessing is a bad idea.  It will result in you guessing incorrectly sometimes and will cause problems for you and for your users.  Since there is a very simple solution that does not involve guessing, why would you want to take the risks that are associated with the possibility of guessing incorrectly?

it's the second that say is wrong. ok i try with signed message of wallet autentication.


Title: Re: get sender address from RPC api
Post by: andytoshi on February 08, 2014, 11:32:45 PM
What you're asking for is implemented in this C# wrapper: https://github.com/GeorgeKimionis/BitcoinLib (IRpcExtenderService -> GetTransactionSenderAddress)


Really? Immediately above the definition of this function there is the comment

Code:
        // Note: Be careful when using GetTransactionSenderAddress(es) as it just gives you an address owned by someone who previously controlled the transaction's outputs
        // which might not actually be the sender

which tells you that this function is horribly misnamed and actually does not do what the OP asked for.

Bitcoin transactions do not contain enough information to determine a sender address. There is therefore no way to obtain this information through the RPC interface.


Title: Re: get sender address from RPC api
Post by: Ins on February 09, 2014, 11:11:11 AM
To get sender's address, you can go two ways
1.
use getrawtransaction TXID
decoderawtransaction TXID
then convert first prev_out pubkey to address
2.
parse JSON http://blockchain.info/rawtx/TXID


Title: Re: get sender address from RPC api
Post by: maaku on February 09, 2014, 11:25:11 AM
To get sender's address, you can go two ways
1.
use getrawtransaction TXID
decoderawtransaction TXID
then convert first prev_out pubkey to address
2.
parse JSON http://blockchain.info/rawtx/TXID
This is a horrible idea, as has already been explained in detail in this very thread. Please don't do this: you will have customers lose money.


Title: Re: get sender address from RPC api
Post by: RangerK on May 18, 2014, 12:38:57 PM
To get sender's address, you can go two ways
1.
use getrawtransaction TXID
decoderawtransaction TXID
then convert first prev_out pubkey to address
2.
parse JSON http://blockchain.info/rawtx/TXID
This is a horrible idea, as has already been explained in detail in this very thread. Please don't do this: you will have customers lose money.

maaku, Isn't this exactly the standard by which Satoshi Dice and some other Bitcoin casinos operate?  My impression was that with standard standard clients and standard transactions, it's no problem.  It will fail only with web-wallets and (Perhaps???) multi-sig transactions.

As noted above:
Quote
As long as the sender uses their own client for the transaction they will always be the previous owners of all transaction's inputs so in this case you actually can get the sender's address(es), this is how SatoshiDice also retrieves the sender's address.

Is this not accurate?  Is your concern based on the fact that people might use web-wallets?


Title: Re: get sender address from RPC api
Post by: maaku on May 18, 2014, 09:53:59 PM
No, that is not accurate. There are an unlimited ways in which this can break (and yes, it does break for SatoshiDice). If it seems relatively safe now, it is because smart contracts, joint transactions, and other on-the-horizon technologies are not being widely deployed. When they are, the assumption that you can simply return funds to a transactions input(s) will be even less valid.


Title: Re: get sender address from RPC api
Post by: mcaizgk2 on May 20, 2014, 04:22:38 PM

As noted above:
Quote
As long as the sender uses their own client for the transaction they will always be the previous owners of all transaction's inputs so in this case you actually can get the sender's address(es), this is how SatoshiDice also retrieves the sender's address.

Is this not accurate?  Is your concern based on the fact that people might use web-wallets?

RangerK the only legitimate way of retrieving the transaction sender's address is to ask for one. You might also want to take a closer look to the refund address facility introduced with the 0.9 client, however this is no production ready yet.

BitcoinLib (https://github.com/GeorgeKimionis/BitcoinLib)'s GetTransactionSenderAddress() is not meant for production environment, as also stated in its comments (https://github.com/GeorgeKimionis/BitcoinLib/blob/master/CoinWrapper/Services/RpcServices/RpcExtenderService/RpcExtenderService.cs#L118) and it will eventually return invalid data for thin clients and e-wallets. SatoshiDice follows the same routine to extract the sender's address but it also fails in exactly the same way.


Title: Re: get sender address from RPC api
Post by: 01835113 on May 31, 2014, 04:43:15 PM
any ideas? I need it.


Title: Re: get sender address from RPC api
Post by: maaku on June 01, 2014, 04:38:38 AM
RangerK the only legitimate way of retrieving the transaction sender's address is to ask for one. You might also want to take a closer look to the refund address facility introduced with the 0.9 client, however this is no production ready yet.

You are talking about the payment protocol, right? That's ready for production, and is the right tool to use here.


Title: Re: get sender address from RPC api
Post by: RangerK on June 03, 2014, 02:43:06 PM
For anyone following this thread:

Quote
With the Payment Protocol, the wallet supplies a refund address along with the payment. This eliminates another potential source of error in refund situations. This approach to refunds works on the block chain, with any wallet software, and does not require the buyers to have a bitpay account.

http://blog.bitpay.com/2014/02/20/bitpay-launches-payment-protocol-support.html


Title: Re: get sender address from RPC api
Post by: PHP.guru on June 03, 2014, 05:16:03 PM
This question pops up every now and then. I will write an "ultimate guide" on how to do this once and for all.


Title: Re: get sender address from RPC api
Post by: RangerK on June 03, 2014, 08:31:34 PM
This question pops up every now and then. I will write an "ultimate guide" on how to do this once and for all.

And I will show my gratitude with a modest donation.  (very modest)


Title: Re: get sender address from RPC api
Post by: kjj on June 03, 2014, 09:44:45 PM
I wrote the ultimate guide many times.  Eventually got sick of it.

The short version is that there is no "sender", much less a "sender address".


Title: Re: get sender address from RPC api
Post by: DannyHamilton on June 03, 2014, 11:38:11 PM
I wrote the ultimate guide many times.  Eventually got sick of it.

The short version is that there is no "sender", much less a "sender address".

I was hoping that the "Ultimate Guide" comment was in reference to:

Quote
With the Payment Protocol, the wallet supplies a refund address along with the payment.

An "Ultimate Guide" on how to choose which address your wallet will choose as the "refund address" when you send the payment, and how as a merchant to request a "refund address" from the customer by way of the payment protocol would be nice.


Title: Re: get sender address from RPC api
Post by: Nicolas Dorier on June 15, 2014, 12:54:44 AM
hi and sorry,

i try to understand this world and i try to crate a game/services.

My program in c# .net call the wallet by RPC, but how i can get sender address ?

for now i can get the transaction on specific account by listtransactions, i try getrawtransaction verbose or decoderawtransaction, but i can't get the address of sender.

Can you help me?

It was not here when you posted this message, but now, here you go
Github : https://github.com/NicolasDorier/NBitcoin (https://github.com/NicolasDorier/NBitcoin)
Nuget : Install-Package NBitcoin
The class that interest you is called RPCClient.
I wrote some articles on codeproject, I let you discover that.