Bitcoin Forum
December 15, 2024, 08:48:09 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: bitcoind - get no. of confirmations for an address  (Read 1288 times)
mav (OP)
Full Member
***
Offline Offline

Activity: 169
Merit: 107


View Profile
June 17, 2012, 07:40:15 AM
 #1

I want to know how many confirmations each of the transfers into a given address has.

I can achieve this in an inefficient way using

Code:
bitcoind listreceivedbyaddress

and manually filtering the result for only the address I'm interested in.

My concern is that if I have a lot of transactions, this command results in a very long list containing all my addresses. Is there a way to get this same list but only for a specific address, so that I don't have to filter through it?

Another way I could do it is using

Code:
bitcoind getreceivedbyaddress ADDRESS X

and iterate over a suitable range for X until I see a balance change, and then I know that there was a transaction to that address which has X confirmations.

I feel like I'm missing something here and I'm making this harder than it is. Anyone got some ideas what I should do?
Revalin
Hero Member
*****
Offline Offline

Activity: 728
Merit: 500


165YUuQUWhBz3d27iXKxRiazQnjEtJNG9g


View Profile
June 17, 2012, 07:47:54 AM
 #2

An address doesn't have a discrete number of confirmations.  Only a transaction does.

Try this:
Code:
bitcoind gettransaction <txid>

      War is God's way of teaching Americans geography.  --Ambrose Bierce
Bitcoin is the Devil's way of teaching geeks economics.  --Revalin 165YUuQUWhBz3d27iXKxRiazQnjEtJNG9g
mav (OP)
Full Member
***
Offline Offline

Activity: 169
Merit: 107


View Profile
June 17, 2012, 08:03:54 AM
 #3

Yep that makes sense about transactions having confirmations not addresses

To be able to use gettransaction I need to have a transaction id which is not something I automatically have for a deposit, only for a send.

I can get a list of incoming transaction ids using

Code:
bitcoind listtransactions ACCOUNT

however I still have the problem of having to do lots of filtering if ACCOUNT has a lot of transactions. I guess I could keep track of how many transactions were returned the last time I called it and use that in the 'from' parameter to narrow down the list.

Thanks for the ideas. Still doesn't seem like a neat solution, but listtransactions is better than the previous ideas I had.

edit:
I might clarify the reason I made this title 'address confirmations' and not 'transaction confirmations' is that I plan to have each address used only once, and hence address should be analogous to a transaction. Of course I cannot assume that the address will indeed only be used once since someone may pay to it multiple times, so I am also thinking about how to deal with that scenario should it arise.
Revalin
Hero Member
*****
Offline Offline

Activity: 728
Merit: 500


165YUuQUWhBz3d27iXKxRiazQnjEtJNG9g


View Profile
June 17, 2012, 08:23:00 AM
 #4

That's what I'd recommend: use one address per sale.  Then you don't get a big long list back.  You just get (usually) one transaction, and you deliver the goods when it confirms.  If any unexpected transactions come in you should notice it in your net balance.

Also check out 'listsinceblock <blockhash> <confirmations>'.

      War is God's way of teaching Americans geography.  --Ambrose Bierce
Bitcoin is the Devil's way of teaching geeks economics.  --Revalin 165YUuQUWhBz3d27iXKxRiazQnjEtJNG9g
kano
Legendary
*
Offline Offline

Activity: 4634
Merit: 1851


Linux since 1997 RedHat 4


View Profile
June 19, 2012, 02:43:04 PM
 #5

 listtransactions '*' N

lists the last N transactions.

Pool: https://kano.is - low 0.5% fee PPLNS 3 Days - Most reliable Solo with ONLY 0.5% fee   Bitcointalk thread: Forum
Discord support invite at https://kano.is/ Majority developer of the ckpool code - k for kano
The ONLY active original developer of cgminer. Original master git: https://github.com/kanoi/cgminer
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!