Open
Description
@mainnet-pat mentioned an issue on telegram (https://t.me/bch_compilers/8024)
hm it is not trivial in context of multicontract spend to figure out the tx size
it is like for each contract spend in context of builder I need to build simple contract spend to figure out the input size
currently for fee management you'd have to get the current transaction size this way:
const rawTxHex = transactionBuilder.build()
const txLengthBytes = rawTxHex.length / 2
we might want to create fee estimation utilities but we'd need to think what they would look like
bch-js has this
let byteCount = bchjs.BitcoinCash.getByteCount({ P2PKH: 1 }, { P2PKH: 1 });
this would obviously be too simple for cashscript but maybe the idea to make it easy to check bytecount for different tx shapes makes sense.
maybe something like
const currentTxSize = transactionBuilder.getCurrentByteSize()
const changeOutputSize = calculateOutputSizes([
{ type: "P2pkhWithTokens", tokenType: "fungible" }
])
const txSizeWithChange = transactionBuilder.getCurrentByteSize() + changeOutputSize