Welcome! This is my personal blog about Web technologies, software development, open source and other related topics
The ideas and opinions expressed here are solely mine and don't represent those of others, either individuals or companies.The code snippets or references to software products or analogous are to be used without any warranty of any kind. If you enjoy the content, feel free to share it and re-use it as long as you provide a link to the original post.
Bitcoin is a internet of money. Invented in 2008. Started in 2009
Bitcoin consists of –
Bitcoin Protocol – A denetralized peer-to-peer network
Blockchain – Public transaction ledger
Consensus rule – Set of rules for independent transaction validation and currency issuance
Proof-of-Work – Distributed computation system.
Mining– A decentralized mathematical and deterministic currency issuance. Competing to find solutions to a mathematical problem while processing bitcoin transactions (power to verify and record transactions) which is done every 10 minutes.
The mining process serves two purposes in bitcoin:
Mining nodes validate all transactions by reference to bitcoin’s consensus rules. Therefore, mining provides security for bitcoin transactions by rejecting invalid or malformed transactions.
Mining creates new bitcoin in each block, almost like a central bank printing new money. The amount of bitcoin created per block is limited and diminishes with time, following a fixed issuance schedule
Transaction script – A decentralized transaction verification system.
Paper title – “Bitcoin: A Peer-to-Peer Electronic Cash System” written by Satoshi Nakamoto.
Fast, Secure and Borderless. Distributed, peer-to-peer system. No central server or point of control. Created through a process called as mining.
Bitcoin is completerly decentralised by design and free of any central authority or point of control that can be attacked or corrupted.
Every 10 minutes or so, Mining computers compete against thousands of similar systems in a global race to find a solution to a block of transactions. Finding such a solution, the so called Proof-of-Work (PoW)
Fixed total 21 millions coins will be created by the year 2140.
Bitcoin is virtual. User of bitcoin own keys that allow then to prove ownership stored in digital wallet.
Application Specific Integrated Circuits (ASIC)
Unverified transactions when included in a new block it is called as candidate block.
Bitcoin Improvement Proposal
Important Notes-
Bitcoin currency will defalte in long term as the rate of issuance will reduce and ultimately diminish.
Bitcoin is not a physical or digital coins. The coins are implied in transactions that can be transfered from sender to receipient.
Bitcoin users can transfer funds using the keys that a re stored in digital wallet/ledger. They need to sign a tranasction to unlock the value and spend it by transfering the funds. key that can sign the transactions is the only pre-requisite to spend bitcoin.
Types of wallets-
Desktop Wallet
Mobile Wallet
Web Wallet
Hardware signing devices (Harware wallet – most secure)
Full node versus lightweight
Full node – offers complete autonomy to its users (self governance)
Create a Resource group in Azure. I create this in West Us region.
Choose the template from the provided link and should take straight to your Azure subscription-
Enter the valid Vm Size and the supported crypto payment.
Select the Network – Mainnet, TestNet or regtest
Select the Ubuntu version. You may select the latest
Resources in Azure
This should create following resources in Azure in the selected resource group-
Navigate to BTCPayServerPublicIP resource. This should show the dns name.
This is your BTC pay admin portal.
Register Admin user
First time when you access the Btc Pay server should ask you to register a user. This user will be a owner.
Login to BTC pay server
Login with the newly created user
You will be asked to configure the lightining network and create a wallet.
Configuring the wallet and lightning network will follow in next blog along with integration with integration with commerce system such as Order Cloud.
Stay tuned to know how to configure this which should ulitmately sync the nodes as shown in below screen.
By default Bitcoin Core builds a database containing only the transactions for the user’s wallet.
Wallet transactions can be retireved using JSON RPC API gettransaction command.
But if you want to retrieve any transaction within the node use command getrawtransaction. This command will search transactions in the index.
bitcoin.conf fileset txindex–
Bitcoin daemon or GUI uses conf file to load settings. On the first bitcoind run it will ask to create a config file.
Set txindex=1 in the config file before running the daemon. If the indexing is enabled the bitcoin daemon then should start synching the blocks and index.
bitcond -reindex option
If the txindex is not set in config before the first run and if later you want to index the database use -reindex option.
Re-index should take a while. To improve perfromance disable -printtoconsole option
This installation is performed on freshly installed Ubuntu system.
sudo apt update
snap install bitcoin-core
This should install Bitcoin Core on Ubuntu machine-
But lets not use GUI for this and setup test node using Bitcoin Daemon.
Bitcoin daemon should be installed in root folder and the executable can be found on this path- /snap/bitcoin-core/141/bin
Use below command to find the version of the daemon-
bitcoin-core.daemon --version
Run command –
bitcoin-core.daemon
Here the last line its expecting a bitcoin.conf file in location- /home/sandy/snap/bitcoin-core/common/.bitcoin/bitcoin.conf. This oath might be different for you.
Create a bitcoin.conf file at this location and paste in following to configure bitcoin daemon to run in test node.
Set the chain=test
set path to blocksdir and datadir
set txindex=1 to index the transaction
Set rpcuser and rpcpassword to use JSON rpc api
server=1 tells Bitcoin-QT to accept JSON-RPC commands.
# [chain]
# Test Network.
chain=test
# [core]
# Specify a non-default location to store blockchain data.
blocksdir=/home/sandy/snap/bitcoin-core/common/.bitcoin
# Specify a non-default location to store blockchain and other data.
datadir=/home/sandy/snap/bitcoin-core/common/.bitcoin
# Options only for mainnet
[main]
# Options only for testnet
[test]
# Options only for regtest
[regtest]
txindex=1
server=1
rpcuser=your_rpc_user
rpcpassword=your_rpc_pwd
rpcallowip=*
-txindex Maintain a full transaction index, used by the getrawtransaction rpc call (default: 0)
-rpcpassword= Password for JSON-RPC connections
-rpcuser= Username for JSON-RPC connections
Run following command to run the daemon in test node. This will download the data which is around 29gb at the time of writing this blog.
This should now start the daemon and will check if the data is available, if not this should start download the blocks.
First it wll pre-Synchronize the block headers and then start Synchronizing headers. At the time of writing this blog there are around 2428000 blocks in test node.
Once synchronizing is complete it should start downloading and indexing blocks-
Here the height is the block it has synchronised and the progress. When the progress is near to 1 it will come to completion of synchronising the node.
In the above example 0000000000002f4ee789f0bd19066bccd78172ca71995505996fbff1a3341eac is a block hash
progress when near to 1 means it about to complete synchronising all blocks.
A new folder called testnet3 will be created in .bitcoin folder – This should be in user folder and not root folder.
For me it took less than 2 hours to sync all blocks.
2023-07-23T16:55:23Z UpdateTip: new best=0000000000000022020dfc2655e4489eb54a8ae306080a47d1fa0be46e0c43a8 height=2443382 version=0x31636000 log2_work=75.416383 tx=66092181 date='2023-07-23T16:40:35Z' progress=0.999999 cache=479.2MiB(3458766txo)
2023-07-23T16:56:04Z New outbound peer connected: version: 70015, blocks=2443382, peer=76 (block-relay-only)
2023-07-23T17:00:42Z Saw new header hash=0000000000001019c41ee044adf1c02d347ed52d875eefeb8e629f0a5baa4a8b height=2443383
2023-07-23T17:00:42Z [net] Saw new cmpctblock header hash=0000000000001019c41ee044adf1c02d347ed52d875eefeb8e629f0a5baa4a8b peer=3
2023-07-23T17:00:42Z UpdateTip: new best=0000000000001019c41ee044adf1c02d347ed52d875eefeb8e629f0a5baa4a8b height=2443383 version=0x29e7a000 log2_work=75.416383 tx=66092225 date='2023-07-23T17:00:37Z' progress=1.000000 cache=479.2MiB(3458790txo)
The last block to sync was 2443382
It also listens to any new block been created on chain- 2443383 which happened after 5 minutes. See highlighted.
This confirms that the blocks are indexed as the getrawtransaction looks for node and not your own wallet transaction.
How to get transaction details will put that in another blog.
Hope this helps to configure full test node on your system.
Performance–
To run the daemon blockonly option –
bitcoind -daemon -blocksonly
.By default, bitcoind relays transactions while you’re syncing and using -blocksonly turns that off. It probably won’t make a huge difference but should save you some bandwidth.
Increase dbcache
-dbcache= The default for this is 450. If you have 8GB of RAM, you could set this to 4096