Bitcoin Forum
April 26, 2024, 11:25:49 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: getting the input addresses of a transaction.  (Read 937 times)
BRules (OP)
Sr. Member
****
Offline Offline

Activity: 293
Merit: 250


View Profile
January 08, 2013, 05:33:13 PM
 #1

What I'm doing is (using the bitcoin rpc):

having the transaction id, I'm using the function getRawTransaction to get the hex and after this I'm using the decoderawtransaction to get the json. So, I'm navigating through all inputs and using the getRawTransaction and decoderawtransaction on each input to find the address.

When doing this on the transaction dcf2af38cebd8abf3a34897b7ef908033fedba825e2ba86a7f7079705e8b2376
it is taking something like 15 milliseconds, but doing this in the transaction: 49a26581cf176de5c13452e773dd7fcae6721acaf0bca5b71a26059da190baa4 it's taking about 781 milliseconds.

So I'm wondering, is there any better way to get the input addresses on a transaction?

tks in advance

1714130749
Hero Member
*
Offline Offline

Posts: 1714130749

View Profile Personal Message (Offline)

Ignore
1714130749
Reply with quote  #2

1714130749
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714130749
Hero Member
*
Offline Offline

Posts: 1714130749

View Profile Personal Message (Offline)

Ignore
1714130749
Reply with quote  #2

1714130749
Report to moderator
1714130749
Hero Member
*
Offline Offline

Posts: 1714130749

View Profile Personal Message (Offline)

Ignore
1714130749
Reply with quote  #2

1714130749
Report to moderator
1714130749
Hero Member
*
Offline Offline

Posts: 1714130749

View Profile Personal Message (Offline)

Ignore
1714130749
Reply with quote  #2

1714130749
Report to moderator
DannyHamilton
Legendary
*
Offline Offline

Activity: 3374
Merit: 4606



View Profile
January 08, 2013, 05:59:34 PM
Last edit: January 08, 2013, 06:15:46 PM by DannyHamilton
 #2

This is generally a bad idea.  People need to stop trying to find input addresses, they aren't typically good for the things people try to use them for.  It would be far easier and better to simply ask users to supply a payout address.

I suspect that kjj or DeathAndTaxes will be here in a bit to share their opinions on how you shouldn't be doing this as well.

For explanations (about how this is a bad idea) given to a few others who have asked a similar question see:

https://bitcointalk.org/index.php?topic=134718.msg1435502#msg1435502

https://bitcointalk.org/index.php?topic=134217.msg1429404#msg1429404

https://bitcointalk.org/index.php?topic=40279.msg498915#msg498915
Peter Todd
Legendary
*
expert
Offline Offline

Activity: 1120
Merit: 1149


View Profile
January 08, 2013, 06:09:11 PM
 #3

If you add the option 1 after the transaction hash in your getrawtransaction call it'll automatically decode the hex for you, saving that second call and some latency. At least that's how it works on the command line; I'm pretty sure the actual HTTP-json RPC interface is identical.

The latter transaction is taking longer because it's bigger. To be exact it's 26 times bigger, (5122 bytes vs 193) and it's taking 50 times longer, so pretty much exactly how much longer you'd expect it to take.

That said, Danny is right. Depending on the input address is almost always a bad idea.

BRules (OP)
Sr. Member
****
Offline Offline

Activity: 293
Merit: 250


View Profile
January 08, 2013, 06:37:46 PM
 #4

ok, tk you guys for the information. for now I'm just trying to figure things out.

what I wanna understand is, I see that this is a problem if someone send bitcoins through mtgox wallet or if someone make the payment for you (which seems like a exceptional case, but can't be discarded). but I read that the bitcoin client could become very slow if there's a lot of address in the wallet.

is this true? if so, how much addresses will the qt client supports before becoming slow?


kjj
Legendary
*
Offline Offline

Activity: 1302
Merit: 1024



View Profile
January 08, 2013, 08:53:41 PM
 #5

ok, tk you guys for the information. for now I'm just trying to figure things out.

what I wanna understand is, I see that this is a problem if someone send bitcoins through mtgox wallet or if someone make the payment for you (which seems like a exceptional case, but can't be discarded). but I read that the bitcoin client could become very slow if there's a lot of address in the wallet.

is this true? if so, how much addresses will the qt client supports before becoming slow?

Most people don't have to worry about getting too many addresses in their wallet.  There is no number that is "too many", because it depends on your computer.

Basically, for each transactions that comes in (whether by protocol or by block), your node needs to compare the inputs and outputs with all of your keys, looking for matches.  The good news is that modern computers are pretty fast.  The better news is that we can probably switch to bloom filters or something similar if it gets to be a widespread problem in the future.

People usually only get this problem if they accept tons and tons of incoming payments, like mtgox or other big names, and they understand that they have to find their own solution (for now).

As to your first question about the transaction tracking, looking backward is the only way to find out where coins were in the past, and what you are doing is about the best you can do.  There are no features in the system to make this step easier, because it is dangerous, not useful.  If you want to follow transactions around the network as an academic or intellectual exercise, feel free.  But please be careful that you do not delude yourself into thinking that you have found "the sender", as the concept does not exist in bitcoin.  If you need to collect state information about an incoming transaction, you must collect that information in advance and associate it with the payment address that you provide.

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

Activity: 1652
Merit: 2216


Chief Scientist


View Profile WWW
January 08, 2013, 09:02:25 PM
 #6

So I'm wondering, is there any better way to get the input addresses on a transaction?

As was pointed out, getrawtransaction <txid> 1    will do the decode for you.

If your JSON-RPC library supports it, you could also use a 'batch' request to get all of the inputs in one round-trip. See http://www.jsonrpc.org/specification#batch

How often do you get the chance to work on a potentially world-changing project?
BRules (OP)
Sr. Member
****
Offline Offline

Activity: 293
Merit: 250


View Profile
January 09, 2013, 09:59:52 PM
 #7

once more tks for the explanation, and Gavin, tks for the batch tip.

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!