P2PKH transaction on the mainnet

We want to go more in deeper to see the size of a transaction. For this reason we take the standard old p2pkh. We use an existing transaction on the main net. We go to retrieve the transaction details from a node and the raw transaction to check the size if matches. let’s consider the transaction id 0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2 . this is a P2PKH transaction type. If we explore such a transaction with the btcnode_bot telegram bot, we get

/tx@btcnode_bot 0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2

Txid: 0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2

id:7957a35fe64f80d234d76d83a2a8f1a0d8149a41d81de548f0a65a8a999f6f18:0 vout:0 value:0.10000000

#0 value:0.01500000
#1 value:0.08450000

Now we can get the transaction itself from a bitcoin node

dev@core396:~$ bitcoin-cli getrawtransaction 0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2


We can see that the hexadecimal of the transaction is infact 258bytes, that is infact the length that matches on the blockchain. In this case moreover the virtual byte lenght is equal to the lenght because the transaction is P2PKH legacy and not segregated witness.

P2SH-P2WPKH transaction on the testnet

Now let’s check a native segwit transaction with just 1 input and 1 output. For simplicity we do that on the testnet. We are going to prepare it on electrum. As we can see the size shown is 110 bytes (1 input + 1 output). As an empiric roule, each next output added is around 31 bytes more: 1input + 2outputs=141bytes ; 1input + 3outputs= 172 bytes and so on.

now if we check the same on blockstream, as soon as the transaction gets confirmed. and there fore we see as the below image:

We can esily check infact that the size is 191 Bytes (normal size), while 110 Bytes as expected in Virtual size (in this case infact the transaction is segwit so there is a difference between the size and the virtualsize because of the segregation of the witness). So all the valies are matching with what was predicted on the electrum transaction preparing facility