@btc-vision/bitcoin 6.5.6 → 7.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HOW_TO_WRITE_GOOD_CODE.md +2436 -0
- package/benchmark/psbt-2000-inputs.bench.ts +178 -0
- package/benchmark/signing.bench.ts +147 -0
- package/browser/address.d.ts +56 -9
- package/browser/address.d.ts.map +1 -0
- package/browser/bech32utils.d.ts +9 -1
- package/browser/bech32utils.d.ts.map +1 -0
- package/browser/bip66.d.ts +11 -6
- package/browser/bip66.d.ts.map +1 -0
- package/browser/block.d.ts +117 -11
- package/browser/block.d.ts.map +1 -0
- package/browser/branded.d.ts +20 -0
- package/browser/branded.d.ts.map +1 -0
- package/browser/crypto/crypto.d.ts +1 -0
- package/browser/crypto/crypto.d.ts.map +1 -0
- package/browser/crypto.d.ts +46 -7
- package/browser/crypto.d.ts.map +1 -0
- package/browser/ecc/context.d.ts +129 -0
- package/browser/ecc/context.d.ts.map +1 -0
- package/browser/ecc/index.d.ts +11 -0
- package/browser/ecc/index.d.ts.map +1 -0
- package/browser/ecc/types.d.ts +128 -0
- package/browser/ecc/types.d.ts.map +1 -0
- package/browser/ecpair.d.ts +99 -0
- package/browser/errors.d.ts +124 -0
- package/browser/errors.d.ts.map +1 -0
- package/browser/index.d.ts +32 -5
- package/browser/index.d.ts.map +1 -0
- package/browser/index.js +12482 -101
- package/browser/io/BinaryReader.d.ts +276 -0
- package/browser/io/BinaryReader.d.ts.map +1 -0
- package/browser/io/BinaryWriter.d.ts +391 -0
- package/browser/io/BinaryWriter.d.ts.map +1 -0
- package/browser/io/MemoryPool.d.ts +220 -0
- package/browser/io/MemoryPool.d.ts.map +1 -0
- package/browser/io/base64.d.ts +13 -0
- package/browser/io/base64.d.ts.map +1 -0
- package/browser/io/hex.d.ts +67 -0
- package/browser/io/hex.d.ts.map +1 -0
- package/browser/io/index.d.ts +17 -0
- package/browser/io/index.d.ts.map +1 -0
- package/browser/io/utils.d.ts +199 -0
- package/browser/io/utils.d.ts.map +1 -0
- package/browser/merkle.d.ts +10 -1
- package/browser/merkle.d.ts.map +1 -0
- package/browser/networks.d.ts +70 -9
- package/browser/networks.d.ts.map +1 -0
- package/browser/opcodes.d.ts +1 -0
- package/browser/opcodes.d.ts.map +1 -0
- package/browser/payments/bip341.d.ts +35 -9
- package/browser/payments/bip341.d.ts.map +1 -0
- package/browser/payments/embed.d.ts +112 -1
- package/browser/payments/embed.d.ts.map +1 -0
- package/browser/payments/index.d.ts +17 -10
- package/browser/payments/index.d.ts.map +1 -0
- package/browser/payments/p2ms.d.ts +150 -0
- package/browser/payments/p2ms.d.ts.map +1 -0
- package/browser/payments/p2op.d.ts +150 -24
- package/browser/payments/p2op.d.ts.map +1 -0
- package/browser/payments/p2pk.d.ts +154 -1
- package/browser/payments/p2pk.d.ts.map +1 -0
- package/browser/payments/p2pkh.d.ts +176 -1
- package/browser/payments/p2pkh.d.ts.map +1 -0
- package/browser/payments/p2sh.d.ts +150 -1
- package/browser/payments/p2sh.d.ts.map +1 -0
- package/browser/payments/p2tr.d.ts +185 -1
- package/browser/payments/p2tr.d.ts.map +1 -0
- package/browser/payments/p2wpkh.d.ts +161 -1
- package/browser/payments/p2wpkh.d.ts.map +1 -0
- package/browser/payments/p2wsh.d.ts +146 -1
- package/browser/payments/p2wsh.d.ts.map +1 -0
- package/browser/payments/types.d.ts +94 -64
- package/browser/payments/types.d.ts.map +1 -0
- package/browser/psbt/bip371.d.ts +34 -8
- package/browser/psbt/bip371.d.ts.map +1 -0
- package/browser/psbt/psbtutils.d.ts +56 -16
- package/browser/psbt/psbtutils.d.ts.map +1 -0
- package/browser/psbt/types.d.ts +245 -0
- package/browser/psbt/types.d.ts.map +1 -0
- package/browser/psbt/utils.d.ts +64 -0
- package/browser/psbt/utils.d.ts.map +1 -0
- package/browser/psbt/validation.d.ts +84 -0
- package/browser/psbt/validation.d.ts.map +1 -0
- package/browser/psbt.d.ts +82 -118
- package/browser/psbt.d.ts.map +1 -0
- package/browser/pubkey.d.ts +27 -6
- package/browser/pubkey.d.ts.map +1 -0
- package/browser/push_data.d.ts +24 -2
- package/browser/push_data.d.ts.map +1 -0
- package/browser/script.d.ts +33 -8
- package/browser/script.d.ts.map +1 -0
- package/browser/script_number.d.ts +17 -0
- package/browser/script_number.d.ts.map +1 -0
- package/browser/script_signature.d.ts +23 -5
- package/browser/script_signature.d.ts.map +1 -0
- package/browser/transaction.d.ts +160 -18
- package/browser/transaction.d.ts.map +1 -0
- package/browser/types.d.ts +36 -38
- package/browser/types.d.ts.map +1 -0
- package/browser/workers/WorkerSigningPool.d.ts +143 -0
- package/browser/workers/WorkerSigningPool.d.ts.map +1 -0
- package/browser/workers/WorkerSigningPool.node.d.ts +116 -0
- package/browser/workers/WorkerSigningPool.node.d.ts.map +1 -0
- package/browser/workers/ecc-bundle.d.ts +25 -0
- package/browser/workers/ecc-bundle.d.ts.map +1 -0
- package/browser/workers/index.d.ts +91 -0
- package/browser/workers/index.d.ts.map +1 -0
- package/browser/workers/psbt-parallel.d.ts +88 -0
- package/browser/workers/psbt-parallel.d.ts.map +1 -0
- package/browser/workers/signing-worker.d.ts +37 -0
- package/browser/workers/signing-worker.d.ts.map +1 -0
- package/browser/workers/types.d.ts +365 -0
- package/browser/workers/types.d.ts.map +1 -0
- package/build/address.d.ts +57 -10
- package/build/address.d.ts.map +1 -0
- package/build/address.js +80 -24
- package/build/address.js.map +1 -0
- package/build/bech32utils.d.ts +9 -1
- package/build/bech32utils.d.ts.map +1 -0
- package/build/bech32utils.js +10 -2
- package/build/bech32utils.js.map +1 -0
- package/build/bip66.d.ts +11 -6
- package/build/bip66.d.ts.map +1 -0
- package/build/bip66.js +32 -3
- package/build/bip66.js.map +1 -0
- package/build/block.d.ts +117 -11
- package/build/block.d.ts.map +1 -0
- package/build/block.js +204 -72
- package/build/block.js.map +1 -0
- package/build/branded.d.ts +20 -0
- package/build/branded.d.ts.map +1 -0
- package/build/branded.js +7 -0
- package/build/branded.js.map +1 -0
- package/build/crypto/crypto.d.ts +1 -0
- package/build/crypto/crypto.d.ts.map +1 -0
- package/build/crypto/crypto.js +1 -0
- package/build/crypto/crypto.js.map +1 -0
- package/build/crypto.d.ts +46 -7
- package/build/crypto.d.ts.map +1 -0
- package/build/crypto.js +65 -20
- package/build/crypto.js.map +1 -0
- package/build/ecc/context.d.ts +135 -0
- package/build/ecc/context.d.ts.map +1 -0
- package/build/ecc/context.js +232 -0
- package/build/ecc/context.js.map +1 -0
- package/build/ecc/index.d.ts +11 -0
- package/build/ecc/index.d.ts.map +1 -0
- package/build/ecc/index.js +11 -0
- package/build/ecc/index.js.map +1 -0
- package/build/ecc/types.d.ts +134 -0
- package/build/ecc/types.d.ts.map +1 -0
- package/build/ecc/types.js +8 -0
- package/build/ecc/types.js.map +1 -0
- package/build/errors.d.ts +124 -0
- package/build/errors.d.ts.map +1 -0
- package/build/errors.js +155 -0
- package/build/errors.js.map +1 -0
- package/build/index.d.ts +32 -5
- package/build/index.d.ts.map +1 -0
- package/build/index.js +26 -3
- package/build/index.js.map +1 -0
- package/build/io/BinaryReader.d.ts +276 -0
- package/build/io/BinaryReader.d.ts.map +1 -0
- package/build/io/BinaryReader.js +425 -0
- package/build/io/BinaryReader.js.map +1 -0
- package/build/io/BinaryWriter.d.ts +391 -0
- package/build/io/BinaryWriter.d.ts.map +1 -0
- package/build/io/BinaryWriter.js +611 -0
- package/build/io/BinaryWriter.js.map +1 -0
- package/build/io/MemoryPool.d.ts +220 -0
- package/build/io/MemoryPool.d.ts.map +1 -0
- package/build/io/MemoryPool.js +309 -0
- package/build/io/MemoryPool.js.map +1 -0
- package/build/io/base64.d.ts +13 -0
- package/build/io/base64.d.ts.map +1 -0
- package/build/io/base64.js +20 -0
- package/build/io/base64.js.map +1 -0
- package/build/io/hex.d.ts +67 -0
- package/build/io/hex.d.ts.map +1 -0
- package/build/io/hex.js +138 -0
- package/build/io/hex.js.map +1 -0
- package/build/io/index.d.ts +17 -0
- package/build/io/index.d.ts.map +1 -0
- package/build/io/index.js +23 -0
- package/build/io/index.js.map +1 -0
- package/build/io/utils.d.ts +199 -0
- package/build/io/utils.d.ts.map +1 -0
- package/build/io/utils.js +271 -0
- package/build/io/utils.js.map +1 -0
- package/build/merkle.d.ts +10 -1
- package/build/merkle.d.ts.map +1 -0
- package/build/merkle.js +12 -1
- package/build/merkle.js.map +1 -0
- package/build/networks.d.ts +70 -9
- package/build/networks.d.ts.map +1 -0
- package/build/networks.js +90 -4
- package/build/networks.js.map +1 -0
- package/build/opcodes.d.ts +1 -0
- package/build/opcodes.d.ts.map +1 -0
- package/build/opcodes.js +1 -0
- package/build/opcodes.js.map +1 -0
- package/build/payments/bip341.d.ts +36 -9
- package/build/payments/bip341.d.ts.map +1 -0
- package/build/payments/bip341.js +35 -15
- package/build/payments/bip341.js.map +1 -0
- package/build/payments/embed.d.ts +120 -1
- package/build/payments/embed.d.ts.map +1 -0
- package/build/payments/embed.js +215 -34
- package/build/payments/embed.js.map +1 -0
- package/build/payments/index.d.ts +17 -10
- package/build/payments/index.d.ts.map +1 -0
- package/build/payments/index.js +20 -10
- package/build/payments/index.js.map +1 -0
- package/build/payments/p2ms.d.ts +159 -1
- package/build/payments/p2ms.d.ts.map +1 -0
- package/build/payments/p2ms.js +427 -108
- package/build/payments/p2ms.js.map +1 -0
- package/build/payments/p2op.d.ts +158 -24
- package/build/payments/p2op.d.ts.map +1 -0
- package/build/payments/p2op.js +379 -93
- package/build/payments/p2op.js.map +1 -0
- package/build/payments/p2pk.d.ts +162 -1
- package/build/payments/p2pk.d.ts.map +1 -0
- package/build/payments/p2pk.js +327 -58
- package/build/payments/p2pk.js.map +1 -0
- package/build/payments/p2pkh.d.ts +185 -1
- package/build/payments/p2pkh.d.ts.map +1 -0
- package/build/payments/p2pkh.js +467 -114
- package/build/payments/p2pkh.js.map +1 -0
- package/build/payments/p2sh.d.ts +159 -1
- package/build/payments/p2sh.d.ts.map +1 -0
- package/build/payments/p2sh.js +500 -152
- package/build/payments/p2sh.js.map +1 -0
- package/build/payments/p2tr.d.ts +193 -1
- package/build/payments/p2tr.d.ts.map +1 -0
- package/build/payments/p2tr.js +592 -174
- package/build/payments/p2tr.js.map +1 -0
- package/build/payments/p2wpkh.d.ts +170 -1
- package/build/payments/p2wpkh.d.ts.map +1 -0
- package/build/payments/p2wpkh.js +429 -104
- package/build/payments/p2wpkh.js.map +1 -0
- package/build/payments/p2wsh.d.ts +155 -1
- package/build/payments/p2wsh.d.ts.map +1 -0
- package/build/payments/p2wsh.js +466 -144
- package/build/payments/p2wsh.js.map +1 -0
- package/build/payments/types.d.ts +98 -64
- package/build/payments/types.d.ts.map +1 -0
- package/build/payments/types.js +17 -13
- package/build/payments/types.js.map +1 -0
- package/build/psbt/bip371.d.ts +35 -9
- package/build/psbt/bip371.d.ts.map +1 -0
- package/build/psbt/bip371.js +113 -28
- package/build/psbt/bip371.js.map +1 -0
- package/build/psbt/psbtutils.d.ts +56 -16
- package/build/psbt/psbtutils.d.ts.map +1 -0
- package/build/psbt/psbtutils.js +71 -16
- package/build/psbt/psbtutils.js.map +1 -0
- package/build/psbt/types.d.ts +249 -0
- package/build/psbt/types.d.ts.map +1 -0
- package/build/psbt/types.js +6 -0
- package/build/psbt/types.js.map +1 -0
- package/build/psbt/utils.d.ts +68 -0
- package/build/psbt/utils.d.ts.map +1 -0
- package/build/psbt/utils.js +171 -0
- package/build/psbt/utils.js.map +1 -0
- package/build/psbt/validation.d.ts +88 -0
- package/build/psbt/validation.d.ts.map +1 -0
- package/build/psbt/validation.js +149 -0
- package/build/psbt/validation.js.map +1 -0
- package/build/psbt.d.ts +84 -120
- package/build/psbt.d.ts.map +1 -0
- package/build/psbt.js +411 -412
- package/build/psbt.js.map +1 -0
- package/build/pubkey.d.ts +27 -6
- package/build/pubkey.d.ts.map +1 -0
- package/build/pubkey.js +36 -12
- package/build/pubkey.js.map +1 -0
- package/build/push_data.d.ts +24 -2
- package/build/push_data.d.ts.map +1 -0
- package/build/push_data.js +44 -12
- package/build/push_data.js.map +1 -0
- package/build/script.d.ts +33 -8
- package/build/script.d.ts.map +1 -0
- package/build/script.js +100 -36
- package/build/script.js.map +1 -0
- package/build/script_number.d.ts +17 -0
- package/build/script_number.d.ts.map +1 -0
- package/build/script_number.js +19 -0
- package/build/script_number.js.map +1 -0
- package/build/script_signature.d.ts +23 -5
- package/build/script_signature.d.ts.map +1 -0
- package/build/script_signature.js +48 -15
- package/build/script_signature.js.map +1 -0
- package/build/transaction.d.ts +160 -18
- package/build/transaction.d.ts.map +1 -0
- package/build/transaction.js +443 -176
- package/build/transaction.js.map +1 -0
- package/build/tsconfig.build.tsbuildinfo +1 -0
- package/build/types.d.ts +36 -38
- package/build/types.d.ts.map +1 -0
- package/build/types.js +175 -57
- package/build/types.js.map +1 -0
- package/build/workers/WorkerSigningPool.d.ts +174 -0
- package/build/workers/WorkerSigningPool.d.ts.map +1 -0
- package/build/workers/WorkerSigningPool.js +553 -0
- package/build/workers/WorkerSigningPool.js.map +1 -0
- package/build/workers/WorkerSigningPool.node.d.ts +124 -0
- package/build/workers/WorkerSigningPool.node.d.ts.map +1 -0
- package/build/workers/WorkerSigningPool.node.js +753 -0
- package/build/workers/WorkerSigningPool.node.js.map +1 -0
- package/build/workers/ecc-bundle.d.ts +25 -0
- package/build/workers/ecc-bundle.d.ts.map +1 -0
- package/build/workers/ecc-bundle.js +25 -0
- package/build/workers/ecc-bundle.js.map +1 -0
- package/build/workers/index.d.ts +91 -0
- package/build/workers/index.d.ts.map +1 -0
- package/build/workers/index.js +114 -0
- package/build/workers/index.js.map +1 -0
- package/build/workers/psbt-parallel.d.ts +117 -0
- package/build/workers/psbt-parallel.d.ts.map +1 -0
- package/build/workers/psbt-parallel.js +233 -0
- package/build/workers/psbt-parallel.js.map +1 -0
- package/build/workers/signing-worker.d.ts +37 -0
- package/build/workers/signing-worker.d.ts.map +1 -0
- package/build/workers/signing-worker.js +350 -0
- package/build/workers/signing-worker.js.map +1 -0
- package/build/workers/types.d.ts +365 -0
- package/build/workers/types.d.ts.map +1 -0
- package/build/workers/types.js +60 -0
- package/build/workers/types.js.map +1 -0
- package/package.json +66 -8
- package/scripts/bundle-ecc.ts +111 -0
- package/src/address.ts +81 -44
- package/src/bech32utils.ts +3 -3
- package/src/bip66.ts +34 -24
- package/src/block.ts +196 -84
- package/src/branded.ts +18 -0
- package/src/crypto.ts +64 -26
- package/src/ecc/context.ts +277 -0
- package/src/ecc/index.ts +14 -0
- package/src/ecc/types.ts +154 -0
- package/src/ecpair.d.ts +99 -0
- package/src/errors.ts +163 -0
- package/src/index.ts +113 -9
- package/src/io/BinaryReader.ts +461 -0
- package/src/io/BinaryWriter.ts +696 -0
- package/src/io/MemoryPool.ts +343 -0
- package/src/io/base64.ts +20 -0
- package/src/io/hex.ts +155 -0
- package/src/io/index.ts +41 -0
- package/src/io/utils.ts +283 -0
- package/src/merkle.ts +14 -9
- package/src/networks.ts +9 -9
- package/src/payments/bip341.ts +34 -33
- package/src/payments/embed.ts +244 -41
- package/src/payments/index.ts +12 -10
- package/src/payments/p2ms.ts +490 -118
- package/src/payments/p2op.ts +431 -133
- package/src/payments/p2pk.ts +370 -72
- package/src/payments/p2pkh.ts +524 -130
- package/src/payments/p2sh.ts +572 -172
- package/src/payments/p2tr.ts +686 -194
- package/src/payments/p2wpkh.ts +484 -107
- package/src/payments/p2wsh.ts +526 -164
- package/src/payments/types.ts +80 -66
- package/src/psbt/bip371.ts +68 -51
- package/src/psbt/psbtutils.ts +39 -40
- package/src/psbt/types.ts +331 -0
- package/src/psbt/utils.ts +188 -0
- package/src/psbt/validation.ts +192 -0
- package/src/psbt.ts +566 -809
- package/src/pubkey.ts +22 -23
- package/src/push_data.ts +18 -16
- package/src/script.ts +82 -64
- package/src/script_number.ts +6 -6
- package/src/script_signature.ts +33 -36
- package/src/transaction.ts +458 -238
- package/src/types.ts +231 -100
- package/src/workers/WorkerSigningPool.node.ts +887 -0
- package/src/workers/WorkerSigningPool.ts +670 -0
- package/src/workers/ecc-bundle.ts +26 -0
- package/src/workers/index.ts +165 -0
- package/src/workers/psbt-parallel.ts +332 -0
- package/src/workers/signing-worker.ts +353 -0
- package/src/workers/types.ts +413 -0
- package/test/address.spec.ts +9 -6
- package/test/bitcoin.core.spec.ts +16 -17
- package/test/block.spec.ts +8 -7
- package/test/bufferutils.spec.ts +228 -214
- package/test/crypto.spec.ts +19 -11
- package/test/fixtures/p2pk.json +0 -8
- package/test/fixtures/p2pkh.json +1 -1
- package/test/fixtures/p2sh.json +1 -1
- package/test/fixtures/script.json +1 -1
- package/test/fixtures/transaction.json +2 -2
- package/test/integration/_regtest.ts +25 -0
- package/test/integration/addresses.spec.ts +4 -3
- package/test/integration/bip32.spec.ts +2 -1
- package/test/integration/blocks.spec.ts +1 -1
- package/test/integration/cltv.spec.ts +18 -16
- package/test/integration/csv.spec.ts +37 -64
- package/test/integration/payments.spec.ts +5 -3
- package/test/integration/taproot.spec.ts +76 -83
- package/test/integration/transactions.spec.ts +38 -35
- package/test/payments.spec.ts +35 -13
- package/test/payments.utils.ts +17 -16
- package/test/psbt.spec.ts +111 -100
- package/test/script.spec.ts +11 -10
- package/test/script_signature.spec.ts +9 -11
- package/test/taproot-cache.spec.ts +694 -0
- package/test/transaction.spec.ts +32 -40
- package/test/types.spec.ts +74 -29
- package/test/workers-pool.spec.ts +963 -0
- package/test/workers-signing.spec.ts +635 -0
- package/test/workers.spec.ts +1390 -0
- package/tsconfig.base.json +34 -18
- package/tsconfig.browser.json +15 -0
- package/tsconfig.build.json +5 -0
- package/tsconfig.json +5 -14
- package/vite.config.browser.ts +3 -42
- package/vitest.config.integration.ts +2 -0
- package/browser/bufferutils.d.ts +0 -34
- package/browser/chunks/crypto-BhCpKpek.js +0 -2033
- package/browser/chunks/payments-B1wlSccx.js +0 -1089
- package/browser/chunks/psbt-BCNk7JUx.js +0 -4055
- package/browser/chunks/script-DyPItFEl.js +0 -318
- package/browser/chunks/transaction-C_UbhMGn.js +0 -432
- package/browser/chunks/utils-DNZi-T5W.js +0 -761
- package/browser/ecc_lib.d.ts +0 -3
- package/browser/hooks/AdvancedSignatureManager.d.ts +0 -16
- package/browser/hooks/HookedSigner.d.ts +0 -4
- package/browser/hooks/SignatureManager.d.ts +0 -13
- package/browser/payments/lazy.d.ts +0 -2
- package/browser/typeforce.d.ts +0 -38
- package/build/bufferutils.d.ts +0 -34
- package/build/bufferutils.js +0 -141
- package/build/ecc_lib.d.ts +0 -3
- package/build/ecc_lib.js +0 -61
- package/build/hooks/AdvancedSignatureManager.d.ts +0 -16
- package/build/hooks/AdvancedSignatureManager.js +0 -52
- package/build/hooks/HookedSigner.d.ts +0 -4
- package/build/hooks/HookedSigner.js +0 -64
- package/build/hooks/SignatureManager.d.ts +0 -13
- package/build/hooks/SignatureManager.js +0 -45
- package/build/payments/lazy.d.ts +0 -2
- package/build/payments/lazy.js +0 -28
- package/build/tsconfig.tsbuildinfo +0 -1
- package/src/bufferutils.ts +0 -188
- package/src/ecc_lib.ts +0 -94
- package/src/hooks/AdvancedSignatureManager.ts +0 -104
- package/src/hooks/HookedSigner.ts +0 -108
- package/src/hooks/SignatureManager.ts +0 -84
- package/src/payments/lazy.ts +0 -28
- package/src/typeforce.d.ts +0 -38
- package/tsconfig.webpack.json +0 -18
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BinaryReader.js","sourceRoot":"","sources":["../../src/io/BinaryReader.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,OAAO,YAAY;IACrB;;OAEG;IACM,KAAK,CAAa;IAE3B;;OAEG;IACM,KAAK,CAAW;IAEzB;;OAEG;IACH,OAAO,CAAS;IAEhB;;;;;;;;;;;;;OAaG;IACH,YAAmB,IAAgB,EAAE,SAAiB,CAAC;QACnD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC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AAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED;;;;;OAKG;IACI,IAAI,CAAC,MAAc;QACtB,IAAI,IAAI,CAAC,OAAO,GAAG,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YAC5C,MAAM,IAAI,UAAU,CAAC,yBAAyB,CAAC,CAAC;QACpD,CAAC;QACD,IAAI,CAAC,OAAO,IAAI,MAAM,CAAC;IAC3B,CAAC;IAED;;OAEG;IACI,KAAK;QACR,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACI,OAAO;QACV,OAAO,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC5C,CAAC;CACJ"}
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stateful binary writer with a single DataView instance.
|
|
3
|
+
*
|
|
4
|
+
* Zero allocations during write operations. The DataView is created once
|
|
5
|
+
* in the constructor and reused for all writes.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* High-performance binary writer for serializing binary data.
|
|
11
|
+
*
|
|
12
|
+
* Creates exactly ONE DataView instance that is reused for all write operations.
|
|
13
|
+
* This eliminates garbage collection pressure from repeated DataView allocations.
|
|
14
|
+
*
|
|
15
|
+
* Methods return `this` for chaining.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { BinaryWriter } from '@btc-vision/bitcoin';
|
|
20
|
+
*
|
|
21
|
+
* // Serialize a simple structure
|
|
22
|
+
* const writer = new BinaryWriter(16);
|
|
23
|
+
* writer
|
|
24
|
+
* .writeInt32LE(1) // version
|
|
25
|
+
* .writeUInt32LE(0) // input count
|
|
26
|
+
* .writeUInt32LE(0) // output count
|
|
27
|
+
* .writeUInt32LE(0); // locktime
|
|
28
|
+
*
|
|
29
|
+
* const bytes = writer.finish();
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare class BinaryWriter {
|
|
33
|
+
#private;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a new BinaryWriter with a pre-allocated buffer.
|
|
36
|
+
*
|
|
37
|
+
* @param size - Size of the buffer in bytes
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* import { BinaryWriter } from '@btc-vision/bitcoin';
|
|
42
|
+
*
|
|
43
|
+
* const writer = new BinaryWriter(1024);
|
|
44
|
+
* writer.writeUInt32LE(42);
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
constructor(size: number);
|
|
48
|
+
/**
|
|
49
|
+
* Creates a new BinaryWriter wrapping an existing buffer.
|
|
50
|
+
*
|
|
51
|
+
* @param buffer - Existing buffer to write into
|
|
52
|
+
* @param offset - Initial write position (default 0)
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* import { BinaryWriter } from '@btc-vision/bitcoin';
|
|
57
|
+
*
|
|
58
|
+
* const buffer = new Uint8Array(1024);
|
|
59
|
+
* const writer = new BinaryWriter(buffer, 10); // Start at offset 10
|
|
60
|
+
* writer.writeUInt32LE(42);
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
constructor(buffer: Uint8Array, offset?: number);
|
|
64
|
+
/**
|
|
65
|
+
* Creates a BinaryWriter with automatic capacity management.
|
|
66
|
+
*
|
|
67
|
+
* Initial capacity is 256 bytes, grows as needed.
|
|
68
|
+
*
|
|
69
|
+
* @returns A new GrowableBinaryWriter instance
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* import { BinaryWriter } from '@btc-vision/bitcoin';
|
|
74
|
+
*
|
|
75
|
+
* const writer = BinaryWriter.growable();
|
|
76
|
+
* writer.writeUInt32LE(1);
|
|
77
|
+
* writer.writeBytes(new Uint8Array(1000)); // Automatically grows
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
static growable(initialCapacity?: number): GrowableBinaryWriter;
|
|
81
|
+
/**
|
|
82
|
+
* Current write position in the buffer.
|
|
83
|
+
*/
|
|
84
|
+
get offset(): number;
|
|
85
|
+
/**
|
|
86
|
+
* Sets the write position.
|
|
87
|
+
*
|
|
88
|
+
* @param value - New offset value
|
|
89
|
+
* @throws RangeError if offset is negative or beyond buffer length
|
|
90
|
+
*/
|
|
91
|
+
set offset(value: number);
|
|
92
|
+
/**
|
|
93
|
+
* Total capacity of the underlying buffer.
|
|
94
|
+
*/
|
|
95
|
+
get capacity(): number;
|
|
96
|
+
/**
|
|
97
|
+
* Number of bytes remaining in the buffer.
|
|
98
|
+
*/
|
|
99
|
+
get remaining(): number;
|
|
100
|
+
/**
|
|
101
|
+
* The underlying data buffer.
|
|
102
|
+
*/
|
|
103
|
+
get data(): Uint8Array;
|
|
104
|
+
/**
|
|
105
|
+
* Writes an 8-bit unsigned integer.
|
|
106
|
+
*
|
|
107
|
+
* @param value - Value to write (0-255)
|
|
108
|
+
* @returns This writer for chaining
|
|
109
|
+
* @throws RangeError if writing past end of buffer
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* writer.writeUInt8(255);
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
writeUInt8(value: number): this;
|
|
117
|
+
/**
|
|
118
|
+
* Writes an 8-bit signed integer.
|
|
119
|
+
*
|
|
120
|
+
* @param value - Value to write (-128 to 127)
|
|
121
|
+
* @returns This writer for chaining
|
|
122
|
+
* @throws RangeError if writing past end of buffer
|
|
123
|
+
*/
|
|
124
|
+
writeInt8(value: number): this;
|
|
125
|
+
/**
|
|
126
|
+
* Writes a 16-bit unsigned integer in little-endian format.
|
|
127
|
+
*
|
|
128
|
+
* @param value - Value to write (0-65535)
|
|
129
|
+
* @returns This writer for chaining
|
|
130
|
+
* @throws RangeError if writing past end of buffer
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```typescript
|
|
134
|
+
* writer.writeUInt16LE(1); // Writes 01 00
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
writeUInt16LE(value: number): this;
|
|
138
|
+
/**
|
|
139
|
+
* Writes a 16-bit signed integer in little-endian format.
|
|
140
|
+
*
|
|
141
|
+
* @param value - Value to write (-32768 to 32767)
|
|
142
|
+
* @returns This writer for chaining
|
|
143
|
+
* @throws RangeError if writing past end of buffer
|
|
144
|
+
*/
|
|
145
|
+
writeInt16LE(value: number): this;
|
|
146
|
+
/**
|
|
147
|
+
* Writes a 32-bit unsigned integer in little-endian format.
|
|
148
|
+
*
|
|
149
|
+
* @param value - Value to write (0 to 4294967295)
|
|
150
|
+
* @returns This writer for chaining
|
|
151
|
+
* @throws RangeError if writing past end of buffer
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* writer.writeUInt32LE(1); // Writes 01 00 00 00
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
writeUInt32LE(value: number): this;
|
|
159
|
+
/**
|
|
160
|
+
* Writes a 32-bit signed integer in little-endian format.
|
|
161
|
+
*
|
|
162
|
+
* @param value - Value to write (-2147483648 to 2147483647)
|
|
163
|
+
* @returns This writer for chaining
|
|
164
|
+
* @throws RangeError if writing past end of buffer
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```typescript
|
|
168
|
+
* writer.writeInt32LE(-1); // Writes ff ff ff ff
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
writeInt32LE(value: number): this;
|
|
172
|
+
/**
|
|
173
|
+
* Writes a 64-bit unsigned integer in little-endian format.
|
|
174
|
+
*
|
|
175
|
+
* @param value - Value to write as bigint
|
|
176
|
+
* @returns This writer for chaining
|
|
177
|
+
* @throws RangeError if writing past end of buffer
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```typescript
|
|
181
|
+
* writer.writeUInt64LE(50000n); // Writes 50 c3 00 00 00 00 00 00
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
writeUInt64LE(value: bigint): this;
|
|
185
|
+
/**
|
|
186
|
+
* Writes a 64-bit signed integer in little-endian format.
|
|
187
|
+
*
|
|
188
|
+
* @param value - Value to write as bigint
|
|
189
|
+
* @returns This writer for chaining
|
|
190
|
+
* @throws RangeError if writing past end of buffer
|
|
191
|
+
*/
|
|
192
|
+
writeInt64LE(value: bigint): this;
|
|
193
|
+
/**
|
|
194
|
+
* Writes raw bytes.
|
|
195
|
+
*
|
|
196
|
+
* @param bytes - Bytes to write
|
|
197
|
+
* @returns This writer for chaining
|
|
198
|
+
* @throws RangeError if writing past end of buffer
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```typescript
|
|
202
|
+
* writer.writeBytes(new Uint8Array([0xde, 0xad, 0xbe, 0xef]));
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
writeBytes(bytes: Uint8Array): this;
|
|
206
|
+
/**
|
|
207
|
+
* Writes a Bitcoin CompactSize variable-length integer.
|
|
208
|
+
*
|
|
209
|
+
* CompactSize encoding:
|
|
210
|
+
* - 0x00-0xFC: 1 byte (value as-is)
|
|
211
|
+
* - 0xFD-0xFFFF: 3 bytes (0xFD + 2-byte LE uint16)
|
|
212
|
+
* - 0x10000-0xFFFFFFFF: 5 bytes (0xFE + 4-byte LE uint32)
|
|
213
|
+
* - Larger: 9 bytes (0xFF + 8-byte LE uint64)
|
|
214
|
+
*
|
|
215
|
+
* @param value - Value to write
|
|
216
|
+
* @returns This writer for chaining
|
|
217
|
+
* @throws RangeError if writing past end of buffer
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```typescript
|
|
221
|
+
* writer.writeVarInt(252); // Writes fc
|
|
222
|
+
* writer.writeVarInt(253); // Writes fd fd 00
|
|
223
|
+
* writer.writeVarInt(65535); // Writes fd ff ff
|
|
224
|
+
* writer.writeVarInt(65536); // Writes fe 00 00 01 00
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
writeVarInt(value: number): this;
|
|
228
|
+
/**
|
|
229
|
+
* Writes a Bitcoin CompactSize variable-length integer from bigint.
|
|
230
|
+
*
|
|
231
|
+
* @param value - Value to write as bigint
|
|
232
|
+
* @returns This writer for chaining
|
|
233
|
+
* @throws RangeError if writing past end of buffer
|
|
234
|
+
*/
|
|
235
|
+
writeVarIntBig(value: bigint): this;
|
|
236
|
+
/**
|
|
237
|
+
* Writes a length-prefixed byte array (VarInt length + bytes).
|
|
238
|
+
*
|
|
239
|
+
* @param bytes - Bytes to write
|
|
240
|
+
* @returns This writer for chaining
|
|
241
|
+
* @throws RangeError if writing past end of buffer
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* ```typescript
|
|
245
|
+
* writer.writeVarBytes(new Uint8Array([0xde, 0xad])); // Writes 02 de ad
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
248
|
+
writeVarBytes(bytes: Uint8Array): this;
|
|
249
|
+
/**
|
|
250
|
+
* Writes an array of length-prefixed byte arrays.
|
|
251
|
+
*
|
|
252
|
+
* Format: VarInt count + (VarInt length + bytes) for each item.
|
|
253
|
+
*
|
|
254
|
+
* @param vector - Array of byte arrays to write
|
|
255
|
+
* @returns This writer for chaining
|
|
256
|
+
* @throws RangeError if writing past end of buffer
|
|
257
|
+
*/
|
|
258
|
+
writeVector(vector: readonly Uint8Array[]): this;
|
|
259
|
+
/**
|
|
260
|
+
* Fills a region with a specific byte value.
|
|
261
|
+
*
|
|
262
|
+
* @param value - Byte value to fill with
|
|
263
|
+
* @param length - Number of bytes to fill
|
|
264
|
+
* @returns This writer for chaining
|
|
265
|
+
* @throws RangeError if writing past end of buffer
|
|
266
|
+
*/
|
|
267
|
+
fill(value: number, length: number): this;
|
|
268
|
+
/**
|
|
269
|
+
* Skips a specified number of bytes (leaves them unchanged).
|
|
270
|
+
*
|
|
271
|
+
* @param length - Number of bytes to skip
|
|
272
|
+
* @returns This writer for chaining
|
|
273
|
+
* @throws RangeError if skipping past end of buffer
|
|
274
|
+
*/
|
|
275
|
+
skip(length: number): this;
|
|
276
|
+
/**
|
|
277
|
+
* Resets the write position to the beginning.
|
|
278
|
+
*
|
|
279
|
+
* @returns This writer for chaining
|
|
280
|
+
*/
|
|
281
|
+
reset(): this;
|
|
282
|
+
/**
|
|
283
|
+
* Verifies the buffer was fully written and returns it.
|
|
284
|
+
*
|
|
285
|
+
* Unlike {@link finish}, this method throws if the writer has not
|
|
286
|
+
* written exactly to the end of the buffer.
|
|
287
|
+
*
|
|
288
|
+
* @returns The underlying buffer
|
|
289
|
+
* @throws Error if the buffer was not fully written
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* ```typescript
|
|
293
|
+
* const writer = new BinaryWriter(8);
|
|
294
|
+
* writer.writeUInt32LE(1);
|
|
295
|
+
* writer.writeUInt32LE(2);
|
|
296
|
+
* const bytes = writer.end(); // OK: wrote exactly 8 bytes
|
|
297
|
+
*
|
|
298
|
+
* const writer2 = new BinaryWriter(8);
|
|
299
|
+
* writer2.writeUInt32LE(1);
|
|
300
|
+
* writer2.end(); // throws: buffer size 8, offset 4
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
end(): Uint8Array;
|
|
304
|
+
/**
|
|
305
|
+
* Returns the written portion of the buffer.
|
|
306
|
+
*
|
|
307
|
+
* If the entire buffer was written, returns the buffer directly (no copy).
|
|
308
|
+
* Otherwise, returns a subarray view.
|
|
309
|
+
*
|
|
310
|
+
* @returns Uint8Array containing the written data
|
|
311
|
+
*
|
|
312
|
+
* @example
|
|
313
|
+
* ```typescript
|
|
314
|
+
* const writer = new BinaryWriter(100);
|
|
315
|
+
* writer.writeUInt32LE(42);
|
|
316
|
+
* const bytes = writer.finish(); // 4 bytes
|
|
317
|
+
* ```
|
|
318
|
+
*/
|
|
319
|
+
finish(): Uint8Array;
|
|
320
|
+
/**
|
|
321
|
+
* Returns the written portion as a hex string.
|
|
322
|
+
*
|
|
323
|
+
* @returns Hex string representation
|
|
324
|
+
*
|
|
325
|
+
* @example
|
|
326
|
+
* ```typescript
|
|
327
|
+
* const writer = new BinaryWriter(4);
|
|
328
|
+
* writer.writeUInt32LE(1);
|
|
329
|
+
* writer.toHex(); // '01000000'
|
|
330
|
+
* ```
|
|
331
|
+
*/
|
|
332
|
+
toHex(): string;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* A BinaryWriter that automatically grows its buffer as needed.
|
|
336
|
+
*
|
|
337
|
+
* Use when the final size is unknown.
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* ```typescript
|
|
341
|
+
* const writer = BinaryWriter.growable();
|
|
342
|
+
* writer.writeBytes(largeData); // Automatically grows
|
|
343
|
+
* const bytes = writer.finish();
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
346
|
+
export declare class GrowableBinaryWriter {
|
|
347
|
+
#private;
|
|
348
|
+
/**
|
|
349
|
+
* Creates a new GrowableBinaryWriter.
|
|
350
|
+
*
|
|
351
|
+
* @param initialCapacity - Initial buffer size (default 256)
|
|
352
|
+
*/
|
|
353
|
+
constructor(initialCapacity?: number);
|
|
354
|
+
/**
|
|
355
|
+
* Current write position.
|
|
356
|
+
*/
|
|
357
|
+
get offset(): number;
|
|
358
|
+
/**
|
|
359
|
+
* Sets the write position.
|
|
360
|
+
*
|
|
361
|
+
* @param value - New offset value
|
|
362
|
+
* @throws RangeError if offset is negative
|
|
363
|
+
*/
|
|
364
|
+
set offset(value: number);
|
|
365
|
+
/**
|
|
366
|
+
* Current buffer capacity.
|
|
367
|
+
*/
|
|
368
|
+
get capacity(): number;
|
|
369
|
+
writeUInt8(value: number): this;
|
|
370
|
+
writeUInt16LE(value: number): this;
|
|
371
|
+
writeUInt32LE(value: number): this;
|
|
372
|
+
writeInt32LE(value: number): this;
|
|
373
|
+
writeUInt64LE(value: bigint): this;
|
|
374
|
+
writeBytes(bytes: Uint8Array): this;
|
|
375
|
+
writeVarInt(value: number): this;
|
|
376
|
+
writeVarBytes(bytes: Uint8Array): this;
|
|
377
|
+
writeVector(vector: readonly Uint8Array[]): this;
|
|
378
|
+
/**
|
|
379
|
+
* Returns the written data as a new Uint8Array.
|
|
380
|
+
*
|
|
381
|
+
* @returns Copy of the written data
|
|
382
|
+
*/
|
|
383
|
+
finish(): Uint8Array;
|
|
384
|
+
/**
|
|
385
|
+
* Returns the written data as a hex string.
|
|
386
|
+
*
|
|
387
|
+
* @returns Hex string representation
|
|
388
|
+
*/
|
|
389
|
+
toHex(): string;
|
|
390
|
+
}
|
|
391
|
+
//# sourceMappingURL=BinaryWriter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BinaryWriter.d.ts","sourceRoot":"","sources":["../../src/io/BinaryWriter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,YAAY;;IAgBrB;;;;;;;;;;;;OAYG;gBACgB,IAAI,EAAE,MAAM;IAE/B;;;;;;;;;;;;;;OAcG;gBACgB,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,MAAM;IAatD;;;;;;;;;;;;;;;OAeG;WACW,QAAQ,CAAC,eAAe,GAAE,MAAY,GAAG,oBAAoB;IAI3E;;OAEG;IACH,IAAW,MAAM,IAAI,MAAM,CAE1B;IAED;;;;;OAKG;IACH,IAAW,MAAM,CAAC,KAAK,EAAE,MAAM,EAK9B;IAED;;OAEG;IACH,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED;;OAEG;IACH,IAAW,SAAS,IAAI,MAAM,CAE7B;IAED;;OAEG;IACH,IAAW,IAAI,IAAI,UAAU,CAE5B;IAED;;;;;;;;;;;OAWG;IACI,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAQtC;;;;;;OAMG;IACI,SAAS,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