@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
|
@@ -1,21 +1,61 @@
|
|
|
1
|
-
import { PartialSig, PsbtInput } from 'bip174
|
|
2
|
-
export declare const isP2MS: (script:
|
|
3
|
-
export declare const isP2PK: (script:
|
|
4
|
-
export declare const isP2PKH: (script:
|
|
5
|
-
export declare const isP2WPKH: (script:
|
|
6
|
-
export declare const isP2WSHScript: (script:
|
|
7
|
-
export declare const isP2SHScript: (script:
|
|
8
|
-
export declare const isP2TR: (script:
|
|
9
|
-
export declare const isP2OP: (script:
|
|
10
|
-
export declare const isP2A: (script:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import type { PartialSig, PsbtInput } from 'bip174';
|
|
2
|
+
export declare const isP2MS: (script: Uint8Array) => boolean;
|
|
3
|
+
export declare const isP2PK: (script: Uint8Array) => boolean;
|
|
4
|
+
export declare const isP2PKH: (script: Uint8Array) => boolean;
|
|
5
|
+
export declare const isP2WPKH: (script: Uint8Array) => boolean;
|
|
6
|
+
export declare const isP2WSHScript: (script: Uint8Array) => boolean;
|
|
7
|
+
export declare const isP2SHScript: (script: Uint8Array) => boolean;
|
|
8
|
+
export declare const isP2TR: (script: Uint8Array) => boolean;
|
|
9
|
+
export declare const isP2OP: (script: Uint8Array) => boolean;
|
|
10
|
+
export declare const isP2A: (script: Uint8Array) => boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Converts a witness stack to a script witness.
|
|
13
|
+
* @param witness The witness stack to convert.
|
|
14
|
+
* @returns The script witness as a Uint8Array.
|
|
15
|
+
*/
|
|
16
|
+
export declare function witnessStackToScriptWitness(witness: Uint8Array[]): Uint8Array;
|
|
17
|
+
/**
|
|
18
|
+
* Finds the position of a public key in a script.
|
|
19
|
+
* @param pubkey The public key to search for.
|
|
20
|
+
* @param script The script to search in.
|
|
21
|
+
* @returns The index of the public key in the script, or -1 if not found.
|
|
22
|
+
* @throws {Error} If there is an unknown script error.
|
|
23
|
+
*/
|
|
24
|
+
export declare function pubkeyPositionInScript(pubkey: Uint8Array, script: Uint8Array): number;
|
|
25
|
+
/**
|
|
26
|
+
* Checks if a public key is present in a script.
|
|
27
|
+
* @param pubkey The public key to check.
|
|
28
|
+
* @param script The script to search in.
|
|
29
|
+
* @returns A boolean indicating whether the public key is present in the script.
|
|
30
|
+
*/
|
|
31
|
+
export declare function pubkeyInScript(pubkey: Uint8Array, script: Uint8Array): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Checks if an input contains a signature for a specific action.
|
|
34
|
+
* @param input - The input to check.
|
|
35
|
+
* @param action - The action to check for.
|
|
36
|
+
* @returns A boolean indicating whether the input contains a signature for the specified action.
|
|
37
|
+
*/
|
|
14
38
|
export declare function checkInputForSig(input: PsbtInput, action: string): boolean;
|
|
15
|
-
type SignatureDecodeFunc = (buffer:
|
|
16
|
-
signature:
|
|
39
|
+
type SignatureDecodeFunc = (buffer: Uint8Array) => {
|
|
40
|
+
signature: Uint8Array;
|
|
17
41
|
hashType: number;
|
|
18
42
|
};
|
|
19
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Determines if a given action is allowed for a signature block.
|
|
45
|
+
* @param signature - The signature block.
|
|
46
|
+
* @param signatureDecodeFn - The function used to decode the signature.
|
|
47
|
+
* @param action - The action to be checked.
|
|
48
|
+
* @returns True if the action is allowed, false otherwise.
|
|
49
|
+
*/
|
|
50
|
+
export declare function signatureBlocksAction(signature: Uint8Array, signatureDecodeFn: SignatureDecodeFunc, action: string): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Retrieves the partial signatures (Psigs) from the input's final scripts.
|
|
53
|
+
* Psigs are extracted from both the final scriptSig and final scriptWitness of the input.
|
|
54
|
+
* Only canonical script signatures are considered.
|
|
55
|
+
*
|
|
56
|
+
* @param input - The PsbtInput object representing the input.
|
|
57
|
+
* @returns An array of PartialSig objects containing the extracted Psigs.
|
|
58
|
+
*/
|
|
20
59
|
export declare function getPsigsFromInputFinalScripts(input: PsbtInput): PartialSig[];
|
|
21
60
|
export {};
|
|
61
|
+
//# sourceMappingURL=psbtutils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"psbtutils.d.ts","sourceRoot":"","sources":["../../src/psbt/psbtutils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AA6BpD,eAAO,MAAM,MAAM,WAX2C,UAAU,KAAK,OAWjC,CAAC;AAC7C,eAAO,MAAM,MAAM,WAZ2C,UAAU,KAAK,OAYjC,CAAC;AAC7C,eAAO,MAAM,OAAO,WAb0C,UAAU,KAAK,OAa/B,CAAC;AAC/C,eAAO,MAAM,QAAQ,WAdyC,UAAU,KAAK,OAc7B,CAAC;AACjD,eAAO,MAAM,aAAa,WAfoC,UAAU,KAAK,OAezB,CAAC;AACrD,eAAO,MAAM,YAAY,WAhBqC,UAAU,KAAK,OAgB3B,CAAC;AACnD,eAAO,MAAM,MAAM,WAjB2C,UAAU,KAAK,OAiBjC,CAAC;AAC7C,eAAO,MAAM,MAAM,WAlB2C,UAAU,KAAK,OAkBjC,CAAC;AAC7C,eAAO,MAAM,KAAK,GAAI,QAAQ,UAAU,KAAG,OAQ1C,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,UAAU,CA2B7E;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,GAAG,MAAM,CA0CrF;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAE9E;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAG1E;AAED,KAAK,mBAAmB,GAAG,CAAC,MAAM,EAAE,UAAU,KAAK;IAC/C,SAAS,EAAE,UAAU,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACjC,SAAS,EAAE,UAAU,EACrB,iBAAiB,EAAE,mBAAmB,EACtC,MAAM,EAAE,MAAM,GACf,OAAO,CAgBT;AAwBD;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,SAAS,GAAG,UAAU,EAAE,CAa5E"}
|
package/build/psbt/psbtutils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { varuint, concat, alloc, equals } from '../io/index.js';
|
|
2
2
|
import { hash160 } from '../crypto.js';
|
|
3
3
|
import { p2ms } from '../payments/p2ms.js';
|
|
4
4
|
import { p2pk } from '../payments/p2pk.js';
|
|
@@ -32,21 +32,26 @@ export const isP2TR = isPaymentFactory(p2tr);
|
|
|
32
32
|
export const isP2OP = isPaymentFactory(p2op);
|
|
33
33
|
export const isP2A = (script) => {
|
|
34
34
|
return (script.length === 4 &&
|
|
35
|
-
script[0] === 0x51 &&
|
|
36
|
-
script[1] === 0x02 &&
|
|
35
|
+
script[0] === 0x51 && // OP_1
|
|
36
|
+
script[1] === 0x02 && // push 2 bytes
|
|
37
37
|
script[2] === 0x4e &&
|
|
38
38
|
script[3] === 0x73);
|
|
39
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* Converts a witness stack to a script witness.
|
|
42
|
+
* @param witness The witness stack to convert.
|
|
43
|
+
* @returns The script witness as a Uint8Array.
|
|
44
|
+
*/
|
|
40
45
|
export function witnessStackToScriptWitness(witness) {
|
|
41
|
-
|
|
46
|
+
const chunks = [];
|
|
42
47
|
function writeSlice(slice) {
|
|
43
|
-
|
|
48
|
+
chunks.push(slice);
|
|
44
49
|
}
|
|
45
50
|
function writeVarInt(i) {
|
|
46
|
-
const currentLen = buffer.length;
|
|
47
51
|
const varintLen = varuint.encodingLength(i);
|
|
48
|
-
|
|
49
|
-
varuint.encode(i,
|
|
52
|
+
const buf = alloc(varintLen);
|
|
53
|
+
varuint.encode(i, buf, 0);
|
|
54
|
+
chunks.push(buf);
|
|
50
55
|
}
|
|
51
56
|
function writeVarSlice(slice) {
|
|
52
57
|
writeVarInt(slice.length);
|
|
@@ -57,13 +62,22 @@ export function witnessStackToScriptWitness(witness) {
|
|
|
57
62
|
vector.forEach(writeVarSlice);
|
|
58
63
|
}
|
|
59
64
|
writeVector(witness);
|
|
60
|
-
return
|
|
65
|
+
return concat(chunks);
|
|
61
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Finds the position of a public key in a script.
|
|
69
|
+
* @param pubkey The public key to search for.
|
|
70
|
+
* @param script The script to search in.
|
|
71
|
+
* @returns The index of the public key in the script, or -1 if not found.
|
|
72
|
+
* @throws {Error} If there is an unknown script error.
|
|
73
|
+
*/
|
|
62
74
|
export function pubkeyPositionInScript(pubkey, script) {
|
|
63
75
|
const decompiled = bscript.decompile(script);
|
|
64
76
|
if (decompiled === null)
|
|
65
77
|
throw new Error('Unknown script error');
|
|
78
|
+
// For P2PKH or P2PK
|
|
66
79
|
const pubkeyHash = hash160(pubkey);
|
|
80
|
+
// For Taproot or some cases, we might also check the x-only
|
|
67
81
|
const pubkeyXOnly = toXOnly(pubkey);
|
|
68
82
|
const uncompressed = decompressPublicKey(pubkey);
|
|
69
83
|
const pubkeyHybridHash = uncompressed?.hybrid ? hash160(uncompressed.hybrid) : undefined;
|
|
@@ -77,7 +91,7 @@ export function pubkeyPositionInScript(pubkey, script) {
|
|
|
77
91
|
return true;
|
|
78
92
|
if (pubkeysMatch(element, pubkeyXOnly))
|
|
79
93
|
return true;
|
|
80
|
-
if (
|
|
94
|
+
if (equals(element, pubkeyHash)) {
|
|
81
95
|
return true;
|
|
82
96
|
}
|
|
83
97
|
if (uncompressed) {
|
|
@@ -85,20 +99,40 @@ export function pubkeyPositionInScript(pubkey, script) {
|
|
|
85
99
|
return true;
|
|
86
100
|
if (pubkeysMatch(element, uncompressed.hybrid))
|
|
87
101
|
return true;
|
|
88
|
-
if ((pubkeyHybridHash &&
|
|
89
|
-
(pubkeyUncompressedHash &&
|
|
102
|
+
if ((pubkeyHybridHash && equals(element, pubkeyHybridHash)) ||
|
|
103
|
+
(pubkeyUncompressedHash && equals(element, pubkeyUncompressedHash))) {
|
|
90
104
|
return true;
|
|
91
105
|
}
|
|
92
106
|
}
|
|
107
|
+
return false;
|
|
93
108
|
});
|
|
94
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Checks if a public key is present in a script.
|
|
112
|
+
* @param pubkey The public key to check.
|
|
113
|
+
* @param script The script to search in.
|
|
114
|
+
* @returns A boolean indicating whether the public key is present in the script.
|
|
115
|
+
*/
|
|
95
116
|
export function pubkeyInScript(pubkey, script) {
|
|
96
117
|
return pubkeyPositionInScript(pubkey, script) !== -1;
|
|
97
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Checks if an input contains a signature for a specific action.
|
|
121
|
+
* @param input - The input to check.
|
|
122
|
+
* @param action - The action to check for.
|
|
123
|
+
* @returns A boolean indicating whether the input contains a signature for the specified action.
|
|
124
|
+
*/
|
|
98
125
|
export function checkInputForSig(input, action) {
|
|
99
126
|
const pSigs = extractPartialSigs(input);
|
|
100
127
|
return pSigs.some((pSig) => signatureBlocksAction(pSig, bscript.signature.decode, action));
|
|
101
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Determines if a given action is allowed for a signature block.
|
|
131
|
+
* @param signature - The signature block.
|
|
132
|
+
* @param signatureDecodeFn - The function used to decode the signature.
|
|
133
|
+
* @param action - The action to be checked.
|
|
134
|
+
* @returns True if the action is allowed, false otherwise.
|
|
135
|
+
*/
|
|
102
136
|
export function signatureBlocksAction(signature, signatureDecodeFn, action) {
|
|
103
137
|
const { hashType } = signatureDecodeFn(signature);
|
|
104
138
|
const whitelist = [];
|
|
@@ -117,6 +151,16 @@ export function signatureBlocksAction(signature, signatureDecodeFn, action) {
|
|
|
117
151
|
}
|
|
118
152
|
return whitelist.indexOf(action) === -1;
|
|
119
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Extracts the signatures from a PsbtInput object.
|
|
156
|
+
* If the input has partial signatures, it returns an array of the signatures.
|
|
157
|
+
* If the input does not have partial signatures, it checks if it has a finalScriptSig or finalScriptWitness.
|
|
158
|
+
* If it does, it extracts the signatures from the final scripts and returns them.
|
|
159
|
+
* If none of the above conditions are met, it returns an empty array.
|
|
160
|
+
*
|
|
161
|
+
* @param input - The PsbtInput object from which to extract the signatures.
|
|
162
|
+
* @returns An array of signatures extracted from the PsbtInput object.
|
|
163
|
+
*/
|
|
120
164
|
function extractPartialSigs(input) {
|
|
121
165
|
const { partialSig } = input;
|
|
122
166
|
let pSigs;
|
|
@@ -128,17 +172,28 @@ function extractPartialSigs(input) {
|
|
|
128
172
|
else {
|
|
129
173
|
pSigs = partialSig;
|
|
130
174
|
}
|
|
131
|
-
return pSigs.map((p) => p.signature);
|
|
175
|
+
return pSigs.map((p) => new Uint8Array(p.signature));
|
|
132
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* Retrieves the partial signatures (Psigs) from the input's final scripts.
|
|
179
|
+
* Psigs are extracted from both the final scriptSig and final scriptWitness of the input.
|
|
180
|
+
* Only canonical script signatures are considered.
|
|
181
|
+
*
|
|
182
|
+
* @param input - The PsbtInput object representing the input.
|
|
183
|
+
* @returns An array of PartialSig objects containing the extracted Psigs.
|
|
184
|
+
*/
|
|
133
185
|
export function getPsigsFromInputFinalScripts(input) {
|
|
134
|
-
const scriptItems = !input.finalScriptSig
|
|
186
|
+
const scriptItems = !input.finalScriptSig
|
|
187
|
+
? []
|
|
188
|
+
: bscript.decompile(new Uint8Array(input.finalScriptSig)) || [];
|
|
135
189
|
const witnessItems = !input.finalScriptWitness
|
|
136
190
|
? []
|
|
137
|
-
: bscript.decompile(input.finalScriptWitness) || [];
|
|
191
|
+
: bscript.decompile(new Uint8Array(input.finalScriptWitness)) || [];
|
|
138
192
|
return scriptItems
|
|
139
193
|
.concat(witnessItems)
|
|
140
194
|
.filter((item) => {
|
|
141
|
-
return
|
|
195
|
+
return item instanceof Uint8Array && bscript.isCanonicalScriptSignature(item);
|
|
142
196
|
})
|
|
143
197
|
.map((sig) => ({ signature: sig }));
|
|
144
198
|
}
|
|
199
|
+
//# sourceMappingURL=psbtutils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"psbtutils.js","sourceRoot":"","sources":["../../src/psbt/psbtutils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,IAAI,EAA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AAC;IACxE,OAAO,WAAW;SACb,MAAM,CAAC,YAAY,CAAC;SACpB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;QACb,OAAO,IAAI,YAAY,UAAU,IAAI,OAAO,CAAC,0BAA0B,CAAC,IAAI,CAAC,CAAC;IAClF,CAAC,CAAC;SACD,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,GAAiB,EAAE,CAAC,CAAiB,CAAC;AAC1E,CAAC"}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PSBT types and interfaces
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
5
|
+
import type { Psbt as PsbtBase, PsbtGlobal, PsbtInput, PsbtOutput } from 'bip174';
|
|
6
|
+
import type { Network } from '../networks.js';
|
|
7
|
+
import type { Transaction, TaprootHashCache } from '../transaction.js';
|
|
8
|
+
import type { Bytes32, PublicKey, Satoshi, Script, Signature, SchnorrSignature } from '../types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Transaction input interface for PSBT.
|
|
11
|
+
*/
|
|
12
|
+
export interface TransactionInput {
|
|
13
|
+
readonly hash: string | Bytes32;
|
|
14
|
+
readonly index: number;
|
|
15
|
+
readonly sequence?: number | undefined;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* PSBT transaction input with Uint8Array hash.
|
|
19
|
+
*/
|
|
20
|
+
export interface PsbtTxInput extends TransactionInput {
|
|
21
|
+
readonly hash: Bytes32;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Transaction output interface for PSBT.
|
|
25
|
+
*/
|
|
26
|
+
export interface TransactionOutput {
|
|
27
|
+
readonly script: Script;
|
|
28
|
+
readonly value: Satoshi;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* PSBT transaction output with optional address.
|
|
32
|
+
*/
|
|
33
|
+
export interface PsbtTxOutput extends TransactionOutput {
|
|
34
|
+
readonly address: string | undefined;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Signature validation function type.
|
|
38
|
+
* msghash is 32 byte hash of preimage, signature is 64 byte compact signature (r,s 32 bytes each)
|
|
39
|
+
*/
|
|
40
|
+
export type ValidateSigFunction = (pubkey: PublicKey, msghash: Bytes32, signature: Uint8Array) => boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Extended PsbtBase interface with typed inputs and globalMap.
|
|
43
|
+
*/
|
|
44
|
+
export interface PsbtBaseExtended extends Omit<PsbtBase, 'inputs'> {
|
|
45
|
+
readonly inputs: PsbtInput[];
|
|
46
|
+
readonly globalMap: PsbtGlobal;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Optional PSBT options.
|
|
50
|
+
*/
|
|
51
|
+
export interface PsbtOptsOptional {
|
|
52
|
+
readonly network?: Network | undefined;
|
|
53
|
+
readonly maximumFeeRate?: number | undefined;
|
|
54
|
+
readonly version?: 1 | 2 | 3 | undefined;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Required PSBT options.
|
|
58
|
+
*/
|
|
59
|
+
export interface PsbtOpts {
|
|
60
|
+
readonly network: Network;
|
|
61
|
+
maximumFeeRate: number;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Extended PSBT input with additional fields.
|
|
65
|
+
*/
|
|
66
|
+
export interface PsbtInputExtended extends PsbtInput, TransactionInput {
|
|
67
|
+
readonly isPayToAnchor?: boolean | undefined;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Extended PSBT output - either address-based or script-based.
|
|
71
|
+
*/
|
|
72
|
+
export type PsbtOutputExtended = PsbtOutputExtendedAddress | PsbtOutputExtendedScript;
|
|
73
|
+
/**
|
|
74
|
+
* PSBT output with address.
|
|
75
|
+
*/
|
|
76
|
+
export interface PsbtOutputExtendedAddress extends PsbtOutput {
|
|
77
|
+
readonly address: string;
|
|
78
|
+
readonly value: Satoshi;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* PSBT output with script.
|
|
82
|
+
*/
|
|
83
|
+
export interface PsbtOutputExtendedScript extends PsbtOutput {
|
|
84
|
+
readonly script: Script;
|
|
85
|
+
readonly value: Satoshi;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Base interface for HD signers.
|
|
89
|
+
*/
|
|
90
|
+
interface HDSignerBase {
|
|
91
|
+
/**
|
|
92
|
+
* DER format compressed publicKey Uint8Array
|
|
93
|
+
*/
|
|
94
|
+
readonly publicKey: PublicKey;
|
|
95
|
+
/**
|
|
96
|
+
* The first 4 bytes of the sha256-ripemd160 of the publicKey
|
|
97
|
+
*/
|
|
98
|
+
readonly fingerprint: Uint8Array;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* HD signer interface for synchronous signing.
|
|
102
|
+
*/
|
|
103
|
+
export interface HDSigner extends HDSignerBase {
|
|
104
|
+
/**
|
|
105
|
+
* The path string must match /^m(\/\d+'?)+$/
|
|
106
|
+
* ex. m/44'/0'/0'/1/23 levels with ' must be hard derivations
|
|
107
|
+
*/
|
|
108
|
+
derivePath(path: string): HDSigner;
|
|
109
|
+
/**
|
|
110
|
+
* Input hash (the "message digest") for the signature algorithm
|
|
111
|
+
* Return a 64 byte signature (32 byte r and 32 byte s in that order)
|
|
112
|
+
*/
|
|
113
|
+
sign(hash: Bytes32): Uint8Array;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* HD signer interface for asynchronous signing.
|
|
117
|
+
*/
|
|
118
|
+
export interface HDSignerAsync extends HDSignerBase {
|
|
119
|
+
derivePath(path: string): HDSignerAsync;
|
|
120
|
+
sign(hash: Bytes32): Promise<Uint8Array>;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Alternative signer interface with lowR support.
|
|
124
|
+
*/
|
|
125
|
+
export interface SignerAlternative {
|
|
126
|
+
readonly publicKey: PublicKey;
|
|
127
|
+
readonly lowR: boolean;
|
|
128
|
+
sign(hash: Bytes32, lowR?: boolean): Signature;
|
|
129
|
+
verify(hash: Bytes32, signature: Signature): boolean;
|
|
130
|
+
signSchnorr(hash: Bytes32): SchnorrSignature;
|
|
131
|
+
verifySchnorr(hash: Bytes32, signature: SchnorrSignature): boolean;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Basic signer interface for synchronous signing.
|
|
135
|
+
*/
|
|
136
|
+
export interface Signer {
|
|
137
|
+
readonly publicKey: PublicKey;
|
|
138
|
+
readonly network?: Network | undefined;
|
|
139
|
+
sign(hash: Bytes32, lowR?: boolean): Signature;
|
|
140
|
+
signSchnorr?(hash: Bytes32): SchnorrSignature;
|
|
141
|
+
getPublicKey?(): PublicKey;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Basic signer interface for asynchronous signing.
|
|
145
|
+
*/
|
|
146
|
+
export interface SignerAsync {
|
|
147
|
+
readonly publicKey: PublicKey;
|
|
148
|
+
readonly network?: Network | undefined;
|
|
149
|
+
sign(hash: Bytes32, lowR?: boolean): Promise<Signature>;
|
|
150
|
+
signSchnorr?(hash: Bytes32): Promise<SchnorrSignature>;
|
|
151
|
+
getPublicKey?(): PublicKey;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Minimal key pair interface for checking Taproot hashes.
|
|
155
|
+
* Only requires publicKey and optional signSchnorr presence check.
|
|
156
|
+
* Used by checkTaprootHashesForSig to accept broader key pair types (e.g., worker key pairs).
|
|
157
|
+
*/
|
|
158
|
+
export interface TaprootHashCheckSigner {
|
|
159
|
+
readonly publicKey: Uint8Array;
|
|
160
|
+
signSchnorr?(hash: Uint8Array): Uint8Array | Promise<Uint8Array>;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Internal PSBT cache for computed values.
|
|
164
|
+
*/
|
|
165
|
+
export interface PsbtCache {
|
|
166
|
+
nonWitnessUtxoTxCache: Transaction[];
|
|
167
|
+
nonWitnessUtxoBufCache: Uint8Array[];
|
|
168
|
+
txInCache: TxInCacheMap;
|
|
169
|
+
tx: Transaction;
|
|
170
|
+
feeRate?: number | undefined;
|
|
171
|
+
fee?: number | undefined;
|
|
172
|
+
extractedTx?: Transaction | undefined;
|
|
173
|
+
unsafeSignNonSegwit: boolean;
|
|
174
|
+
/** Cached flag: true if any input has signatures (avoids O(n) check) */
|
|
175
|
+
hasSignatures: boolean;
|
|
176
|
+
/** Cached prevOuts for Taproot signing (computed once) */
|
|
177
|
+
prevOuts?: readonly PrevOut[] | undefined;
|
|
178
|
+
/** Cached signing scripts */
|
|
179
|
+
signingScripts?: readonly Script[] | undefined;
|
|
180
|
+
/** Cached values */
|
|
181
|
+
values?: readonly Satoshi[] | undefined;
|
|
182
|
+
/** Cached intermediate hashes for Taproot sighash (computed once per PSBT) */
|
|
183
|
+
taprootHashCache?: TaprootHashCache | undefined;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Keys for cached numeric values in the transaction cache.
|
|
187
|
+
*/
|
|
188
|
+
export type TxCacheNumberKey = 'feeRate' | 'fee';
|
|
189
|
+
/**
|
|
190
|
+
* Script types for classification.
|
|
191
|
+
*/
|
|
192
|
+
export type ScriptType = 'witnesspubkeyhash' | 'pubkeyhash' | 'multisig' | 'pubkey' | 'nonstandard';
|
|
193
|
+
/**
|
|
194
|
+
* All possible script types including witness types.
|
|
195
|
+
* Note: P2WPKH can't be wrapped in P2WSH (already a witness program)
|
|
196
|
+
*/
|
|
197
|
+
export type AllScriptType = 'witnesspubkeyhash' | 'pubkeyhash' | 'multisig' | 'pubkey' | 'nonstandard' | 'p2sh-witnesspubkeyhash' | 'p2sh-pubkeyhash' | 'p2sh-multisig' | 'p2sh-pubkey' | 'p2sh-nonstandard' | 'p2wsh-pubkeyhash' | 'p2wsh-multisig' | 'p2wsh-pubkey' | 'p2wsh-nonstandard' | 'p2sh-p2wsh-pubkeyhash' | 'p2sh-p2wsh-multisig' | 'p2sh-p2wsh-pubkey' | 'p2sh-p2wsh-nonstandard';
|
|
198
|
+
/**
|
|
199
|
+
* Return type for getScriptFromInput function.
|
|
200
|
+
*/
|
|
201
|
+
export interface GetScriptReturn {
|
|
202
|
+
script: Script | null;
|
|
203
|
+
isSegwit: boolean;
|
|
204
|
+
isP2SH: boolean;
|
|
205
|
+
isP2WSH: boolean;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Index map for transaction input cache.
|
|
209
|
+
*/
|
|
210
|
+
export interface TxInCacheMap {
|
|
211
|
+
readonly [index: string]: number;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Previous output data for signing.
|
|
215
|
+
*/
|
|
216
|
+
export interface PrevOut {
|
|
217
|
+
readonly script: Script;
|
|
218
|
+
readonly value: Satoshi;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Result from getTaprootHashesForSig containing hash and optional leaf hash.
|
|
222
|
+
*/
|
|
223
|
+
export interface TaprootHashResult {
|
|
224
|
+
readonly hash: Bytes32;
|
|
225
|
+
readonly leafHash?: Bytes32 | undefined;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Extended Taproot hash result with pubkey for validation.
|
|
229
|
+
*/
|
|
230
|
+
export interface TaprootSigningHash {
|
|
231
|
+
readonly pubkey: PublicKey;
|
|
232
|
+
readonly hash: Bytes32;
|
|
233
|
+
readonly leafHash?: Bytes32 | undefined;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Function type for final scripts computation.
|
|
237
|
+
*/
|
|
238
|
+
export type FinalScriptsFunc = (inputIndex: number, input: PsbtInput, script: Script, isSegwit: boolean, isP2SH: boolean, isP2WSH: boolean, canRunChecks: boolean) => {
|
|
239
|
+
finalScriptSig: Script | undefined;
|
|
240
|
+
finalScriptWitness: Uint8Array | undefined;
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* Function type for final Taproot scripts computation.
|
|
244
|
+
*/
|
|
245
|
+
export type FinalTaprootScriptsFunc = (inputIndex: number, input: PsbtInput, tapLeafHashToFinalize?: Bytes32) => {
|
|
246
|
+
finalScriptWitness: Uint8Array | undefined;
|
|
247
|
+
};
|
|
248
|
+
export {};
|
|
249
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/psbt/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,IAAI,IAAI,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAClF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,KAAK,EACR,OAAO,EACP,SAAS,EACT,OAAO,EACP,MAAM,EACN,SAAS,EACT,gBAAgB,EACnB,MAAM,aAAa,CAAC;AAErB;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,WAAY,SAAQ,gBAAgB;IACjD,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,iBAAiB;IACnD,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;CACxC;AAED;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAC9B,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,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AK,EAAE,SAAS,EAChB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,OAAO,EACjB,MAAM,EAAE,OAAO,EACf,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,OAAO,KACpB;IACD,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,kBAAkB,EAAE,UAAU,GAAG,SAAS,CAAC;CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,CAClC,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,SAAS,EAChB,qBAAqB,CAAC,EAAE,OAAO,KAC9B;IACD,kBAAkB,EAAE,UAAU,GAAG,SAAS,CAAC;CAC9C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/psbt/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PSBT utility functions
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
5
|
+
import type { ScriptType } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Converts a witness script buffer to an array of witness stack items.
|
|
8
|
+
* @param buffer - The witness script buffer
|
|
9
|
+
* @returns Array of witness stack items
|
|
10
|
+
*/
|
|
11
|
+
export declare function scriptWitnessToWitnessStack(buffer: Uint8Array): Uint8Array[];
|
|
12
|
+
/**
|
|
13
|
+
* Converts a sighash type to a human-readable string.
|
|
14
|
+
* @param sighashType - The sighash type value
|
|
15
|
+
* @returns Human-readable sighash type string
|
|
16
|
+
*/
|
|
17
|
+
export declare function sighashTypeToString(sighashType: number): string;
|
|
18
|
+
/**
|
|
19
|
+
* Compresses an uncompressed public key to compressed form.
|
|
20
|
+
* @param pubkey - The public key (33 or 65 bytes)
|
|
21
|
+
* @returns Compressed public key (33 bytes)
|
|
22
|
+
*/
|
|
23
|
+
export declare function compressPubkey(pubkey: Uint8Array): Uint8Array;
|
|
24
|
+
/**
|
|
25
|
+
* Checks if a buffer looks like a public key.
|
|
26
|
+
* @param buf - The buffer to check
|
|
27
|
+
* @returns True if the buffer is a valid compressed public key format
|
|
28
|
+
*/
|
|
29
|
+
export declare function isPubkeyLike(buf: Uint8Array): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Checks if a buffer looks like a signature.
|
|
32
|
+
* @param buf - The buffer to check
|
|
33
|
+
* @returns True if the buffer is a valid canonical signature format
|
|
34
|
+
*/
|
|
35
|
+
export declare function isSigLike(buf: Uint8Array): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Classifies a script into a known script type.
|
|
38
|
+
* @param script - The script to classify
|
|
39
|
+
* @returns The script type
|
|
40
|
+
*/
|
|
41
|
+
export declare function classifyScript(script: Uint8Array): ScriptType;
|
|
42
|
+
/**
|
|
43
|
+
* Creates an array of numbers from 0 to n-1.
|
|
44
|
+
* @param n - The length of the array
|
|
45
|
+
* @returns Array of numbers [0, 1, 2, ..., n-1]
|
|
46
|
+
*/
|
|
47
|
+
export declare function range(n: number): number[];
|
|
48
|
+
/**
|
|
49
|
+
* Validates that a script is not P2WPKH or P2SH (invalid for P2WSH).
|
|
50
|
+
* @param script - The script to check
|
|
51
|
+
* @throws {Error} If the script is P2WPKH or P2SH
|
|
52
|
+
*/
|
|
53
|
+
export declare function checkInvalidP2WSH(script: Uint8Array): void;
|
|
54
|
+
/**
|
|
55
|
+
* Extracts the meaningful script from a potentially wrapped script.
|
|
56
|
+
* Handles P2SH, P2WSH, and P2SH-P2WSH wrapping.
|
|
57
|
+
* @param script - The script to analyze
|
|
58
|
+
* @param index - The input/output index (for error messages)
|
|
59
|
+
* @param ioType - Whether this is an input or output
|
|
60
|
+
* @param redeemScript - Optional redeem script for P2SH
|
|
61
|
+
* @param witnessScript - Optional witness script for P2WSH
|
|
62
|
+
* @returns The meaningful script and its type
|
|
63
|
+
*/
|
|
64
|
+
export declare function getMeaningfulScript(script: Uint8Array, index: number, ioType: 'input' | 'output', redeemScript?: Uint8Array, witnessScript?: Uint8Array): {
|
|
65
|
+
meaningfulScript: Uint8Array;
|
|
66
|
+
type: 'p2sh' | 'p2wsh' | 'p2sh-p2wsh' | 'raw';
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/psbt/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAI7C;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,EAAE,CA0B5E;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAe/D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAQ7D;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAErD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAElD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAM7D;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAEzC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAI1D;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAC/B,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,OAAO,GAAG,QAAQ,EAC1B,YAAY,CAAC,EAAE,UAAU,EACzB,aAAa,CAAC,EAAE,UAAU,GAC3B;IACC,gBAAgB,EAAE,UAAU,CAAC;IAC7B,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,YAAY,GAAG,KAAK,CAAC;CACjD,CAkCA"}
|