1

I am using bit library to make a Bitcoin transaction.
I can use methods like this:

key.create_transaction([('1Archive1n2C579dMsAu3iC6tWzuQJz8dN', 190, 'jpy')])

or

key.send([('1Archive1n2C579dMsAu3iC6tWzuQJz8dN', 190, 'jpy')])

However, I'm wondering how can I get the transaction size in bytes so i can estimate the transaction fee.

sr_gi
  • 3,220
  • 1
  • 13
  • 37
reza_khalafi
  • 119
  • 4
  • Related: https://bitcoin.stackexchange.com/q/103654/5406, https://bitcoin.stackexchange.com/a/75124/5406, https://bitcoin.stackexchange.com/a/84006/5406. – Murch May 24 '23 at 12:54
  • @Murch Unfortunately, everyone only explains, it seems that everyone is a good speaker in this matter. But no one can provide sample code. Everyone says to get this first and then that, but how to get the necessary amounts? – reza_khalafi May 24 '23 at 13:20
  • Standard output types have known weights. You can just hardcode the upperbound values for the inputs and outputs. The latter two linked questions include these vsizes, the last even in table format. If you want to calculate them yourself, there is a whole series of topics about different input and output types where the size and weight is deduced from the bytes they are composed of, all tagged with [tag:transaction-weight] e.g. https://bitcoin.stackexchange.com/q/111395/5406, https://bitcoin.stackexchange.com/q/111395/5406, https://bitcoin.stackexchange.com/q/108283/5406 – Murch May 24 '23 at 13:42
  • If you don’t mind reading Typescript, this library has code for transaction weight calculations: https://github.com/BitGo/BitGoJS/tree/master/modules/unspents/src – Murch May 24 '23 at 13:51

0 Answers0