Skip to content

Investigate better utilities for fee management/estimation #258

Open
@mr-zwets

Description

@mr-zwets

@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

Metadata

Metadata

Assignees

No one assigned

    Labels

    javascript-sdkRelates to the CashScript JavaScript SDK

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions