Category: Bitcoin

Guide to avoid scam with crypto

Keep self-custody of your crypto asset

For Noncustodial wallets keep your recovery code safe

Don’t fall in trap if wallet application asks for recovery code for no reasonRecovery code is asked while creating a wallet i.e. initial setup or if you have lost your wallet i.e. recovery – other than that ensure that you are been not phished

Don’t keep all you crypto assets in a single address

Don’t share the same address to multiple person – Private keys are used to generate the Bitcoin Address. For each transaction create a new address. This way you avoid anybody to know how much bitcoin has been sent to that address in total. Generating new address everytime also protects your privacy.

Block explorer privacy – Block explorer is a web appplication that operates as a Bitcoin search engine. You can search by Bitcoin addresse, transaction hash, block number and block hash. Using these applications and searching a transaction allows them to associate the IP address, previous earches and browser details through which can identify and learn your activities. Searching somebody else transaction should not be a problem but if you search your own transactions these operators might be able to analyse the Bitcoin your have received and spent or currently own. So as mentioned earleir each transaction should be on different address to make the operators difficult to identify you.

Ways to acquire a Bitcoin as a new user

Bitcoin transactions are irreversible. So be careful when doing transaction either send or receive. Since the transactions are done on address and there is not identity attached, there is no verification process to check if the address is your’s before doing a transaction. This way acquring, holding and spending bitcoin does not expose your personal identity. Although everybody in the network can see the how much bitcoin is in a address but that address doesn’t disclose your identity. As a new user follow this guidelines-

  • First do a self study how the crypto transaction works. With most of the mobile apps its as as easy as transfering the fiat currency. But if you have a self custodial assets its very important to understand the process. Understand the current Price of bitcoin from the currency exchange, transaction fees, location from where you will be doing transactions. It is good to understand the rules and regulations of the country where you reside.
  • Get introduction about bitcoin from a friend – Take help from you friend who already has Bitcoin and buy from your them directly with a small amount. This should give you a confidence when doing further transactions by yourself. Once you are familiarised and have confidently done transactions help new users and share your expereince.
  • Earn a bitcoin. Earn a bitcoin by providing service with which ever profession you are in. Example- if you are porgrammer you sell your skills for firat currency, instead sell your service for bitcoin. This requires to share your adddress along with the invoice to your client who should then send agreed bitcoin to your address. This way you learn how to generate address to receive bitcoin. Always remember to genereate new address for each invoice. See section “Don’t share the same address to multiple person“.
  • Use Bitcoin ATM – A Bitcoin ATM is a standalone device or kiosk that allows you to buy or sell bitcoin or other cryptocurrencies using a terminal. Bitcoin ATMs are connected to the Internet and often utilize QR codes to send and receive tokens to users’ digital wallets. Bitcoin ATM accepts cash and send bitcoins to your wallet. This way you get to familiarise with bitcoin transaction’s.
  • Use Bitcoin currency eschange – you can buy bitcoin from the digital curerncy exchange such as Coinbase which is linked to your back account. Although they will take the transaction fees but a safe way to buy or sell the bitcoins.

Transaction Fees for transfering funds

Check the current transaction fee while doing the transfer. The higher the transaction fee the faster the transaction is confirmed. If you are in no rush you can set/suggest the transaction fee, which might delay the trasnfer and cosidered in later blocks in network.

Transaction fees collected by miners

Transactions are like double-entry bookkeeping ledger which contains multiple inputs and outputs. The funds you recieve will be slightsly less than you send and the difference represents transaction fee which is collected by miners who includes the transaction in blockchain.

Unconfirmed Transactions

Once the transfer is done you will see the transaction as “Unconfirmed”. This means the transaction has propagated to the network but has not yet been recorded in the blockchain i.e. Bitcoin transaction journal. For this the transaction must be included in block and added to blockchain happens on an average every 10 minutes. Confirmation in traditional terms is the funds clearing.

Change Output

You might see in the transaction multiple outputs, one if then is the output that pays spender called as change. If the address has bitcoin value more than the spend value the change output is given back to spender. e.g. an address has 10000 satoshi and the spend is 6000 satoshi, the output will have 4000 that pays back to spender called as change. The change output does not have to be same address. So the address the value is sent and the change address can be a new address. Transfering to the same address will disclose the privacy so apart from transfering to the new address it is good to transfer the change to new address. Both the address shoud be never-seen-address to prevent from having any privacy issues.

Changeless Output

See change output in other section. Not every transaction has change output such transactions are called as changeless transaction.

Loading

Bitcoin Notes

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)
  • Lightweight client. simplified-payment-verification (SPV)
  • Third-party API client

Abbrevations –

  • SPV – Simplified Payment Verification
  • NFC – Near field communication
  • POW – Proof of work
  • P2P – peer-to-peer network

Computing problems –

  • Byzantine Generals problem – consensus between various parties without a leader in distributed computing

Alogrithms-

  • proof-of-work algorithm (pow)

Setup BTCPay server in Azure

BTCPay Server is a self-hosted, open-source cryptocurrency payment processor. It’s secure, private, censorship-resistant and free.

Refer this link

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.

Loading

Indexing Bitcoin Transaction Database

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 file set 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

bitcoind -reindex -rpcuser=xxxx -rpcpassword=xxxxx

bitcond -txindex option

If the txindex is not set in config before the first run and if later you want to index the database use -txindex option.

bitcoind -txindex -rpcuser=xxxx -rpcpassword=xxxxx

Bitcoin FAQs

How much Satoshi is 1 Bitcoin?

One Hundred Million Satoshi(Sats) is 1 Bitcoin

100000000 Satoshi = 1 Bitcoin

Satoshi to Bitcoin Conversion

SatoshiBitcoin
1 Satoshi (One)(1/100,000,000th)0.00000001 Bitcoin
10 Satoshi (Ten)0.00000010 Bitcoin
100 Satoshi (One Hundred)0.00000100 Bitcoin
1,000 Satoshi (One Thousand)0.00001000 Bitcoin
10,000 Satoshi (Ten Thousand)0.00010000 Bitcoin
100,000 Satoshi ( One Hundred Thousand)0.00100000 Bitcoin
1,000,000 Satoshi ( One Million)0.01000000 Bitcoin
10,000,000 Satoshi (Ten Million)0.10000000 Bitcoin
100,000,000 Satoshi (One Hundred Million)1.00000000 Bitcoin

How to start daemon in background?

To run Bitcoin in background as a process, start the bitcoind with daemon option.

bitcoind -daemon

Popular blockchain explorers-

Bitcoin Block Explorer

BlockCypher Explorer

blockhain.info

Bitpay Insight

mempool space

In these explorer you can search by transaction hash, address, block number and block hash

Loading

Run Bitcoin full test node in Linux

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.

bitcoin-core.daemon -txindex -rpcuser=your_rpc_user -rpcpassword=your_rpc_pwd

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-

2023-07-23T15:14:46Z UpdateTip: new best=0000000000002f4ee789f0bd19066bccd78172ca71995505996fbff1a3341eac height=271984 version=0x00000002 log2_work=60.719797 tx=2107245 date=’2014-08-05T09:37:28Z’ progress=0.031835 cache=337.4MiB(2518207txo)

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.

Quick check-

Pick the block – 2443383

bitcoin-core.cli -rpcuser=xxxx -rpcpassword=xxxxx getblockhash 2443382

It should print the hash-

0000000000000022020dfc2655e4489eb54a8ae306080a47d1fa0be46e0c43a8

Take this hash and use command to get block

bitcoin-core.cli -rpcuser=xxxxxx -rpcpassword=xxxxx getblock 0000000000000022020dfc2655e4489eb54a8ae306080a47d1fa0be46e0c43a8

Output – should show details of the block along with the transactions- I have trimmed the transactions here due to space.

{
  "hash": "0000000000000022020dfc2655e4489eb54a8ae306080a47d1fa0be46e0c43a8",
  "confirmations": 2,
  "height": 2443382,
  "version": 828596224,
  "versionHex": "31636000",
  "merkleroot": "9e0403fef59a803426851f3c428306c15d81360f665f37cc62549825056c6823",
  "time": 1690130435,
  "mediantime": 1690129060,
  "nonce": 2392034863,
  "bits": "192495f8",
  "difficulty": 117392538.8721802,
  "chainwork": "000000000000000000000000000000000000000000000aad36ccc3b8310b4b65",
  "nTx": 26,
  "previousblockhash": "000000000000000b994cbbfe015d77aaa70140af817b6d28d228da690d1ce4da",
  "nextblockhash": "0000000000001019c41ee044adf1c02d347ed52d875eefeb8e629f0a5baa4a8b",
  "strippedsize": 5511,
  "size": 8258,
  "weight": 24791,
  "tx": [
    "b96a95b85e2ec270b471afded7d49c7db46d5002ac43de0bbcc13a4dd972f763",
    "823f5a59b5c6878ba68f21fdfdc9fe796fc879a471d69fcd0430200d9e5aba9a",
    
  ]
}

GetRawTransactions

bitcoin-core.cli -rpcuser=xxxx -rpcpassword=xxxxx getrawtransaction b96a95b85e2ec270b471afded7d49c7db46d5002ac43de0bbcc13a4dd972f763

Output-

010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff1e0376482519444d47426c6f636b636861696e309e3c095f01000000000000ffffffff02b29a270000000000160014b23716e183ba0949c55d6cac21a3e94176eed1120000000000000000266a24aa21a9eddcc8960d06c43b2eaab1e03370081155bac04c26ea7282b8dffaf7c2c452d2220120000000000000000000000000000000000000000000000000000000000000000000000000

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