Client-side Bitcoin JavaScript library for node.js and browsers with comprehensive Bitcoin protocol support
Overall
score
99%
Build a utility that analyzes Bitcoin transactions to calculate their weight and virtual size, distinguishing between legacy and SegWit transactions based on their witness data.
Your solution should handle both legacy transactions (without witness data) and SegWit transactions (with witness data). The system needs to:
@generates
Create a module that exports a function to analyze transactions.
/**
* Analyzes a Bitcoin transaction and returns weight metrics.
*
* @param {string} txHex - The transaction in hexadecimal format
* @returns {Object} Analysis results containing:
* - isSegWit: boolean indicating if transaction uses SegWit
* - weight: number representing transaction weight in weight units
* - virtualSize: number representing vsize in bytes
* - txid: string transaction ID
* @throws {Error} If the transaction hex is invalid
*/
function analyzeTransaction(txHex) {
// IMPLEMENTATION HERE
}
module.exports = { analyzeTransaction };Provides Bitcoin transaction parsing and witness data handling capabilities.
Install with Tessl CLI
npx tessl i tessl/npm-bitcoinjs-libdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10