A TypeScript library for accurately calculating Bitcoin transaction sizes, virtual bytes (vBytes), and fees for various script types including SegWit and Taproot.
- Calculate transaction sizes in both vBytes and raw bytes
- Support for all standard script types:
- Legacy (P2PKH, P2SH)
- SegWit (P2WPKH, P2WSH)
- Taproot (P2TR)
- Nested SegWit (P2SH-P2WPKH, P2SH-P2WSH)
- OP_RETURN data size calculation
- Fee estimation based on sat/vByte
- Inscription transaction fee calculation
Type | Description |
---|---|
P2PKH |
Legacy Pay-to-Public-Key-Hash |
P2SH |
Pay-to-Script-Hash |
P2WPKH |
Native SegWit |
P2WSH |
SegWit Script |
P2TR |
Taproot |
P2SH-P2WPKH |
Nested SegWit in P2SH |
P2SH-P2WSH |
Nested SegWit Script in P2SH |
-
Clone the repository:
git clone https://github.com/ordinalsbot/bitcoin-fee-estimator.git cd bitcoin-fee-estimator
-
Optional - Using nvm:
nvm install # Uses version from .nvmrc nvm use # Switches to correct Node version
-
Install dependencies:
npm install
-
Run tests:
npm test
-
Build the project:
npm run build