Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate better utilities for fee management/estimation #258

Open
mr-zwets opened this issue Jan 15, 2025 · 0 comments
Open

Investigate better utilities for fee management/estimation #258

mr-zwets opened this issue Jan 15, 2025 · 0 comments
Labels
javascript-sdk Relates to the CashScript JavaScript SDK

Comments

@mr-zwets
Copy link
Member

@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
@mr-zwets mr-zwets added the javascript-sdk Relates to the CashScript JavaScript SDK label Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
javascript-sdk Relates to the CashScript JavaScript SDK
Projects
None yet
Development

No branches or pull requests

1 participant