Bitcoin Forum
May 05, 2024, 07:41:37 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 »  All
  Print  
Author Topic: How to watch confirmations on set of transactions?  (Read 4919 times)
adrian33 (OP)
Member
**
Offline Offline

Activity: 118
Merit: 10


View Profile
July 26, 2013, 10:58:33 AM
 #1

HI there, I am interested in building a web page that watches a set of transactions and their number of confirmations as they rise. As a novice developer, what's the best and/or easiest way to do this? I checked http://blockchain.info/api/blockchain_api and confirmed transactions doesn't appear part of their api for Single transaction. How could I get the necessary data  realtime?

cheers.

1714938097
Hero Member
*
Offline Offline

Posts: 1714938097

View Profile Personal Message (Offline)

Ignore
1714938097
Reply with quote  #2

1714938097
Report to moderator
1714938097
Hero Member
*
Offline Offline

Posts: 1714938097

View Profile Personal Message (Offline)

Ignore
1714938097
Reply with quote  #2

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

Posts: 1714938097

View Profile Personal Message (Offline)

Ignore
1714938097
Reply with quote  #2

1714938097
Report to moderator
1714938097
Hero Member
*
Offline Offline

Posts: 1714938097

View Profile Personal Message (Offline)

Ignore
1714938097
Reply with quote  #2

1714938097
Report to moderator
Mike Hearn
Legendary
*
expert
Offline Offline

Activity: 1526
Merit: 1129


View Profile
July 26, 2013, 05:33:39 PM
 #2

You can do this with bitcoinj if you are OK with Java.
piotr_n
Legendary
*
Offline Offline

Activity: 2053
Merit: 1354


aka tonikt


View Profile WWW
July 26, 2013, 07:37:53 PM
 #3

I just wonder, why do you even need it?
Watching a set of transactions and their number of confirmations as they rise - seems pretty crazy for me Wink

Check out gocoin - my original project of full bitcoin node & cold wallet written in Go.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
piotr_n
Legendary
*
Offline Offline

Activity: 2053
Merit: 1354


aka tonikt


View Profile WWW
July 26, 2013, 07:49:06 PM
 #4

I mean, I dont want to be mean, but if you explain you application maybe we could explain you better.

Check out gocoin - my original project of full bitcoin node & cold wallet written in Go.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
adrian33 (OP)
Member
**
Offline Offline

Activity: 118
Merit: 10


View Profile
July 26, 2013, 11:03:29 PM
 #5

I just wonder, why do you even need it?
Watching a set of transactions and their number of confirmations as they rise - seems pretty crazy for me Wink

Thanks for responses.

I just want to know when a few transactions I will make have hit 4 confirmations. Can I do that with bitcoinj on transactions where I don't hold any keys... totally independent of me? Or rather, I don't want to link the web app in any way to my wallet, so I make the transaction, and then close my wallet app... but tell the confirmation app the transaction address(es) to track for subsequent confirmations.

I skimmed the documentation.. but not sure if I can do that with bitcoinj.

piotr_n
Legendary
*
Offline Offline

Activity: 2053
Merit: 1354


aka tonikt


View Profile WWW
July 26, 2013, 11:13:53 PM
 #6

I just want to know when a few transactions I will make have hit 4 confirmations/
So you basically want to send a tx, from you wallet, and then get some alatm clock tiggered, when it reaches 4 confiscation.
How much secured you need to have ii?
If not, I belvbe any block explorer would ro.

Check out gocoin - my original project of full bitcoin node & cold wallet written in Go.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
adrian33 (OP)
Member
**
Offline Offline

Activity: 118
Merit: 10


View Profile
July 26, 2013, 11:21:05 PM
 #7

I just want to know when a few transactions I will make have hit 4 confirmations/
So you basically want to send a tx, from you wallet, and then get some alatm clock tiggered, when it reaches 4 confiscation.
How much secured you need to have ii?
If not, I belvbe any block explorer would ro.

Thanks what's the easiest or fastest way to build my own block explorer.. or can bitcoinj do what is required if it knows the transactions to watch.. or does it require keys of some sort?

Come-from-Beyond
Legendary
*
Offline Offline

Activity: 2142
Merit: 1009

Newbie


View Profile
July 26, 2013, 11:25:08 PM
 #8

HI there, I am interested in building a web page that watches a set of transactions and their number of confirmations as they rise. As a novice developer, what's the best and/or easiest way to do this? I checked http://blockchain.info/api/blockchain_api and confirmed transactions doesn't appear part of their api for Single transaction. How could I get the necessary data  realtime?

cheers.

[block_height acquired via http://blockchain.info/latestblock] minus [block_height of ur transaction] plus 1
piotr_n
Legendary
*
Offline Offline

Activity: 2053
Merit: 1354


aka tonikt


View Profile WWW
July 26, 2013, 11:25:38 PM
 #9

I just want to know when a few transactions I will make have hit 4 confirmations/
So you basically want to send a tx, from you wallet, and then get some alatm clock tiggered, when it reaches 4 confiscation.
How much secured you need to have ii?
If not, I belvbe any block explorer would ro.

Thanks what's the easiest or fastest way to build my own block explorer.. or can bitcoinj do what is required if it knows the transactions to watch.. or does it require keys of some sort?
So what are you going to do, after the alarm clock triggers the 4th confirmation?

Check out gocoin - my original project of full bitcoin node & cold wallet written in Go.
PGP fingerprint: AB9E A551 E262 A87A 13BB  9059 1BE7 B545 CDF3 FD0E
adrian33 (OP)
Member
**
Offline Offline

Activity: 118
Merit: 10


View Profile
July 26, 2013, 11:45:56 PM
 #10

[block_height acquired via http://blockchain.info/latestblock] minus [block_height of ur transaction] plus 1

cheers. block_height of transaction I can grab from http://blockchain.info/rawtx/43384a79232a8844f9ec1f5149ed2aa7d7800f6197d194b02c948785e795d6c9

But I can also get block height from http://blockchain.info/api/api_websocket -- "Receive notifications when a new block is found."?

.. better than polling for latestblock.

After that, I wipe the sweat from my brow.

Come-from-Beyond
Legendary
*
Offline Offline

Activity: 2142
Merit: 1009

Newbie


View Profile
July 27, 2013, 02:07:40 PM
 #11

But I can also get block height from http://blockchain.info/api/api_websocket -- "Receive notifications when a new block is found."?

.. better than polling for latestblock.

It's better to keep things simple. I would poll the latest block each 10 sec.
Abdussamad
Legendary
*
Offline Offline

Activity: 3612
Merit: 1564



View Profile
July 27, 2013, 02:41:47 PM
 #12

See here:

http://blockchain.info/q/

See under address lookups

Also in future if you ever find yourself wondering how to do something bitcoin related go through the ENTIRE page below:

http://blockchain.info/api/

Blockchain.info has half a dozen different APIs and it is easy to miss a few.
adrian33 (OP)
Member
**
Offline Offline

Activity: 118
Merit: 10


View Profile
July 28, 2013, 12:47:37 PM
 #13

Cheers. I just found this:

"Bitcoin blockchain in a MongoDB database to allow querying of block and transaction data.. In order to use bitcoinquery you need a Bitcoind RPC server. "

http://github.com/thelinuxkid/bitcoinquery

Long term, probably better to move away from third party APIs if opening to outside users.

assortmentofsorts
Member
**
Offline Offline

Activity: 91
Merit: 10



View Profile
July 28, 2013, 02:21:16 PM
 #14

HI there, I am interested in building a web page that watches a set of transactions and their number of confirmations as they rise. As a novice developer, what's the best and/or easiest way to do this? I checked http://blockchain.info/api/blockchain_api and confirmed transactions doesn't appear part of their api for Single transaction. How could I get the necessary data  realtime?

cheers.

[block_height acquired via http://blockchain.info/latestblock] minus [block_height of ur transaction] plus 1

The way I do it is.. using http://blockchain.info/api/api_websocket api, I subscribe to new blocks. Every time a block is found, I store the block height from the JSON payload that is sent back (as a key in redis). I store my 0-confirmation transaction indexes (which I again fetch from blockchain: http://blockchain.info/rawtx/$tx_hash) in a collection (pending_transactions) in mongodb. The JSON payload for a new block contains a list of transaction indexes (block.x.txIndexes) which I match against the ones stored in my mongodb collection (and increment their confirmation count by 1). I also increment confirmation counts of all those transactions(excluding the txIndexes sent in the payload) that already have 1 confirmation (note: I don't increment 0 confirmations). When it hits 6 confirmations, I move the transaction from pending_transactions collection to confirmed_transactions collection.

The reason I do all this nonsense is that sometimes 0 confirmation transactions never get included in the new blocks (ex: when you send with 0 fee). So doing a latest_block_height - block_height_of_transaction + 1 may not work for such edge cases.

Also there are times where your server might crash due to unknown bugs. When the server reboots, I fetch all blocks from where I left off (use the last stored block height in redis and then fetch block heights from blockchain. Example: http://blockchain.info/block-height/246536?format=json) and catch-up to the latest block (and repeat the whole process again).

This is temporary though. My future plan is to write my own client with these features (esp notifications on confirmations; it sucks that there is no API to subscribe for notifications) or fork the bitcoin client and make these necessary changes.

If you want to tip: BTC 1KbjTUEfcziwMv7BMXcjmvNAKEpTJbZCsF
adrian33 (OP)
Member
**
Offline Offline

Activity: 118
Merit: 10


View Profile
July 28, 2013, 03:29:17 PM
 #15

Yeah, I found this Lua script that uses twilio and mailgun that is used to curl to alert via email, sms, or phone when something completes.

http://gist.github.com/jnankin/6089984

Mike Hearn
Legendary
*
expert
Offline Offline

Activity: 1526
Merit: 1129


View Profile
July 29, 2013, 12:45:06 PM
 #16

With bitcoinj you can use a depth future. Something like the following would work (not compiled or testing, just typed from memory):

Code:

byte[] pubkeybytes = ....;

Wallet wallet = new Wallet(params);
wallet.addKey(new ECKey(null, pubkeybytes));

... (insert usual boilerplate setup here) ...

wallet.addEventListener(new AbstractWalletEventListener() {
    public void onCoinsReceived(Wallet wallet, Transaction tx, BigInteger prevBalance, BigInteger newBalance) {
        // Transaction was received. Get a callback when 4 confirmations have occurred.
        ListenableFuture<Transaction> future = tx.getConfidence().getDepthFuture(4);
        Futures.addCallback(future, new FutureCallback<Transaction>() {
            public void onSuccess(Transaction tx) {
                System.out.println("Transaction " + tx + " now has 4 confirmations - party time!!");
            }
        });
    }
});

The syntax is a bit verbose - languages like Java 8 or Kotlin have some features to make it more fluid, if you don't mind what language you use. Also, if your app restarts, you'll have to re-register the confidence listeners on the loaded wallet of course.
adrian33 (OP)
Member
**
Offline Offline

Activity: 118
Merit: 10


View Profile
July 29, 2013, 01:06:47 PM
 #17

Thanks Mike - I think the key is to differentiate watching confirmations for a private wallet and watching them for a public blockchain. For my application, it's all about OPCs -- other people's confirmations, because I want to separate the new app from my wallet app. Does bitcoinj allow that?

A Confirmation Party site would be good... you could have a $20,000 confirmation party room and a $500,000 room - social networking for high rollers.

Mike Hearn
Legendary
*
expert
Offline Offline

Activity: 1526
Merit: 1129


View Profile
July 29, 2013, 02:28:42 PM
 #18

The key issue is scalability. If you want to monitor tens of thousands of keys/transactions, bitcoinj probably won't scale to what you need. If you want to monitor less than that, it might work. You could try it.
adrian33 (OP)
Member
**
Offline Offline

Activity: 118
Merit: 10


View Profile
August 08, 2013, 02:46:52 PM
 #19

A London-based hacker has been working on this site idea with me, to my delight, and we'll have something up in the next week that will alert on confirmations, with some other lookup goodies in the pipeline.

adrian33 (OP)
Member
**
Offline Offline

Activity: 118
Merit: 10


View Profile
September 21, 2013, 05:07:50 PM
 #20

We've finally got something up. -- http://donebit.com

The site gives information on any transaction or any address, with ability to setup email notifications on transactions (regarding confirmations) and addresses (regarding input and outputs according to certain triggers.)

Check it out.









Would be happy to hear feedback or answer questions.

Pages: [1] 2 »  All
  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!