Author

Topic: Bitcoin walletnotify's confirmations number can be increased? (Read 167 times)

staff
Activity: 3458
Merit: 6793
Just writing some code
Can we increase this number?
No.

If can't, we should revise coin's source code itself? where?
You can't, not without modifying a lot of code. It's almost all in https://github.com/bitcoin/bitcoin/blob/master/src/wallet/wallet.cpp. Bitcoin Core does not actually track the number of confirmations for a transaction; there is no trigger for that. Rather it just records the block height the block including a transaction was found and calculates the confirmations from the current block height. You will need to add something which, for each block, checks all known transactions in the wallet, calculates their confirmations, and triggers walletnotify for transactions at whatever confirmation count.
full member
Activity: 198
Merit: 130
Some random software engineer
So at bitcoin.conf file, there we can set walletnotify option, and it only called when some transaction's confirmations are 0 and 1.

Can we increase this number?

If can't, we should revise coin's source code itself? where?

There is a wallet notification only when there is a wallet change, which happens when a new transaction enters the mempool (confirmation is 0) and when it enters the chain (confirmation will be 1).
In the case you want to have a notification when confirmation number reaches another number, like 6, the best is to keep track in a database confirmed transactions and to use -blocknotify to have a notification when a new blocks comes in. With those information, you'll be able to compute how much confirmation a transaction has (eg: current block number minus the transaction's block number).

Pseudo code:

Code:
In tx notify script:

tx = // the tx passed by argv[1]
tx_info = call gettransaction RPC on tx
block_info = call getblock RPC on tx_info['blockhash']
store in database(tx, block_info['height']) // store in db the tx & the block height


In block notify script:

hash = // the hash passed by argv[1]
confirmation_required = 6
// to retrieve all transactions from your table with confirmation_required number of required confirmation:
txs = select tx from your_table where hash['height'] = tx_block_height + confirmation_required

And you'll be done. You'll have all tx in your wallets with 6 confirmations.
jr. member
Activity: 413
Merit: 5
So at bitcoin.conf file, there we can set walletnotify option, and it only called when some transaction's confirmations are 0 and 1.

Can we increase this number?

If can't, we should revise coin's source code itself? where?
Jump to: