Bitcoin Forum
November 13, 2024, 08:45:48 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: get sender address from RPC api  (Read 3668 times)
Chida (OP)
Full Member
***
Offline Offline

Activity: 212
Merit: 100



View Profile
January 13, 2014, 06:17:41 PM
Last edit: January 14, 2014, 05:47:28 PM by Chida
 #1

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?
DBordello
Sr. Member
****
Offline Offline

Activity: 349
Merit: 250


BTCPak.com - Exchange your Bitcoins for MP!


View Profile WWW
January 13, 2014, 06:37:26 PM
 #2

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".

www.BTCPak.com - Exchange your bitcoins for MP: Secure, Anonymous and Easy!
Chida (OP)
Full Member
***
Offline Offline

Activity: 212
Merit: 100



View Profile
January 13, 2014, 07:15:39 PM
 #3

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
Chida (OP)
Full Member
***
Offline Offline

Activity: 212
Merit: 100



View Profile
January 14, 2014, 05:48:12 PM
 #4

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?
DannyHamilton
Legendary
*
Offline Offline

Activity: 3486
Merit: 4851



View Profile
January 14, 2014, 09:50:40 PM
Last edit: May 18, 2014, 04:32:12 PM by DannyHamilton
 #5

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?
Chida (OP)
Full Member
***
Offline Offline

Activity: 212
Merit: 100



View Profile
January 14, 2014, 10:06:12 PM
 #6

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.
andytoshi
Full Member
***
Offline Offline

Activity: 179
Merit: 151

-


View Profile
February 08, 2014, 11:32:45 PM
 #7

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.
Ins
Full Member
***
Offline Offline

Activity: 196
Merit: 100


View Profile
February 09, 2014, 11:11:11 AM
 #8

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
maaku
Legendary
*
Offline Offline

Activity: 905
Merit: 1012


View Profile
February 09, 2014, 11:25:11 AM
 #9

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.

I'm an independent developer working on bitcoin-core, making my living off community donations.
If you like my work, please consider donating yourself: 13snZ4ZyCzaL7358SmgvHGC9AxskqumNxP
RangerK
Member
**
Offline Offline

Activity: 93
Merit: 10



View Profile WWW
May 18, 2014, 12:38:57 PM
 #10

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?

Cool ---> Who will mine the next 777 Block??? Place your bets at block777.com!!!
maaku
Legendary
*
Offline Offline

Activity: 905
Merit: 1012


View Profile
May 18, 2014, 09:53:59 PM
 #11

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.

I'm an independent developer working on bitcoin-core, making my living off community donations.
If you like my work, please consider donating yourself: 13snZ4ZyCzaL7358SmgvHGC9AxskqumNxP
mcaizgk2
Member
**
Offline Offline

Activity: 66
Merit: 10


View Profile
May 20, 2014, 04:22:38 PM
 #12


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's GetTransactionSenderAddress() is not meant for production environment, as also stated in its comments 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.
01835113
Full Member
***
Offline Offline

Activity: 128
Merit: 104


View Profile
May 31, 2014, 04:43:15 PM
 #13

any ideas? I need it.
maaku
Legendary
*
Offline Offline

Activity: 905
Merit: 1012


View Profile
June 01, 2014, 04:38:38 AM
 #14

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.

I'm an independent developer working on bitcoin-core, making my living off community donations.
If you like my work, please consider donating yourself: 13snZ4ZyCzaL7358SmgvHGC9AxskqumNxP
RangerK
Member
**
Offline Offline

Activity: 93
Merit: 10



View Profile WWW
June 03, 2014, 02:43:06 PM
 #15

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

Cool ---> Who will mine the next 777 Block??? Place your bets at block777.com!!!
PHP.guru
Member
**
Offline Offline

Activity: 154
Merit: 10


View Profile
June 03, 2014, 05:16:03 PM
 #16

This question pops up every now and then. I will write an "ultimate guide" on how to do this once and for all.

RangerK
Member
**
Offline Offline

Activity: 93
Merit: 10



View Profile WWW
June 03, 2014, 08:31:34 PM
 #17

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)

Cool ---> Who will mine the next 777 Block??? Place your bets at block777.com!!!
kjj
Legendary
*
Offline Offline

Activity: 1302
Merit: 1026



View Profile
June 03, 2014, 09:44:45 PM
 #18

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".

17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8
I routinely ignore posters with paid advertising in their sigs.  You should too.
DannyHamilton
Legendary
*
Offline Offline

Activity: 3486
Merit: 4851



View Profile
June 03, 2014, 11:38:11 PM
 #19

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.
Nicolas Dorier
Hero Member
*****
Offline Offline

Activity: 714
Merit: 662


View Profile
June 15, 2014, 12:54:44 AM
 #20

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
Nuget : Install-Package NBitcoin
The class that interest you is called RPCClient.
I wrote some articles on codeproject, I let you discover that.

Bitcoin address 15sYbVpRh6dyWycZMwPdxJWD4xbfxReeHe
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!