Bitcoin Forum
May 10, 2024, 03:58:07 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitcoin walletnotify's confirmations number can be increased?  (Read 150 times)
wsxdrfv (OP)
Jr. Member
*
Offline Offline

Activity: 405
Merit: 5


View Profile WWW
June 14, 2018, 05:52:40 AM
 #1

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?
BitcoinCleanup.com: Learn why Bitcoin isn't bad for the environment
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715313487
Hero Member
*
Offline Offline

Posts: 1715313487

View Profile Personal Message (Offline)

Ignore
1715313487
Reply with quote  #2

1715313487
Report to moderator
1715313487
Hero Member
*
Offline Offline

Posts: 1715313487

View Profile Personal Message (Offline)

Ignore
1715313487
Reply with quote  #2

1715313487
Report to moderator
1715313487
Hero Member
*
Offline Offline

Posts: 1715313487

View Profile Personal Message (Offline)

Ignore
1715313487
Reply with quote  #2

1715313487
Report to moderator
starmyc
Full Member
***
Offline Offline

Activity: 198
Merit: 130

Some random software engineer


View Profile
June 14, 2018, 06:06:04 AM
Merited by ABCbits (2), bob123 (1)
 #2

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.

Hi, I'm just some random software engineer.
You can check my projects: Bitcoin & altcoin balances/addresses listing dumps: https://balances.crypto-nerdz.org/
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3388
Merit: 6631


Just writing some code


View Profile WWW
June 14, 2018, 06:28:17 AM
Merited by ABCbits (1), bob123 (1)
 #3

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.

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!