@btc-vision/bitcoin 6.5.6 → 7.0.0-alpha.1
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 +57 -10
- 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 +12477 -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 +58 -11
- package/build/address.d.ts.map +1 -0
- package/build/address.js +82 -25
- 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 +202 -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 +35 -9
- package/build/payments/bip341.d.ts.map +1 -0
- package/build/payments/bip341.js +34 -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 -150
- 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 +428 -103
- 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 +465 -143
- 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 +117 -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 +406 -413
- 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 +101 -37
- 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 +169 -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 +68 -9
- package/scripts/bundle-ecc.ts +111 -0
- package/src/address.ts +91 -45
- package/src/bech32utils.ts +3 -3
- package/src/bip66.ts +34 -24
- package/src/block.ts +205 -86
- package/src/branded.ts +18 -0
- package/src/crypto.ts +64 -26
- package/src/ecc/context.ts +280 -0
- package/src/ecc/index.ts +14 -0
- package/src/ecc/types.ts +147 -0
- package/src/ecpair.d.ts +99 -0
- package/src/errors.ts +163 -0
- package/src/index.ts +112 -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 +32 -33
- package/src/payments/embed.ts +244 -41
- package/src/payments/index.ts +12 -10
- package/src/payments/p2ms.ts +497 -118
- package/src/payments/p2op.ts +432 -134
- package/src/payments/p2pk.ts +370 -72
- package/src/payments/p2pkh.ts +524 -130
- package/src/payments/p2sh.ts +572 -169
- package/src/payments/p2tr.ts +686 -194
- package/src/payments/p2wpkh.ts +482 -105
- package/src/payments/p2wsh.ts +524 -162
- package/src/payments/types.ts +80 -66
- package/src/psbt/bip371.ts +72 -51
- package/src/psbt/psbtutils.ts +39 -40
- package/src/psbt/types.ts +324 -0
- package/src/psbt/utils.ts +188 -0
- package/src/psbt/validation.ts +185 -0
- package/src/psbt.ts +608 -827
- package/src/pubkey.ts +22 -23
- package/src/push_data.ts +18 -16
- package/src/script.ts +81 -66
- package/src/script_number.ts +6 -6
- package/src/script_signature.ts +33 -36
- package/src/transaction.ts +462 -239
- package/src/types.ts +229 -100
- package/src/workers/WorkerSigningPool.node.ts +887 -0
- package/src/workers/WorkerSigningPool.ts +666 -0
- package/src/workers/ecc-bundle.ts +26 -0
- package/src/workers/index.ts +165 -0
- package/src/workers/psbt-parallel.ts +327 -0
- package/src/workers/signing-worker.ts +353 -0
- package/src/workers/types.ts +417 -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/typedoc.json +29 -0
- 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
package/browser/psbt.d.ts
CHANGED
|
@@ -1,34 +1,58 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { KeyValue, PartialSig, PsbtGlobal, PsbtGlobalUpdate, PsbtInput, PsbtInputUpdate, PsbtOutput, PsbtOutputUpdate } from 'bip174/src/lib/interfaces.js';
|
|
1
|
+
import { KeyValue, PartialSig, PsbtGlobalUpdate, PsbtInput, PsbtInputUpdate, PsbtOutputUpdate } from 'bip174';
|
|
3
2
|
import { BIP32Interface } from '@btc-vision/bip32';
|
|
4
3
|
import { ECPairInterface } from 'ecpair';
|
|
5
|
-
import { Network } from './networks.js';
|
|
6
4
|
import { Transaction } from './transaction.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
5
|
+
import { Bytes32, PublicKey, Script } from './types.js';
|
|
6
|
+
import { AllScriptType, FinalScriptsFunc, FinalTaprootScriptsFunc, HDSigner, HDSignerAsync, PsbtBaseExtended, PsbtCache, PsbtInputExtended, PsbtOpts, PsbtOptsOptional, PsbtOutputExtended, PsbtTxInput, PsbtTxOutput, Signer, SignerAlternative, SignerAsync, TaprootHashCheckSigner, ValidateSigFunction } from './psbt/types.js';
|
|
7
|
+
export type { TransactionInput, PsbtTxInput, TransactionOutput, PsbtTxOutput, ValidateSigFunction, PsbtBaseExtended, PsbtOptsOptional, PsbtOpts, PsbtInputExtended, PsbtOutputExtended, PsbtOutputExtendedAddress, PsbtOutputExtendedScript, HDSigner, HDSignerAsync, SignerAlternative, Signer, SignerAsync, TaprootHashCheckSigner, PsbtCache, TxCacheNumberKey, ScriptType, AllScriptType, GetScriptReturn, FinalScriptsFunc, FinalTaprootScriptsFunc, } from './psbt/types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Psbt class can parse and generate a PSBT binary based off of the BIP174.
|
|
10
|
+
* There are 6 roles that this class fulfills. (Explained in BIP174)
|
|
11
|
+
*
|
|
12
|
+
* Creator: This can be done with `new Psbt()`
|
|
13
|
+
*
|
|
14
|
+
* Updater: This can be done with `psbt.addInput(input)`, `psbt.addInputs(inputs)`,
|
|
15
|
+
* `psbt.addOutput(output)`, `psbt.addOutputs(outputs)` when you are looking to
|
|
16
|
+
* add new inputs and outputs to the PSBT, and `psbt.updateGlobal(itemObject)`,
|
|
17
|
+
* `psbt.updateInput(itemObject)`, `psbt.updateOutput(itemObject)`
|
|
18
|
+
* addInput requires hash: Uint8Array | string; and index: number; as attributes
|
|
19
|
+
* and can also include any attributes that are used in updateInput method.
|
|
20
|
+
* addOutput requires script: Uint8Array; and value: bigint; and likewise can include
|
|
21
|
+
* data for updateOutput.
|
|
22
|
+
* For a list of what attributes should be what types. Check the bip174 library.
|
|
23
|
+
* Also, check the integration tests for some examples of usage.
|
|
24
|
+
*
|
|
25
|
+
* Signer: There are a few methods. signAllInputs and signAllInputsAsync, which will search all input
|
|
26
|
+
* information for your pubkey or pubkeyhash, and only sign inputs where it finds
|
|
27
|
+
* your info. Or you can explicitly sign a specific input with signInput and
|
|
28
|
+
* signInputAsync. For the async methods you can create a SignerAsync object
|
|
29
|
+
* and use something like a hardware wallet to sign with. (You must implement this)
|
|
30
|
+
*
|
|
31
|
+
* Combiner: psbts can be combined easily with `psbt.combine(psbt2, psbt3, psbt4 ...)`
|
|
32
|
+
* the psbt calling combine will always have precedence when a conflict occurs.
|
|
33
|
+
* Combine checks if the internal bitcoin transaction is the same, so be sure that
|
|
34
|
+
* all sequences, version, locktime, etc. are the same before combining.
|
|
35
|
+
*
|
|
36
|
+
* Input Finalizer: This role is fairly important. Not only does it need to construct
|
|
37
|
+
* the input scriptSigs and witnesses, but it SHOULD verify the signatures etc.
|
|
38
|
+
* Before running `psbt.finalizeAllInputs()` please run `psbt.validateSignaturesOfAllInputs()`
|
|
39
|
+
* Running any finalize method will delete any data in the input(s) that are no longer
|
|
40
|
+
* needed due to the finalized scripts containing the information.
|
|
41
|
+
*
|
|
42
|
+
* Transaction Extractor: This role will perform some checks before returning a
|
|
43
|
+
* Transaction object. Such as fee rate not being larger than maximumFeeRate etc.
|
|
44
|
+
*/
|
|
45
|
+
/**
|
|
46
|
+
* Psbt class can parse and generate a PSBT binary based off of the BIP174.
|
|
47
|
+
*/
|
|
27
48
|
export declare class Psbt {
|
|
49
|
+
#private;
|
|
28
50
|
data: PsbtBaseExtended;
|
|
29
|
-
private readonly __CACHE;
|
|
30
|
-
private readonly opts;
|
|
31
51
|
constructor(opts?: PsbtOptsOptional, data?: PsbtBaseExtended);
|
|
52
|
+
/** @internal - Exposed for testing. Do not use in production code. */
|
|
53
|
+
get __CACHE(): PsbtCache;
|
|
54
|
+
/** @internal - Exposed for testing. Do not use in production code. */
|
|
55
|
+
get opts(): PsbtOpts;
|
|
32
56
|
get inputCount(): number;
|
|
33
57
|
get version(): number;
|
|
34
58
|
set version(version: number);
|
|
@@ -38,7 +62,7 @@ export declare class Psbt {
|
|
|
38
62
|
get txOutputs(): PsbtTxOutput[];
|
|
39
63
|
static fromBase64(data: string, opts?: PsbtOptsOptional): Psbt;
|
|
40
64
|
static fromHex(data: string, opts?: PsbtOptsOptional): Psbt;
|
|
41
|
-
static fromBuffer(buffer:
|
|
65
|
+
static fromBuffer(buffer: Uint8Array, opts?: PsbtOptsOptional): Psbt;
|
|
42
66
|
combine(...those: Psbt[]): this;
|
|
43
67
|
clone(): Psbt;
|
|
44
68
|
setMaximumFeeRate(satoshiPerByte: number): void;
|
|
@@ -48,32 +72,43 @@ export declare class Psbt {
|
|
|
48
72
|
setInputSequence(inputIndex: number, sequence: number): this;
|
|
49
73
|
addInputs(inputDatas: PsbtInputExtended[], checkPartialSigs?: boolean): this;
|
|
50
74
|
addInput(inputData: PsbtInputExtended, checkPartialSigs?: boolean): this;
|
|
51
|
-
addOutputs(outputDatas: PsbtOutputExtended[]): this;
|
|
52
|
-
|
|
75
|
+
addOutputs(outputDatas: PsbtOutputExtended[], checkPartialSigs?: boolean): this;
|
|
76
|
+
/**
|
|
77
|
+
* Add an output to the PSBT.
|
|
78
|
+
*
|
|
79
|
+
* **PERFORMANCE WARNING:** Passing an `address` string is ~10x slower than passing
|
|
80
|
+
* a `script` directly due to address parsing overhead (bech32 decode, etc.).
|
|
81
|
+
* For high-performance use cases with many outputs, pre-compute the script using
|
|
82
|
+
* `toOutputScript(address, network)` and pass `{ script, value }` instead.
|
|
83
|
+
*
|
|
84
|
+
* @param outputData - Output data with either `address` or `script`, and `value`
|
|
85
|
+
* @param checkPartialSigs - Whether to check for existing signatures (default: true)
|
|
86
|
+
*/
|
|
87
|
+
addOutput(outputData: PsbtOutputExtended, checkPartialSigs?: boolean): this;
|
|
53
88
|
extractTransaction(disableFeeCheck?: boolean, disableOutputChecks?: boolean): Transaction;
|
|
54
89
|
getFeeRate(disableOutputChecks?: boolean): number;
|
|
55
90
|
getFee(disableOutputChecks?: boolean): number;
|
|
56
91
|
finalizeAllInputs(): this;
|
|
57
92
|
finalizeInput(inputIndex: number, finalScriptsFunc?: FinalScriptsFunc | FinalTaprootScriptsFunc, canRunChecks?: boolean): this;
|
|
58
|
-
finalizeTaprootInput(inputIndex: number, tapLeafHashToFinalize?:
|
|
93
|
+
finalizeTaprootInput(inputIndex: number, tapLeafHashToFinalize?: Bytes32, finalScriptsFunc?: FinalTaprootScriptsFunc): this;
|
|
59
94
|
getInputType(inputIndex: number): AllScriptType;
|
|
60
|
-
inputHasPubkey(inputIndex: number, pubkey:
|
|
95
|
+
inputHasPubkey(inputIndex: number, pubkey: PublicKey): boolean;
|
|
61
96
|
inputHasHDKey(inputIndex: number, root: HDSigner): boolean;
|
|
62
|
-
outputHasPubkey(outputIndex: number, pubkey:
|
|
97
|
+
outputHasPubkey(outputIndex: number, pubkey: PublicKey): boolean;
|
|
63
98
|
outputHasHDKey(outputIndex: number, root: HDSigner): boolean;
|
|
64
99
|
validateSignaturesOfAllInputs(validator: ValidateSigFunction): boolean;
|
|
65
|
-
validateSignaturesOfInput(inputIndex: number, validator: ValidateSigFunction, pubkey?:
|
|
100
|
+
validateSignaturesOfInput(inputIndex: number, validator: ValidateSigFunction, pubkey?: PublicKey): boolean;
|
|
66
101
|
signAllInputsHD(hdKeyPair: HDSigner, sighashTypes?: number[]): this;
|
|
67
102
|
signAllInputsHDAsync(hdKeyPair: HDSigner | HDSignerAsync, sighashTypes?: number[]): Promise<void>;
|
|
68
103
|
signInputHD(inputIndex: number, hdKeyPair: HDSigner, sighashTypes?: number[]): this;
|
|
69
104
|
signInputHDAsync(inputIndex: number, hdKeyPair: HDSigner | HDSignerAsync, sighashTypes?: number[]): Promise<void>;
|
|
70
105
|
signAllInputs(keyPair: Signer | SignerAlternative | BIP32Interface | ECPairInterface, sighashTypes?: number[]): this;
|
|
71
106
|
signAllInputsAsync(keyPair: Signer | SignerAlternative | SignerAsync | BIP32Interface | ECPairInterface, sighashTypes?: number[]): Promise<void>;
|
|
72
|
-
signInput(inputIndex: number, keyPair: Signer | SignerAlternative | BIP32Interface | ECPairInterface, sighashTypes?: number[]): this;
|
|
73
|
-
signTaprootInput(inputIndex: number, keyPair: Signer | SignerAlternative | BIP32Interface | ECPairInterface, tapLeafHashToSign?:
|
|
74
|
-
signInputAsync(inputIndex: number, keyPair: Signer | SignerAlternative | SignerAsync | BIP32Interface | ECPairInterface, sighashTypes?: number[]): Promise<void>;
|
|
75
|
-
signTaprootInputAsync(inputIndex: number, keyPair: Signer | SignerAlternative | SignerAsync | BIP32Interface | ECPairInterface, tapLeafHash?:
|
|
76
|
-
toBuffer():
|
|
107
|
+
signInput(inputIndex: number, keyPair: Signer | SignerAlternative | HDSigner | BIP32Interface | ECPairInterface, sighashTypes?: number[]): this;
|
|
108
|
+
signTaprootInput(inputIndex: number, keyPair: Signer | SignerAlternative | HDSigner | BIP32Interface | ECPairInterface, tapLeafHashToSign?: Uint8Array, sighashTypes?: number[]): this;
|
|
109
|
+
signInputAsync(inputIndex: number, keyPair: Signer | SignerAlternative | SignerAsync | HDSigner | HDSignerAsync | BIP32Interface | ECPairInterface, sighashTypes?: number[]): Promise<void>;
|
|
110
|
+
signTaprootInputAsync(inputIndex: number, keyPair: Signer | SignerAlternative | SignerAsync | HDSigner | HDSignerAsync | BIP32Interface | ECPairInterface, tapLeafHash?: Uint8Array, sighashTypes?: number[]): Promise<void>;
|
|
111
|
+
toBuffer(): Uint8Array;
|
|
77
112
|
toHex(): string;
|
|
78
113
|
toBase64(): string;
|
|
79
114
|
updateGlobal(updateData: PsbtGlobalUpdate): this;
|
|
@@ -83,88 +118,17 @@ export declare class Psbt {
|
|
|
83
118
|
addUnknownKeyValToInput(inputIndex: number, keyVal: KeyValue): this;
|
|
84
119
|
addUnknownKeyValToOutput(outputIndex: number, keyVal: KeyValue): this;
|
|
85
120
|
clearFinalizedInput(inputIndex: number): this;
|
|
86
|
-
checkTaprootHashesForSig(inputIndex: number, input: PsbtInput, keyPair: Signer | SignerAlternative | SignerAsync | BIP32Interface | ECPairInterface, tapLeafHashToSign?:
|
|
87
|
-
hash:
|
|
88
|
-
leafHash?:
|
|
121
|
+
checkTaprootHashesForSig(inputIndex: number, input: PsbtInput, keyPair: Signer | SignerAlternative | SignerAsync | HDSigner | HDSignerAsync | TaprootHashCheckSigner | BIP32Interface | ECPairInterface, tapLeafHashToSign?: Uint8Array, allowedSighashTypes?: number[]): {
|
|
122
|
+
hash: Bytes32;
|
|
123
|
+
leafHash?: Bytes32;
|
|
89
124
|
}[];
|
|
90
|
-
private _finalizeInput;
|
|
91
|
-
private _finalizeTaprootInput;
|
|
92
|
-
private _validateSignaturesOfInput;
|
|
93
|
-
private validateSignaturesOfTaprootInput;
|
|
94
|
-
private _signInput;
|
|
95
|
-
private _signTaprootInput;
|
|
96
|
-
private _signInputAsync;
|
|
97
|
-
private _signTaprootInputAsync;
|
|
98
|
-
}
|
|
99
|
-
export interface PsbtOptsOptional {
|
|
100
|
-
network?: Network;
|
|
101
|
-
maximumFeeRate?: number;
|
|
102
|
-
version?: 1 | 2 | 3;
|
|
103
|
-
}
|
|
104
|
-
export interface PsbtOpts {
|
|
105
|
-
network: Network;
|
|
106
|
-
maximumFeeRate: number;
|
|
107
|
-
}
|
|
108
|
-
export interface PsbtInputExtended extends PsbtInput, TransactionInput {
|
|
109
|
-
isPayToAnchor?: boolean;
|
|
110
|
-
}
|
|
111
|
-
export type PsbtOutputExtended = PsbtOutputExtendedAddress | PsbtOutputExtendedScript;
|
|
112
|
-
export interface PsbtOutputExtendedAddress extends PsbtOutput {
|
|
113
|
-
address: string;
|
|
114
|
-
value: number;
|
|
115
125
|
}
|
|
116
|
-
export
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
interface HDSignerBase {
|
|
121
|
-
publicKey: Buffer;
|
|
122
|
-
fingerprint: Buffer;
|
|
123
|
-
}
|
|
124
|
-
export interface HDSigner extends HDSignerBase {
|
|
125
|
-
derivePath(path: string): HDSigner;
|
|
126
|
-
sign(hash: Buffer): Buffer;
|
|
127
|
-
}
|
|
128
|
-
export interface HDSignerAsync extends HDSignerBase {
|
|
129
|
-
derivePath(path: string): HDSignerAsync;
|
|
130
|
-
sign(hash: Buffer): Promise<Buffer>;
|
|
131
|
-
}
|
|
132
|
-
export interface SignerAlternative {
|
|
133
|
-
publicKey: Buffer;
|
|
134
|
-
lowR: boolean;
|
|
135
|
-
sign(hash: Buffer, lowR?: boolean): Buffer;
|
|
136
|
-
verify(hash: Buffer, signature: Buffer): boolean;
|
|
137
|
-
signSchnorr(hash: Buffer): Buffer;
|
|
138
|
-
verifySchnorr(hash: Buffer, signature: Buffer): boolean;
|
|
139
|
-
}
|
|
140
|
-
export interface Signer {
|
|
141
|
-
publicKey: Buffer;
|
|
142
|
-
network?: Network;
|
|
143
|
-
sign(hash: Buffer, lowR?: boolean): Buffer;
|
|
144
|
-
signSchnorr?(hash: Buffer): Buffer;
|
|
145
|
-
getPublicKey?(): Buffer;
|
|
146
|
-
}
|
|
147
|
-
export interface SignerAsync {
|
|
148
|
-
publicKey: Buffer;
|
|
149
|
-
network?: Network;
|
|
150
|
-
sign(hash: Buffer, lowR?: boolean): Promise<Buffer>;
|
|
151
|
-
signSchnorr?(hash: Buffer): Promise<Buffer>;
|
|
152
|
-
getPublicKey?(): Buffer;
|
|
153
|
-
}
|
|
154
|
-
type FinalScriptsFunc = (inputIndex: number, input: PsbtInput, script: Buffer, isSegwit: boolean, isP2SH: boolean, isP2WSH: boolean, canRunChecks: boolean) => {
|
|
155
|
-
finalScriptSig: Buffer | undefined;
|
|
156
|
-
finalScriptWitness: Buffer | undefined;
|
|
157
|
-
};
|
|
158
|
-
type FinalTaprootScriptsFunc = (inputIndex: number, input: PsbtInput, tapLeafHashToFinalize?: Buffer) => {
|
|
159
|
-
finalScriptWitness: Buffer | undefined;
|
|
160
|
-
};
|
|
161
|
-
export declare function getFinalScripts(inputIndex: number, input: PsbtInput, script: Buffer, isSegwit: boolean, isP2SH: boolean, isP2WSH: boolean, canRunChecks?: boolean, solution?: Buffer[]): {
|
|
162
|
-
finalScriptSig: Buffer | undefined;
|
|
163
|
-
finalScriptWitness: Buffer | undefined;
|
|
126
|
+
export declare function getFinalScripts(inputIndex: number, input: PsbtInput, script: Script, isSegwit: boolean, isP2SH: boolean, isP2WSH: boolean, canRunChecks?: boolean, solution?: Uint8Array[]): {
|
|
127
|
+
finalScriptSig: Script | undefined;
|
|
128
|
+
finalScriptWitness: Uint8Array | undefined;
|
|
164
129
|
};
|
|
165
|
-
export declare function prepareFinalScripts(script:
|
|
166
|
-
finalScriptSig:
|
|
167
|
-
finalScriptWitness:
|
|
130
|
+
export declare function prepareFinalScripts(script: Uint8Array, scriptType: string, partialSig: PartialSig[], isSegwit: boolean, isP2SH: boolean, isP2WSH: boolean, solution?: Uint8Array[]): {
|
|
131
|
+
finalScriptSig: Script | undefined;
|
|
132
|
+
finalScriptWitness: Uint8Array | undefined;
|
|
168
133
|
};
|
|
169
|
-
|
|
170
|
-
export {};
|
|
134
|
+
//# sourceMappingURL=psbt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"psbt.d.ts","sourceRoot":"","sources":["../src/psbt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAER,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,SAAS,EACT,eAAe,EAEf,gBAAgB,EAKnB,MAAM,QAAQ,CAAC;AAIhB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAA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E,OAAO,EAChB,QAAQ,CAAC,EAAE,UAAU,EAAE,GACxB;IACC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,kBAAkB,EAAE,UAAU,GAAG,SAAS,CAAC;CAC9C,CAsCA"}
|
package/browser/pubkey.d.ts
CHANGED
|
@@ -1,8 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
import { PublicKey, XOnlyPublicKey } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Converts a public key to x-only format (32 bytes).
|
|
4
|
+
* @param pubKey - The public key buffer (33 or 65 bytes)
|
|
5
|
+
* @returns The x-only public key (32 bytes)
|
|
6
|
+
*/
|
|
7
|
+
export declare const toXOnly: (pubKey: PublicKey | XOnlyPublicKey) => XOnlyPublicKey;
|
|
2
8
|
export interface UncompressedPublicKey {
|
|
3
|
-
hybrid:
|
|
4
|
-
uncompressed:
|
|
9
|
+
hybrid: Uint8Array;
|
|
10
|
+
uncompressed: Uint8Array;
|
|
5
11
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Converts bigint to 32-byte Uint8Array.
|
|
14
|
+
*/
|
|
15
|
+
export declare function bigIntTo32Bytes(num: bigint): Uint8Array;
|
|
16
|
+
/**
|
|
17
|
+
* Converts an existing real Bitcoin public key (compressed or uncompressed)
|
|
18
|
+
* to its "hybrid" form (prefix 0x06/0x07), then derives a P2PKH address from it.
|
|
19
|
+
*
|
|
20
|
+
* @param realPubKey - 33-byte compressed (0x02/0x03) or 65-byte uncompressed (0x04) pubkey
|
|
21
|
+
* @returns UncompressedPublicKey | undefined
|
|
22
|
+
*/
|
|
23
|
+
export declare function decompressPublicKey(realPubKey: PublicKey): UncompressedPublicKey | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Compare two potential pubkey Uint8Arrays, treating hybrid keys (0x06/0x07)
|
|
26
|
+
* as equivalent to uncompressed (0x04).
|
|
27
|
+
*/
|
|
28
|
+
export declare function pubkeysMatch(a: Uint8Array, b: Uint8Array): boolean;
|
|
29
|
+
//# sourceMappingURL=pubkey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pubkey.d.ts","sourceRoot":"","sources":["../src/pubkey.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5D;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,QAAQ,SAAS,GAAG,cAAc,KAAG,cAE5D,CAAC;AAEF,MAAM,WAAW,qBAAqB;IAClC,MAAM,EAAE,UAAU,CAAC;IACnB,YAAY,EAAE,UAAU,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAOvD;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,SAAS,GAAG,qBAAqB,GAAG,SAAS,CAoC5F;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,OAAO,CAclE"}
|
package/browser/push_data.d.ts
CHANGED
|
@@ -1,7 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the encoding length of a number used for push data in Bitcoin transactions.
|
|
3
|
+
* @param i The number to calculate the encoding length for.
|
|
4
|
+
* @returns The encoding length of the number.
|
|
5
|
+
*/
|
|
1
6
|
export declare function encodingLength(i: number): number;
|
|
2
|
-
|
|
3
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Encodes a number into a buffer using a variable-length encoding scheme.
|
|
9
|
+
* The encoded buffer is written starting at the specified offset.
|
|
10
|
+
* Returns the size of the encoded buffer.
|
|
11
|
+
*
|
|
12
|
+
* @param buffer - The buffer to write the encoded data into.
|
|
13
|
+
* @param num - The number to encode.
|
|
14
|
+
* @param offset - The offset at which to start writing the encoded buffer.
|
|
15
|
+
* @returns The size of the encoded buffer.
|
|
16
|
+
*/
|
|
17
|
+
export declare function encode(buffer: Uint8Array, num: number, offset: number): number;
|
|
18
|
+
/**
|
|
19
|
+
* Decodes a buffer and returns information about the opcode, number, and size.
|
|
20
|
+
* @param buffer - The buffer to decode.
|
|
21
|
+
* @param offset - The offset within the buffer to start decoding.
|
|
22
|
+
* @returns An object containing the opcode, number, and size, or null if decoding fails.
|
|
23
|
+
*/
|
|
24
|
+
export declare function decode(buffer: Uint8Array, offset: number): {
|
|
4
25
|
opcode: number;
|
|
5
26
|
number: number;
|
|
6
27
|
size: number;
|
|
7
28
|
} | null;
|
|
29
|
+
//# sourceMappingURL=push_data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"push_data.d.ts","sourceRoot":"","sources":["../src/push_data.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;;;;;;;GASG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAyB9E;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAClB,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,GACf;IACC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CAChB,GAAG,IAAI,CAqCP"}
|
package/browser/script.d.ts
CHANGED
|
@@ -1,16 +1,41 @@
|
|
|
1
1
|
import { opcodes } from './opcodes.js';
|
|
2
|
-
import { Stack } from './types.js';
|
|
2
|
+
import { Script, Stack } from './types.js';
|
|
3
3
|
import * as scriptNumber from './script_number.js';
|
|
4
4
|
import * as scriptSignature from './script_signature.js';
|
|
5
5
|
export { opcodes };
|
|
6
6
|
export declare function isPushOnly(value: Stack): boolean;
|
|
7
7
|
export declare function countNonPushOnlyOPs(value: Stack): number;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Compiles an array of chunks into a Uint8Array.
|
|
10
|
+
*
|
|
11
|
+
* @param chunks - The array of chunks to compile.
|
|
12
|
+
* @returns The compiled Uint8Array.
|
|
13
|
+
* @throws Error if the compilation fails.
|
|
14
|
+
*/
|
|
15
|
+
export declare function compile(chunks: Uint8Array | Stack): Script;
|
|
16
|
+
export declare function decompile(buffer: Uint8Array | Stack): Array<number | Uint8Array> | null;
|
|
17
|
+
/**
|
|
18
|
+
* Converts the given chunks into an ASM (Assembly) string representation.
|
|
19
|
+
* If the chunks parameter is a Uint8Array, it will be decompiled into a Stack before conversion.
|
|
20
|
+
* @param chunks - The chunks to convert into ASM.
|
|
21
|
+
* @returns The ASM string representation of the chunks.
|
|
22
|
+
*/
|
|
23
|
+
export declare function toASM(chunks: Uint8Array | Stack): string;
|
|
24
|
+
/**
|
|
25
|
+
* Converts an ASM string to a Uint8Array.
|
|
26
|
+
* @param asm The ASM string to convert.
|
|
27
|
+
* @returns The converted Uint8Array.
|
|
28
|
+
*/
|
|
29
|
+
export declare function fromASM(asm: string): Script;
|
|
30
|
+
/**
|
|
31
|
+
* Converts the given chunks into a stack of Uint8Arrays.
|
|
32
|
+
*
|
|
33
|
+
* @param chunks - The chunks to convert.
|
|
34
|
+
* @returns The stack of Uint8Arrays.
|
|
35
|
+
*/
|
|
36
|
+
export declare function toStack(chunks: Uint8Array | Stack): Uint8Array[];
|
|
37
|
+
export declare function isCanonicalPubKey(buffer: Uint8Array): boolean;
|
|
38
|
+
export declare function isCanonicalScriptSignature(buffer: Uint8Array): boolean;
|
|
15
39
|
export declare const number: typeof scriptNumber;
|
|
16
40
|
export declare const signature: typeof scriptSignature;
|
|
41
|
+
//# sourceMappingURL=script.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"script.d.ts","sourceRoot":"","sources":["../src/script.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAe,MAAM,cAAc,CAAC;AAEpD,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,eAAe,MAAM,uBAAuB,CAAC;AAEzD,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAIhD,OAAO,EAAE,OAAO,EAAE,CAAC;AAgBnB,wBAAgB,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAEhD;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAExD;AAsBD;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,UAAU,GAAG,KAAK,GAAG,MAAM,CAkD1D;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,KAAK,GAAG,KAAK,CAAC,MAAM,GAAG,UAAU,CAAC,GAAG,IAAI,CA6CvF;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,MAAM,EAAE,UAAU,GAAG,KAAK,GAAG,MAAM,CAwBxD;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAmB3C;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,UAAU,GAAG,KAAK,GAAG,UAAU,EAAE,CAYhE;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAE7D;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAKtE;AAED,eAAO,MAAM,MAAM,qBAAe,CAAC;AACnC,eAAO,MAAM,SAAS,wBAAkB,CAAC"}
|
|
@@ -1,2 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decodes a script number from a buffer.
|
|
3
|
+
*
|
|
4
|
+
* @param buffer - The buffer containing the script number.
|
|
5
|
+
* @param maxLength - The maximum length of the script number. Defaults to 4.
|
|
6
|
+
* @param minimal - Whether the script number should be minimal. Defaults to true.
|
|
7
|
+
* @returns The decoded script number.
|
|
8
|
+
* @throws {TypeError} If the script number overflows the maximum length.
|
|
9
|
+
* @throws {Error} If the script number is not minimally encoded when minimal is true.
|
|
10
|
+
*/
|
|
1
11
|
export declare function decode(buffer: Buffer, maxLength?: number, minimal?: boolean): number;
|
|
12
|
+
/**
|
|
13
|
+
* Encodes a number into a Buffer using a specific format.
|
|
14
|
+
*
|
|
15
|
+
* @param _number - The number to encode.
|
|
16
|
+
* @returns The encoded number as a Buffer.
|
|
17
|
+
*/
|
|
2
18
|
export declare function encode(_number: number): Buffer;
|
|
19
|
+
//# sourceMappingURL=script_number.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"script_number.d.ts","sourceRoot":"","sources":["../src/script_number.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CA+BpF;AAMD;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAkB9C"}
|
|
@@ -1,8 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a hash type is defined (valid for Bitcoin signatures).
|
|
3
|
+
* @param hashType - The hash type to check.
|
|
4
|
+
* @returns True if the hash type is valid, false otherwise.
|
|
5
|
+
*/
|
|
1
6
|
export declare function isDefinedHashType(hashType: number): boolean;
|
|
2
|
-
interface ScriptSignature {
|
|
3
|
-
signature:
|
|
7
|
+
export interface ScriptSignature {
|
|
8
|
+
signature: Uint8Array;
|
|
4
9
|
hashType: number;
|
|
5
10
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Decodes a Uint8Array into a ScriptSignature object.
|
|
13
|
+
* @param buffer - The Uint8Array to decode.
|
|
14
|
+
* @returns The decoded ScriptSignature object.
|
|
15
|
+
* @throws Error if the hashType is invalid.
|
|
16
|
+
*/
|
|
17
|
+
export declare function decode(buffer: Uint8Array): ScriptSignature;
|
|
18
|
+
/**
|
|
19
|
+
* Encodes a signature and hash type into a Uint8Array.
|
|
20
|
+
* @param signature - The signature to encode.
|
|
21
|
+
* @param hashType - The hash type to encode.
|
|
22
|
+
* @returns The encoded Uint8Array.
|
|
23
|
+
* @throws Error if the hashType is invalid.
|
|
24
|
+
*/
|
|
25
|
+
export declare function encode(signature: Uint8Array, hashType: number): Uint8Array;
|
|
26
|
+
//# sourceMappingURL=script_signature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"script_signature.d.ts","sourceRoot":"","sources":["../src/script_signature.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAG3D;AA+BD,MAAM,WAAW,eAAe;IAC5B,SAAS,EAAE,UAAU,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CACpB;AAGD;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,eAAe,CAY1D;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,CAkB1E"}
|