Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: deceive3w on January 10, 2020, 08:15:16 AM



Title: Run Bitcoind without full sync
Post by: deceive3w on January 10, 2020, 08:15:16 AM
I want to using bitcoin-cli to listen new block and make notification when there have a receive transaction. i didnt want to have a ancient block, how to run bitcoin core without sync ancient block but just current blockheight


Title: Re: Run Bitcoind without full sync
Post by: ABCbits on January 10, 2020, 08:58:07 AM
Bitcoin Core don't support such feature, you must download and verify all block at least once. But if you don't mind download all blocks, but only store recent blocks, then pruned mode is what you're looking.

Using 3rd party API or SPV wallet (e.g. Electrum) are other choice you might be interested.


Title: Re: Run Bitcoind without full sync
Post by: pooya87 on January 10, 2020, 09:04:42 AM
that is not how bitcoin works. if you don't first download and verify* all these "ancient" blocks you won't be able to know if the new blocks and transactions that you receive are valid or not. in other words what you call "ancient" block is necessary for decentralized security without needing a middle man.

* you can discard blocks after they were downloaded and verified to end up storing a smaller blockchain database. the process is known as pruning. https://bitcointalk.org/index.php?topic=5213552.0


Title: Re: Run Bitcoind without full sync
Post by: deceive3w on January 10, 2020, 10:53:20 AM
i have tried Electrum but the protocol methods is limited. i want to make notification when there have receive transaction on my child address. if i am using Electrum or third party API, i must get transaction in every block and compare there is such address in my database, that's could have more resource if block have more than 1000+ tx. in bitcoin-cli i think that's possible using method "listtransaction" to get only latest transaction in my child address. or do you have any suggest?. Thanks for response  ;D


Title: Re: Run Bitcoind without full sync
Post by: joniboini on January 11, 2020, 04:09:36 AM
i have tried Electrum but the protocol methods is limited. i want to make notification when there have receive transaction on my child address. if i am using Electrum or third party API, i must get transaction in every block and compare there is such address in my database, that's could have more resource if block have more than 1000+ tx.

That's not really a problem imo. Electrum is quite fast, which is the point of an SPV client.

There is also an alternative for e-mail notifications that are available on a platform such as https://www.blockonomics.co/. You need to pay though.


Title: Re: Run Bitcoind without full sync
Post by: HCP on January 11, 2020, 04:34:19 AM
i have tried Electrum but the protocol methods is limited. i want to make notification when there have receive transaction on my child address. if i am using Electrum or third party API, i must get transaction in every block and compare there is such address in my database, that's could have more resource if block have more than 1000+ tx. in bitcoin-cli i think that's possible using method "listtransaction" to get only latest transaction in my child address. or do you have any suggest?. Thanks for response  ;D
If you're wanting "notifications"... you should probably be using walletnotify. That will trigger the specified script to execute whenever a transaction is received (or confirms etc) that relates to your wallet (and any of the addresses in it).

Quote from: bitcoind commandline arguments
  -walletnotify=<cmd>
       Execute command when a wallet transaction changes (%s in cmd is replaced
       by TxID)

As noted, you can pass in the TxID to that script by using the %s value... and you could then retrieve the information for that specific transaction using gettransaction and parse the JSON returned, instead of returning a bunch of transactions for ALL your addresses using listtransactions and trying to figure out which transaction is "new" etc.


Title: Re: Run Bitcoind without full sync
Post by: tranthidung on January 11, 2020, 05:16:26 AM
I don't know whether there are available scripts to do it with Electrum wallet or not, but if you open your Electrum wallet, you will get notifications for new transactions, both receiving and sending (when you send your coins away).

Electrum wallet is a SPV and much lighter than Bitcoin Core, because it only download block headers, than cost 80 bytes for each block only.

In Electrum, you can use Filter options (for History feature).

  • Activating the Filter option (Wallet > History > Filter)
  • Using the History sub-tab
  • Clicking on All / Specific year / Custom *
  • After choosing Custom, you have to choose the start and end days for the period in which you want to get transaction history.
*: By default, it shows all of your transaction history, whole time, but you can narrow down the observing period by choosing either specific year or (start and end days with Custom) for your interests.

I think you can also export your history: Wallet > History > Export (to .csv).

The export file will contain some variables for you: transaction_hash, label (of your addresses), confirmations, and timestamp. You can sort your transactions out, over timestamp, label, and confirmations. If you filter directly on Electrum, it does not allow you to do multi-filter (by timestamp, and label and the others, so you have to do it handy.


What I present is for offline with export data, but I guess you can write some code to do it, in real-time (not sure). I hope my information give you some ideas to build up your scripts (I guess it is possible).


Title: Re: Run Bitcoind without full sync
Post by: pooya87 on January 11, 2020, 06:39:24 AM
Electrum protocol supports notifications. when you connect to an Electrum node you have an open socket and a bunch of subscriptions to certain addresses which the node will inform you about when there is any new transaction that involves those addresses.
more info can be found on the documentation: https://electrumx.readthedocs.io/en/latest/


Title: Re: Run Bitcoind without full sync
Post by: barrysty1e on March 06, 2020, 05:39:14 AM
I want to using bitcoin-cli to listen new block and make notification when there have a receive transaction. i didnt want to have a ancient block, how to run bitcoin core without sync ancient block but just current blockheight

What you are after is done partially in https://github.com/bitcoin/bitcoin/pull/9483.
While it isnt true SPV mode, it will only synchronize the blockheaders on the chain; then request only blocks which are relevant to the inputs you hold in your wallet.

Hope this helps.


Title: Re: Run Bitcoind without full sync
Post by: maplelake on March 08, 2020, 12:24:52 AM
Electrum protocol supports notifications. when you connect to an Electrum node you have an open socket and a bunch of subscriptions to certain addresses which the node will inform you about when there is any new transaction that involves those addresses.
more info can be found on the documentation: https://electrumx.readthedocs.io/en/latest/
what is Electrum protocal ? is it bitcoin feature or configuration option in bitcoin.conf ?


Title: Re: Run Bitcoind without full sync
Post by: maplelake on March 08, 2020, 12:27:30 AM
i have tried Electrum but the protocol methods is limited. i want to make notification when there have receive transaction on my child address. if i am using Electrum or third party API, i must get transaction in every block and compare there is such address in my database, that's could have more resource if block have more than 1000+ tx. in bitcoin-cli i think that's possible using method "listtransaction" to get only latest transaction in my child address. or do you have any suggest?. Thanks for response  ;D
If you're wanting "notifications"... you should probably be using walletnotify. That will trigger the specified script to execute whenever a transaction is received (or confirms etc) that relates to your wallet (and any of the addresses in it).

Quote from: bitcoind commandline arguments
  -walletnotify=<cmd>
       Execute command when a wallet transaction changes (%s in cmd is replaced
       by TxID)

As noted, you can pass in the TxID to that script by using the %s value... and you could then retrieve the information for that specific transaction using gettransaction and parse the JSON returned, instead of returning a bunch of transactions for ALL your addresses using listtransactions and trying to figure out which transaction is "new" etc.

I think it works. But not practice it.


Title: Re: Run Bitcoind without full sync
Post by: maplelake on March 08, 2020, 12:28:37 AM
I want to using bitcoin-cli to listen new block and make notification when there have a receive transaction. i didnt want to have a ancient block, how to run bitcoin core without sync ancient block but just current blockheight

Use prune to reduce the size of storage.


Title: Re: Run Bitcoind without full sync
Post by: pooya87 on March 08, 2020, 04:37:47 AM
Electrum protocol supports notifications. when you connect to an Electrum node you have an open socket and a bunch of subscriptions to certain addresses which the node will inform you about when there is any new transaction that involves those addresses.
more info can be found on the documentation: https://electrumx.readthedocs.io/en/latest/
what is Electrum protocal ? is it bitcoin feature or configuration option in bitcoin.conf ?

all the additional functionalities and commands that a certain type of bitcoin full nodes support create "Electrum protocol". all these features are added on top of bitcoin core to make it easier for SPV clients to connect to these special nodes and receive their transaction history, etc. faster and easier.

"bitcoin.conf" file is basic configuration that affect the way you run bitcoin core application and is unrelated to this.