Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: init1 on July 18, 2015, 03:19:43 PM



Title: monitoring incoming txId
Post by: init1 on July 18, 2015, 03:19:43 PM
Hello!

Can I monitoring incoming  txId by bitcoind ?

like https://www.blocktrail.com/tBTC/address/2NEV6KKpFiWb3HKb75TqEupePDXaznTqGaC/transactions

For example

Quote
1) createmultisig 2
2) addmultisigaddress 2
3) monitoringincommingTX id and get List:
49c585907b71d849aec3fbfbc105bb398b8bd320d885f1a6f32bd065056e86d5
9d523eedf1130867f298c8a17d835590387d3e269928ebc7b41b1c206946094d
47f3d689a9acdf29f5c7963bb8272b141d21490b012804de4e468f6e9aa1326d
...

BR !


Title: Re: monitoring incoming txId
Post by: achow101 on July 18, 2015, 03:53:49 PM
What do you mean by monitoring? Do you want a command that checks to see if there are any new transactions for a bitcoin address? If so, there isn't.


Title: Re: monitoring incoming txId
Post by: InceptionCoin on July 18, 2015, 06:09:37 PM
Hello!

Can I monitoring incoming  txId by bitcoind ?

like https://www.blocktrail.com/tBTC/address/2NEV6KKpFiWb3HKb75TqEupePDXaznTqGaC/transactions

For example

Quote
1) createmultisig 2
2) addmultisigaddress 2
3) monitoringincommingTX id and get List:
49c585907b71d849aec3fbfbc105bb398b8bd320d885f1a6f32bd065056e86d5
9d523eedf1130867f298c8a17d835590387d3e269928ebc7b41b1c206946094d
47f3d689a9acdf29f5c7963bb8272b141d21490b012804de4e468f6e9aa1326d
...

BR !

https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list
listreceivedbyaddress 0 true


Title: Re: monitoring incoming txId
Post by: fbueller on July 19, 2015, 12:59:10 AM
There are a few ways, but they differ greatly in the amount of effort required.

You could use an API - blocktrail at least supports webhooks so you can receive notifications on any payments. It lets you specify the number of confirmations, which is neat.

Otherwise you could use stratum, like the electrum client. There are public stratum servers you can query for transactions on an address, and even set up subscriptions (like blocktrail, but using a public resource).

You could actually look into using https://github.com/btcdrak/bitcoin/tree/addrindex - with the -addrindex flag it lets you look up transactions on any address at all (its bitcoin core patched with a few additional RPC commands).

You could write this purely using bitcoind. blocknotify, and parse every tx in every block.. Look for an output script that belongs to an address you are awaiting payment on. It's not ideal, since you need to be able to handle reorgs (reshuffling the blockchain, and possibly invalidating your transaction temporarily, and potentially changing the txid...which means your reorg handling needs to be excellent, to avoid what appears to be double payments).

(PS, oops, only saw your post in the other thread)


Title: Re: monitoring incoming txId
Post by: init1 on July 19, 2015, 03:40:33 PM
What do you mean by monitoring? Do you want a command that checks to see if there are any new transactions for a bitcoin address? If so, there isn't.

I mean, get all txId for the incoming transaction, like https://www.blocktrail.com/tBTC/address/2NEV6KKpFiWb3HKb75TqEupePDXaznTqGaC/transactions
also can I get balance by address ?


Title: Re: monitoring incoming txId
Post by: init1 on July 19, 2015, 03:48:40 PM
There are a few ways, but they differ greatly in the amount of effort required.

You could use an API - blocktrail at least supports webhooks so you can receive notifications on any payments. It lets you specify the number of confirmations, which is neat.

Otherwise you could use stratum, like the electrum client. There are public stratum servers you can query for transactions on an address, and even set up subscriptions (like blocktrail, but using a public resource).

You could actually look into using https://github.com/btcdrak/bitcoin/tree/addrindex - with the -addrindex flag it lets you look up transactions on any address at all (its bitcoin core patched with a few additional RPC commands).

You could write this purely using bitcoind. blocknotify, and parse every tx in every block.. Look for an output script that belongs to an address you are awaiting payment on. It's not ideal, since you need to be able to handle reorgs (reshuffling the blockchain, and possibly invalidating your transaction temporarily, and potentially changing the txid...which means your reorg handling needs to be excellent, to avoid what appears to be double payments).

(PS, oops, only saw your post in the other thread)

Thank you for advices. How about some local block chain explorers with RCP. Do you know some ?


Title: Re: monitoring incoming txId
Post by: fbueller on July 19, 2015, 04:01:04 PM
Bitcoind with the addrindex patch is very close to what you want - just to look up txids on addresses. Some of the other chain explorers build their own database as well as bitcoind, so keeping it to bitcoind would be better.

Insight isn't bad - it syncs against bitcoind, and exposes an API to look up addresses.


Title: Re: monitoring incoming txId
Post by: arnuschky on July 20, 2015, 04:02:49 PM
Bitcoind with the addrindex patch is very close to what you want - just to look up txids on addresses. Some of the other chain explorers build their own database as well as bitcoind, so keeping it to bitcoind would be better.

Insight isn't bad - it syncs against bitcoind, and exposes an API to look up addresses.

Insight is awefuly slow - so slow, that it's barely usable. Haven't tested it's successor bitcore-node yet.

As an alternative, btcd has support for a full address index out of the box. I have made quite good experiences with btcd, and it allows you to connect to it via websocket which can be quite convenient as well.


Title: Re: monitoring incoming txId
Post by: nuno12345 on July 23, 2015, 03:27:55 PM
From my understanding you want to monitor incoming, your own wallet/addresses, transactions right?

There are a couple of way of doing this, assuming you can run a full server (bitcoin, php, sql)

The first is using wallet_notify in bitcoin.conf.

Code:
walletnotify=wget "http://yourdomain/newTX.php?coin=bitcoin&tx=%s"

You can also call a script or any command actually, %s holds the tx received.

You may want to see who is the sender of that tx, you can do it with the following:

newTX.php
Code:
<?php
        
include "jsonRPCClient.php";
        
$rpc = new jsonRPCClient("http://bitcoinrpc:rpcpass@127.0.0.1:24000/");

        
$tx $_GET["tx"];
$txidJson $rpc->gettransaction($txtrue);

if(isset($txidJson))
{
$address $txidJson["details"][0]["address"];
$type $txidJson["details"][0]["category"];
$amount $txidJson["details"][0]["amount"];

echo $address ":" $type;

                
//add to sql or anything else
        
}
?>


If you know when you are supposed to get a new transaction and know the address where the client is going to pay you can:
1-At sql make confirms field default=-1
2-When a tx is about to happen set confirms=0
3-Run a cron to loop thru every confirms>=0<minConfirms
4-With the above use RPC and do getbalance on the address
5-If balance is greater or less than balance field at SQL update balance field and confirms++
6-If needed keep increasing it until you achieve the minConfirms

I think you can also use blockchain which allows something like push notifications when a transaction happens.

Hope this helps


Title: Re: monitoring incoming txId
Post by: fbueller on July 25, 2015, 01:12:40 PM
nuno12345: init1 is working on multisig, and won't have the keys in his wallet.