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 Inputs id:7957a35fe64f80d234d76d83a2a8f1a0d8149a41d81de548f0a65a8a999f6f18:0 vout:0 value:0.10000000 Outputs #0 value:0.01500000 address:1GdK9UzpHBzqzX2A9JFP3Di4weBwqgmoQA #1 value:0.08450000 address:1Cdid9KFAaatwczBwBttQcwXYCpvK8h7FK
Now we can get the transaction itself from a bitcoin node
dev@core396:~$ bitcoin-cli getrawtransaction 0627052b6f28912f2703066a912ea577f2ce4da4caa5a5fbd8a57286c345c2f2 0100000001186f9f998a5aa6f048e51dd8419a14d8a0f1a8a2836dd734d2804fe65fa35779000000008b483045022100884d142d86652a3f47ba4746ec719bbfbd040a570b1deccbb6498c75c4ae24cb02204b9f039ff08df09cbe9f6addac960298cad530a863ea8f53982c09db8f6e381301410484ecc0d46f1918b30928fa0e4ed99f16a0fb4fde0735e7ade8416ab9fe423cc5412336376789d172787ec3457eee41c04f4938de5cc17b4a10fa336a8d752adfffffffff0260e31600000000001976a914ab68025513c3dbd2f7b92a94e0581f5d50f654e788acd0ef8000000000001976a9147f9b1a7fb68d60c536c2fd8aeaa53a8f3cc025a888ac00000000
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