Pages:
Author

Topic: how to use wallet notify (bitcoind) ? - page 2. (Read 4180 times)

full member
Activity: 224
Merit: 101
April 20, 2016, 10:06:32 PM
#8
i use gettransaction($txid);

how get my wallet address for receiving? (this method get payer wallet address only)
sr. member
Activity: 257
Merit: 250
April 20, 2016, 07:10:31 PM
#7
Every new block.
Code:
milton@milton:~$ ps -eo cmd | egrep bitcoind | egrep -v grep
bitcoind -daemon -blocknotify=blocknotify %s

Code:
#!/bin/bash -e

block_message()
{
    local DATE=$1
    local HEIGHT=$2
    local BLOCKHASH=$3
    echo -e "+====================================================================="
    echo -e "| \033[31m ${DATE} \033[0m"
    echo -e "+====================================================================="
    echo -e "| \033[31m ${HEIGHT} \033[0m"
    echo -e "+====================================================================="
    echo -e "| \033[31m ${BLOCKHASH} \033[0m"
    echo -e "+====================================================================="

} >> $HOME/temp/blocknotify.txt

block_message "$(date -u)" "$(bitcoin-cli getblockcount)" "$@"

Code:
milton@milton:~$ tail -f temp/blocknotify.txt
+====================================================================+
| 0000000000000000016c397b5eac0d5b3580d11b585996d2a8452bef2e03fa3e   |
+====================================================================+
+====================================================================+
| Wed Apr 20 23:49:27 UTC 2016                                                            
+====================================================================+
| 408221                                                          
+====================================================================+
| 0000000000000000033ed3a5284a10c8992cb9411bf4fd33a130fc742436e3f7   |
+====================================================================+
full member
Activity: 224
Merit: 101
April 20, 2016, 07:29:27 AM
#6
-walletnotify will run twice per transaction, when it's first seen on the network as unconfirmed, and when it gets it's first confirmation.

To track more than one confirmation you need to use -blocknotify

and blocknotify how much times call myscript.php?
full member
Activity: 224
Merit: 101
April 20, 2016, 07:25:39 AM
#5
-walletnotify will run twice per transaction, when it's first seen on the network as unconfirmed, and when it gets it's first confirmation.

To track more than one confirmation you need to use -blocknotify

after first confirmation payment not lost?
sr. member
Activity: 261
Merit: 523
April 20, 2016, 07:15:32 AM
#4
-walletnotify will run twice per transaction, when it's first seen on the network as unconfirmed, and when it gets it's first confirmation.

To track more than one confirmation you need to use -blocknotify
full member
Activity: 224
Merit: 101
April 20, 2016, 02:46:43 AM
#3
   -alertnotify=    Execute command when a relevant alert is received or we see a really long fork (%s in cmd is replaced by message)
   -blocknotify=    Execute command when the best block changes (%s in cmd is replaced by block hash)
    -walletnotify=    Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)


So for individual transactions, you would want to use walletnotify, eg:

Code:
bitcoind -walletnotify=/path/to/script.php %s

Then in script.php, you could do something like:

Code:
$tx $argv[1];
$txinfo json_decode( `bitcoin-cli gettransaction $tx` );
if( 
$txinfo['confirmations'] >= ) {
    
// update mysql if necessary.
}
of course with sanitization, error checks, etc....   ;-)


If you are likely to have more than one tx in a given block, a more efficient way to do it can be to include the block-hash with the tx in the db, so you can look up all tx by block.  Then use blocknotify instead of walletnotify.


edit:  and don't forget that the txid can change due to transaction malleability. 

Thanks!

how much times wallet notify call script.php ?
 
full member
Activity: 203
Merit: 168
April 20, 2016, 12:25:45 AM
#2
    -alertnotify=    Execute command when a relevant alert is received or we see a really long fork (%s in cmd is replaced by message)
   -blocknotify=    Execute command when the best block changes (%s in cmd is replaced by block hash)
    -walletnotify=    Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)


So for individual transactions, you would want to use walletnotify, eg:

Code:
bitcoind -walletnotify=/path/to/script.php %s

Then in script.php, you could do something like:

Code:
$tx $argv[1];
$txinfo json_decode( `bitcoin-cli gettransaction $tx` );
if( 
$txinfo['confirmations'] >= ) {
    
// update mysql if necessary.
}
of course with sanitization, error checks, etc....   ;-)


If you are likely to have more than one tx in a given block, a more efficient way to do it can be to include the block-hash with the tx in the db, so you can look up all tx by block.  Then use blocknotify instead of walletnotify.


edit:  and don't forget that the txid can change due to transaction malleability. 
full member
Activity: 224
Merit: 101
April 19, 2016, 09:50:25 AM
#1
Hello,

how to use wallet notify (bitcoind) ?

I generate new address by json-rpc..


I need update info in MySQL after 3 confirmations.

how think how much need confirmations for receive payments?
Pages:
Jump to: