Bitcoin Forum
June 15, 2024, 09:42:43 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to see transaction size when creating raw transactions?  (Read 346 times)
alikim (OP)
Member
**
Offline Offline

Activity: 80
Merit: 11


View Profile
June 28, 2017, 09:39:18 PM
 #1

After I successfully created and signed a raw transaction with bitcoind-cli, is there a way to see the size of it in bytes, the one that is used for fee per byte calculations?
HCP
Legendary
*
Offline Offline

Activity: 2086
Merit: 4316

<insert witty quote here>


View Profile
June 28, 2017, 11:56:53 PM
Last edit: November 15, 2023, 09:01:41 AM by HCP
 #2

Both the createrawtransaction and signrawtransaction commands should give you the "hex" output of the transaction. The number of characters in that hex string divided by 2 should equal the the transaction size in bytes... as a byte is represented as 2 characters.

For instance, take this raw transaction:
Code:
01000000016efac358d35ea862e8d88b96538acd86b8888e02201535f91bca0fb9bc239c25010000006b483045022100ad50c9e46dbb52b3dbcac8386c41eeac7a4aad2531d6ca708f6a12da2d6754250220448eee510d37db8fb77b462c87dda89233e494355b933df3413b4d985267f2f9012102ffdf17c600f3a3afdf6c946759d65e7923b4bc698ac2e80357b212a56048bdaeffffffff0280234300000000001976a9143c920a4de91cdb35f139d153d7fa5ba379a99c4d88ac3cbbbe2f000000001976a914f13ac2940f286e32da783b27bcf2223c4f23f06d88ac00000000

Length = 452... so the transaction size = 226 bytes.

You can also use the decoderawtransaction command and it will output the JSON of the transaction and you can see the "size" and/or "vsize" elements at the top:


█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
alikim (OP)
Member
**
Offline Offline

Activity: 80
Merit: 11


View Profile
June 29, 2017, 09:46:42 AM
 #3

Thank you!
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!