Bitcoin Forum
November 18, 2024, 12:04:15 PM *
News: Check out the artwork 1Dq created to commemorate this forum's 15th anniversary
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitcoind and php - get the newest transactions  (Read 3360 times)
TAiS46 (OP)
Full Member
***
Offline Offline

Activity: 222
Merit: 100



View Profile WWW
June 25, 2012, 01:13:36 PM
Last edit: June 26, 2012, 02:57:10 PM by TAiS46
 #1

Hello,

how is it possible, to get the newest transactions and put them into the database?
Dose someone found a way to do this?

At this moment I don't save receive transactions in the database, but I will
do this in the future.

Is it the correct way to list the transactions "bitcoind listtransactions"
and put them into the database and sync every 5 minutes the transacions?

I think this is not the best way?

Greetings
Simon
Stephen Gornick
Legendary
*
Offline Offline

Activity: 2506
Merit: 1010


View Profile
June 26, 2012, 01:03:08 AM
 #2

Is it the correct way to list the transactions "bitcoind listtransactions"

Just transactions for addresses in your wallet or all transactions?

Using Armory is one way:
 - https://bitcointalk.org/index.php?topic=77650.msg866810#msg866810

Others:
 - BitcoinJ
 - libbitcoin
 - ABE Blockchain explorer

Unichange.me

            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █
            █


weex
Legendary
*
Offline Offline

Activity: 1102
Merit: 1014



View Profile
June 26, 2012, 02:46:33 AM
 #3

Yes, depending on volume you may also want to add a txn count to that request.
notme
Legendary
*
Offline Offline

Activity: 1904
Merit: 1002


View Profile
June 26, 2012, 04:08:55 AM
 #4

If you're talking about php (assumed from the title), look at https://github.com/mikegogulski/bitcoin-php

Also,

> bitcoind help listtransactions
listtransactions [account] [count=10] [from=0]
Returns up to [count] most recent transactions skipping the first [from] transactions for account [account].

You can use '*' for the account to get all transactions, so I'd keep track of the how many transactions you've recorded (T) and do this:

bitcoind listtransactions 10000 T

If you expect to ever have more than 10000 transactions per 5 minute period (or however often you check), bump that number up.

https://www.bitcoin.org/bitcoin.pdf
While no idea is perfect, some ideas are useful.
TAiS46 (OP)
Full Member
***
Offline Offline

Activity: 222
Merit: 100



View Profile WWW
June 26, 2012, 12:24:08 PM
Last edit: June 26, 2012, 12:44:53 PM by TAiS46
 #5

> bitcoind help listtransactions
listtransactions [account] [count=10] [from=0]
Returns up to [count] most recent transactions skipping the first [from] transactions for account [account].

You can use '*' for the account to get all transactions, so I'd keep track of the how many transactions you've recorded (T) and do this:

bitcoind listtransactions 10000 T

If you expect to ever have more than 10000 transactions per 5 minute period (or however often you check), bump that number up.

What dose T mean?
What dose from mean? The time?

I think it looks good wo work with it when I know what "from" is Smiley


Edit:
I dont understand, why the transactions will not get an id on my own server.
So the "from" value will be get more interesting!
notme
Legendary
*
Offline Offline

Activity: 1904
Merit: 1002


View Profile
June 26, 2012, 02:36:40 PM
 #6

> bitcoind help listtransactions
listtransactions [account] [count=10] [from=0]
Returns up to [count] most recent transactions skipping the first [from] transactions for account [account].

You can use '*' for the account to get all transactions, so I'd keep track of the how many transactions you've recorded (T) and do this:

bitcoind listtransactions 10000 T

If you expect to ever have more than 10000 transactions per 5 minute period (or however often you check), bump that number up.

What dose T mean?
What dose from mean? The time?

I think it looks good wo work with it when I know what "from" is Smiley


Edit:
I dont understand, why the transactions will not get an id on my own server.
So the "from" value will be get more interesting!

Quote
keep track of the how many transactions you've recorded (T)

Quote
skipping the first [from] transactions

https://www.bitcoin.org/bitcoin.pdf
While no idea is perfect, some ideas are useful.
TAiS46 (OP)
Full Member
***
Offline Offline

Activity: 222
Merit: 100



View Profile WWW
June 26, 2012, 02:49:02 PM
 #7

skipping the first [from] transactions

i think this is not correct!

If you use: bitcoind listtransactions "*" 1 0
it will not show you the first transaction, it will show you the last transaction made!

It count from backward, not forward!
For what is the function?
notme
Legendary
*
Offline Offline

Activity: 1904
Merit: 1002


View Profile
June 26, 2012, 03:04:26 PM
 #8

skipping the first [from] transactions

i think this is not correct!

If you use: bitcoind listtransactions "*" 1 0
it will not show you the first transaction, it will show you the last transaction made!

It count from backward, not forward!
For what is the function?

I've not used listtransactions like this before, I'm only pulling that from the help.  It look like you're right about it being backwards.  You're probably better off with listsinceblock.  With no parameters, it returns all transactions, and a lastblock value.  Save that last block each time, then pass it as the first parameter to the next call of listsinceblock.  This should get you any new transactions since your last sync. (And you don't have any magic numbers that leave you vulnerable to someone intentionally overflowing your transaction buffer.)

https://www.bitcoin.org/bitcoin.pdf
While no idea is perfect, some ideas are useful.
TAiS46 (OP)
Full Member
***
Offline Offline

Activity: 222
Merit: 100



View Profile WWW
June 26, 2012, 03:38:35 PM
 #9

Thats a nice idea to use listsinceblock.

But I think I can get a problem with that function!
What is, if two blocks will find within 1 minute and I only
check every 5 minutes?
So I skip one block, correct?


I think the best solution is:

bitcoind getinfo
to look, if there is a new block (blocks count)
if there is a new block, get the blockhash

bitcoind getblockhash 186334
so with this blockhash you can use now

bitcoind listsinceblock 00000000000006e5cd708f7d0825b9c6b2746f36fc9045c4c0025c839a28cfc1

now I can check the transactions and write it into my database / check the txid.


I am trying to get off the json rpc! I will all make over the database and the server directly.
Also I will not use bitcoin accounts anymore for my customers.
I will have only account "" and and every user will get his own address.
notme
Legendary
*
Offline Offline

Activity: 1904
Merit: 1002


View Profile
June 26, 2012, 03:43:03 PM
 #10

Thats a nice idea to use listsinceblock.

But I think I can get a problem with that function!
What is, if two blocks will find within 1 minute and I only
check every 5 minutes?
So I skip one block, correct?


I think the best solution is:

bitcoind getinfo
to look, if there is a new block (blocks count)
if there is a new block, get the blockhash

bitcoind getblockhash 186334
so with this blockhash you can use now

bitcoind listsinceblock 00000000000006e5cd708f7d0825b9c6b2746f36fc9045c4c0025c839a28cfc1

now I can check the transactions and write it into my database / check the txid.


I am trying to get off the json rpc! I will all make over the database and the server directly.
Also I will not use bitcoin accounts anymore for my customers.
I will have only account "" and and every user will get his own address.

I'm pretty sure you're overcomplicating it.  It will not skip over blocks.  It lists every transaction since the blockhash you give it.  It also gives you the blockhash you're currently on, so you can save that for your next call.

https://www.bitcoin.org/bitcoin.pdf
While no idea is perfect, some ideas are useful.
TAiS46 (OP)
Full Member
***
Offline Offline

Activity: 222
Merit: 100



View Profile WWW
June 26, 2012, 04:06:13 PM
 #11

ok, now I have it!

As example, there are 5 blocks in the network.
I use bitcoind listsinceblock 3
So I will get all transactions, that are in the blocks 3, 4, 5!

lastblock = block 5.

I can put now the transactions into the database, and check their confirmations.
are the confirmations are higher than 6, will will count the confirmations with the blockid Smiley


Thank you for your support
notme
Legendary
*
Offline Offline

Activity: 1904
Merit: 1002


View Profile
June 26, 2012, 04:12:16 PM
 #12

ok, now I have it!

As example, there are 5 blocks in the network.
I use bitcoind listsinceblock 3
So I will get all transactions, that are in the blocks 3, 4, 5!

lastblock = block 5.

I can put now the transactions into the database, and check their confirmations.
are the confirmations are higher than 6, will will count the confirmations with the blockid Smiley


Thank you for your support

Pretty much, although listsinceblock takes the block hash, not the block number.

https://www.bitcoin.org/bitcoin.pdf
While no idea is perfect, some ideas are useful.
weex
Legendary
*
Offline Offline

Activity: 1102
Merit: 1014



View Profile
June 27, 2012, 12:08:39 AM
 #13

With this listsinceblock, what happens on a reorg?
notme
Legendary
*
Offline Offline

Activity: 1904
Merit: 1002


View Profile
June 27, 2012, 12:31:44 AM
 #14

With this listsinceblock, what happens on a reorg?

Good question.

https://www.bitcoin.org/bitcoin.pdf
While no idea is perfect, some ideas are useful.
weex
Legendary
*
Offline Offline

Activity: 1102
Merit: 1014



View Profile
June 27, 2012, 06:00:31 AM
 #15

I think you're better off doing a listtransactions, there you can see the confirmations and update your db accordingly. Then by looking at your db you'll know for sure if a transaction reached your target number of confirmations.
TAiS46 (OP)
Full Member
***
Offline Offline

Activity: 222
Merit: 100



View Profile WWW
June 27, 2012, 07:17:09 AM
 #16

I think you're better off doing a listtransactions, there you can see the confirmations and update your db accordingly. Then by looking at your db you'll know for sure if a transaction reached your target number of confirmations.

listtransaction with what parameters?
The only way is with listtransactions to get the last 1000 transactions and check them for confirmations.
But I think it will cost much performance?
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!