@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
package/src/psbt/psbtutils.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import type { PartialSig, PsbtInput } from 'bip174';
|
|
2
|
+
import { varuint, concat, alloc, equals } from '../io/index.js';
|
|
3
3
|
import { hash160 } from '../crypto.js';
|
|
4
4
|
import { p2ms } from '../payments/p2ms.js';
|
|
5
5
|
import { p2pk } from '../payments/p2pk.js';
|
|
@@ -12,13 +12,14 @@ import { p2op } from '../payments/p2op.js';
|
|
|
12
12
|
import { decompressPublicKey, pubkeysMatch, toXOnly } from '../pubkey.js';
|
|
13
13
|
import * as bscript from '../script.js';
|
|
14
14
|
import { Transaction } from '../transaction.js';
|
|
15
|
+
import type { PublicKey, Script } from '../types.js';
|
|
15
16
|
|
|
16
|
-
type PaymentFunction = (opts: { output:
|
|
17
|
+
type PaymentFunction = (opts: { output: Script }) => unknown;
|
|
17
18
|
|
|
18
|
-
function isPaymentFactory(payment: PaymentFunction): (script:
|
|
19
|
-
return (script:
|
|
19
|
+
function isPaymentFactory(payment: PaymentFunction): (script: Uint8Array) => boolean {
|
|
20
|
+
return (script: Uint8Array): boolean => {
|
|
20
21
|
try {
|
|
21
|
-
payment({ output: script });
|
|
22
|
+
payment({ output: script as Script });
|
|
22
23
|
return true;
|
|
23
24
|
} catch {
|
|
24
25
|
return false;
|
|
@@ -34,7 +35,7 @@ export const isP2WSHScript = isPaymentFactory(p2wsh);
|
|
|
34
35
|
export const isP2SHScript = isPaymentFactory(p2sh);
|
|
35
36
|
export const isP2TR = isPaymentFactory(p2tr);
|
|
36
37
|
export const isP2OP = isPaymentFactory(p2op);
|
|
37
|
-
export const isP2A = (script:
|
|
38
|
+
export const isP2A = (script: Uint8Array): boolean => {
|
|
38
39
|
return (
|
|
39
40
|
script.length === 4 &&
|
|
40
41
|
script[0] === 0x51 && // OP_1
|
|
@@ -47,41 +48,35 @@ export const isP2A = (script: Buffer): boolean => {
|
|
|
47
48
|
/**
|
|
48
49
|
* Converts a witness stack to a script witness.
|
|
49
50
|
* @param witness The witness stack to convert.
|
|
50
|
-
* @returns The script witness as a
|
|
51
|
+
* @returns The script witness as a Uint8Array.
|
|
51
52
|
*/
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
* @param witness The witness stack to convert.
|
|
55
|
-
* @returns The converted script witness.
|
|
56
|
-
*/
|
|
57
|
-
export function witnessStackToScriptWitness(witness: Buffer[]): Buffer {
|
|
58
|
-
let buffer = Buffer.allocUnsafe(0);
|
|
53
|
+
export function witnessStackToScriptWitness(witness: Uint8Array[]): Uint8Array {
|
|
54
|
+
const chunks: Uint8Array[] = [];
|
|
59
55
|
|
|
60
|
-
function writeSlice(slice:
|
|
61
|
-
|
|
56
|
+
function writeSlice(slice: Uint8Array): void {
|
|
57
|
+
chunks.push(slice);
|
|
62
58
|
}
|
|
63
59
|
|
|
64
60
|
function writeVarInt(i: number): void {
|
|
65
|
-
const currentLen = buffer.length;
|
|
66
61
|
const varintLen = varuint.encodingLength(i);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
const buf = alloc(varintLen);
|
|
63
|
+
varuint.encode(i, buf, 0);
|
|
64
|
+
chunks.push(buf);
|
|
70
65
|
}
|
|
71
66
|
|
|
72
|
-
function writeVarSlice(slice:
|
|
67
|
+
function writeVarSlice(slice: Uint8Array): void {
|
|
73
68
|
writeVarInt(slice.length);
|
|
74
69
|
writeSlice(slice);
|
|
75
70
|
}
|
|
76
71
|
|
|
77
|
-
function writeVector(vector:
|
|
72
|
+
function writeVector(vector: Uint8Array[]): void {
|
|
78
73
|
writeVarInt(vector.length);
|
|
79
74
|
vector.forEach(writeVarSlice);
|
|
80
75
|
}
|
|
81
76
|
|
|
82
77
|
writeVector(witness);
|
|
83
78
|
|
|
84
|
-
return
|
|
79
|
+
return concat(chunks);
|
|
85
80
|
}
|
|
86
81
|
|
|
87
82
|
/**
|
|
@@ -91,7 +86,7 @@ export function witnessStackToScriptWitness(witness: Buffer[]): Buffer {
|
|
|
91
86
|
* @returns The index of the public key in the script, or -1 if not found.
|
|
92
87
|
* @throws {Error} If there is an unknown script error.
|
|
93
88
|
*/
|
|
94
|
-
export function pubkeyPositionInScript(pubkey:
|
|
89
|
+
export function pubkeyPositionInScript(pubkey: Uint8Array, script: Uint8Array): number {
|
|
95
90
|
const decompiled = bscript.decompile(script);
|
|
96
91
|
if (decompiled === null) throw new Error('Unknown script error');
|
|
97
92
|
|
|
@@ -99,8 +94,8 @@ export function pubkeyPositionInScript(pubkey: Buffer, script: Buffer): number {
|
|
|
99
94
|
const pubkeyHash = hash160(pubkey);
|
|
100
95
|
|
|
101
96
|
// For Taproot or some cases, we might also check the x-only
|
|
102
|
-
const pubkeyXOnly = toXOnly(pubkey);
|
|
103
|
-
const uncompressed = decompressPublicKey(pubkey);
|
|
97
|
+
const pubkeyXOnly = toXOnly(pubkey as PublicKey);
|
|
98
|
+
const uncompressed = decompressPublicKey(pubkey as PublicKey);
|
|
104
99
|
|
|
105
100
|
const pubkeyHybridHash = uncompressed?.hybrid ? hash160(uncompressed.hybrid) : undefined;
|
|
106
101
|
const pubkeyUncompressedHash = uncompressed?.uncompressed
|
|
@@ -114,7 +109,7 @@ export function pubkeyPositionInScript(pubkey: Buffer, script: Buffer): number {
|
|
|
114
109
|
|
|
115
110
|
if (pubkeysMatch(element, pubkeyXOnly)) return true;
|
|
116
111
|
|
|
117
|
-
if (
|
|
112
|
+
if (equals(element, pubkeyHash)) {
|
|
118
113
|
return true;
|
|
119
114
|
}
|
|
120
115
|
|
|
@@ -124,12 +119,14 @@ export function pubkeyPositionInScript(pubkey: Buffer, script: Buffer): number {
|
|
|
124
119
|
if (pubkeysMatch(element, uncompressed.hybrid)) return true;
|
|
125
120
|
|
|
126
121
|
if (
|
|
127
|
-
(pubkeyHybridHash &&
|
|
128
|
-
(pubkeyUncompressedHash &&
|
|
122
|
+
(pubkeyHybridHash && equals(element, pubkeyHybridHash)) ||
|
|
123
|
+
(pubkeyUncompressedHash && equals(element, pubkeyUncompressedHash))
|
|
129
124
|
) {
|
|
130
125
|
return true;
|
|
131
126
|
}
|
|
132
127
|
}
|
|
128
|
+
|
|
129
|
+
return false;
|
|
133
130
|
});
|
|
134
131
|
}
|
|
135
132
|
|
|
@@ -139,7 +136,7 @@ export function pubkeyPositionInScript(pubkey: Buffer, script: Buffer): number {
|
|
|
139
136
|
* @param script The script to search in.
|
|
140
137
|
* @returns A boolean indicating whether the public key is present in the script.
|
|
141
138
|
*/
|
|
142
|
-
export function pubkeyInScript(pubkey:
|
|
139
|
+
export function pubkeyInScript(pubkey: Uint8Array, script: Uint8Array): boolean {
|
|
143
140
|
return pubkeyPositionInScript(pubkey, script) !== -1;
|
|
144
141
|
}
|
|
145
142
|
|
|
@@ -154,8 +151,8 @@ export function checkInputForSig(input: PsbtInput, action: string): boolean {
|
|
|
154
151
|
return pSigs.some((pSig) => signatureBlocksAction(pSig, bscript.signature.decode, action));
|
|
155
152
|
}
|
|
156
153
|
|
|
157
|
-
type SignatureDecodeFunc = (buffer:
|
|
158
|
-
signature:
|
|
154
|
+
type SignatureDecodeFunc = (buffer: Uint8Array) => {
|
|
155
|
+
signature: Uint8Array;
|
|
159
156
|
hashType: number;
|
|
160
157
|
};
|
|
161
158
|
|
|
@@ -167,7 +164,7 @@ type SignatureDecodeFunc = (buffer: Buffer) => {
|
|
|
167
164
|
* @returns True if the action is allowed, false otherwise.
|
|
168
165
|
*/
|
|
169
166
|
export function signatureBlocksAction(
|
|
170
|
-
signature:
|
|
167
|
+
signature: Uint8Array,
|
|
171
168
|
signatureDecodeFn: SignatureDecodeFunc,
|
|
172
169
|
action: string,
|
|
173
170
|
): boolean {
|
|
@@ -198,7 +195,7 @@ export function signatureBlocksAction(
|
|
|
198
195
|
* @param input - The PsbtInput object from which to extract the signatures.
|
|
199
196
|
* @returns An array of signatures extracted from the PsbtInput object.
|
|
200
197
|
*/
|
|
201
|
-
function extractPartialSigs(input: PsbtInput):
|
|
198
|
+
function extractPartialSigs(input: PsbtInput): Uint8Array[] {
|
|
202
199
|
const { partialSig } = input;
|
|
203
200
|
let pSigs: PartialSig[];
|
|
204
201
|
if (!partialSig || partialSig.length === 0) {
|
|
@@ -207,7 +204,7 @@ function extractPartialSigs(input: PsbtInput): Buffer[] {
|
|
|
207
204
|
} else {
|
|
208
205
|
pSigs = partialSig;
|
|
209
206
|
}
|
|
210
|
-
return pSigs.map((p) => p.signature);
|
|
207
|
+
return pSigs.map((p) => new Uint8Array(p.signature));
|
|
211
208
|
}
|
|
212
209
|
|
|
213
210
|
/**
|
|
@@ -219,14 +216,16 @@ function extractPartialSigs(input: PsbtInput): Buffer[] {
|
|
|
219
216
|
* @returns An array of PartialSig objects containing the extracted Psigs.
|
|
220
217
|
*/
|
|
221
218
|
export function getPsigsFromInputFinalScripts(input: PsbtInput): PartialSig[] {
|
|
222
|
-
const scriptItems = !input.finalScriptSig
|
|
219
|
+
const scriptItems = !input.finalScriptSig
|
|
220
|
+
? []
|
|
221
|
+
: bscript.decompile(new Uint8Array(input.finalScriptSig)) || [];
|
|
223
222
|
const witnessItems = !input.finalScriptWitness
|
|
224
223
|
? []
|
|
225
|
-
: bscript.decompile(input.finalScriptWitness) || [];
|
|
224
|
+
: bscript.decompile(new Uint8Array(input.finalScriptWitness)) || [];
|
|
226
225
|
return scriptItems
|
|
227
226
|
.concat(witnessItems)
|
|
228
227
|
.filter((item) => {
|
|
229
|
-
return
|
|
228
|
+
return item instanceof Uint8Array && bscript.isCanonicalScriptSignature(item);
|
|
230
229
|
})
|
|
231
|
-
.map((sig) => ({ signature: sig })) as PartialSig[];
|
|
230
|
+
.map((sig) => ({ signature: sig as Uint8Array })) as PartialSig[];
|
|
232
231
|
}
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PSBT types and interfaces
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { Psbt as PsbtBase, PsbtGlobal, PsbtInput, PsbtOutput } from 'bip174';
|
|
7
|
+
import type { Network } from '../networks.js';
|
|
8
|
+
import type { Transaction, TaprootHashCache } from '../transaction.js';
|
|
9
|
+
import type {
|
|
10
|
+
Bytes32,
|
|
11
|
+
PublicKey,
|
|
12
|
+
Satoshi,
|
|
13
|
+
Script,
|
|
14
|
+
Signature,
|
|
15
|
+
SchnorrSignature,
|
|
16
|
+
} from '../types.js';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Transaction input interface for PSBT.
|
|
20
|
+
*/
|
|
21
|
+
export interface TransactionInput {
|
|
22
|
+
readonly hash: string | Bytes32;
|
|
23
|
+
readonly index: number;
|
|
24
|
+
readonly sequence?: number | undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* PSBT transaction input with Uint8Array hash.
|
|
29
|
+
*/
|
|
30
|
+
export interface PsbtTxInput extends TransactionInput {
|
|
31
|
+
readonly hash: Bytes32;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Transaction output interface for PSBT.
|
|
36
|
+
*/
|
|
37
|
+
export interface TransactionOutput {
|
|
38
|
+
readonly script: Script;
|
|
39
|
+
readonly value: Satoshi;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* PSBT transaction output with optional address.
|
|
44
|
+
*/
|
|
45
|
+
export interface PsbtTxOutput extends TransactionOutput {
|
|
46
|
+
readonly address: string | undefined;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Signature validation function type.
|
|
51
|
+
* msghash is 32 byte hash of preimage, signature is 64 byte compact signature (r,s 32 bytes each)
|
|
52
|
+
*/
|
|
53
|
+
export type ValidateSigFunction = (
|
|
54
|
+
pubkey: PublicKey,
|
|
55
|
+
msghash: Bytes32,
|
|
56
|
+
signature: Uint8Array,
|
|
57
|
+
) => boolean;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Extended PsbtBase interface with typed inputs and globalMap.
|
|
61
|
+
*/
|
|
62
|
+
export interface PsbtBaseExtended extends Omit<PsbtBase, 'inputs'> {
|
|
63
|
+
readonly inputs: PsbtInput[];
|
|
64
|
+
readonly globalMap: PsbtGlobal;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Optional PSBT options.
|
|
69
|
+
*/
|
|
70
|
+
export interface PsbtOptsOptional {
|
|
71
|
+
readonly network?: Network | undefined;
|
|
72
|
+
readonly maximumFeeRate?: number | undefined;
|
|
73
|
+
readonly version?: 1 | 2 | 3 | undefined;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Required PSBT options.
|
|
78
|
+
*/
|
|
79
|
+
export interface PsbtOpts {
|
|
80
|
+
readonly network: Network;
|
|
81
|
+
maximumFeeRate: number;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Extended PSBT input with additional fields.
|
|
86
|
+
*/
|
|
87
|
+
export interface PsbtInputExtended extends PsbtInput, TransactionInput {
|
|
88
|
+
readonly isPayToAnchor?: boolean | undefined;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Extended PSBT output - either address-based or script-based.
|
|
93
|
+
*/
|
|
94
|
+
export type PsbtOutputExtended = PsbtOutputExtendedAddress | PsbtOutputExtendedScript;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* PSBT output with address.
|
|
98
|
+
*/
|
|
99
|
+
export interface PsbtOutputExtendedAddress extends PsbtOutput {
|
|
100
|
+
readonly address: string;
|
|
101
|
+
readonly value: Satoshi;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* PSBT output with script.
|
|
106
|
+
*/
|
|
107
|
+
export interface PsbtOutputExtendedScript extends PsbtOutput {
|
|
108
|
+
readonly script: Script;
|
|
109
|
+
readonly value: Satoshi;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Base interface for HD signers.
|
|
114
|
+
*/
|
|
115
|
+
interface HDSignerBase {
|
|
116
|
+
/**
|
|
117
|
+
* DER format compressed publicKey Uint8Array
|
|
118
|
+
*/
|
|
119
|
+
readonly publicKey: PublicKey;
|
|
120
|
+
/**
|
|
121
|
+
* The first 4 bytes of the sha256-ripemd160 of the publicKey
|
|
122
|
+
*/
|
|
123
|
+
readonly fingerprint: Uint8Array;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* HD signer interface for synchronous signing.
|
|
128
|
+
*/
|
|
129
|
+
export interface HDSigner extends HDSignerBase {
|
|
130
|
+
/**
|
|
131
|
+
* The path string must match /^m(\/\d+'?)+$/
|
|
132
|
+
* ex. m/44'/0'/0'/1/23 levels with ' must be hard derivations
|
|
133
|
+
*/
|
|
134
|
+
derivePath(path: string): HDSigner;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Input hash (the "message digest") for the signature algorithm
|
|
138
|
+
* Return a 64 byte signature (32 byte r and 32 byte s in that order)
|
|
139
|
+
*/
|
|
140
|
+
sign(hash: Bytes32): Uint8Array;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* HD signer interface for asynchronous signing.
|
|
145
|
+
*/
|
|
146
|
+
export interface HDSignerAsync extends HDSignerBase {
|
|
147
|
+
derivePath(path: string): HDSignerAsync;
|
|
148
|
+
|
|
149
|
+
sign(hash: Bytes32): Promise<Uint8Array>;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Alternative signer interface with lowR support.
|
|
154
|
+
*/
|
|
155
|
+
export interface SignerAlternative {
|
|
156
|
+
readonly publicKey: PublicKey;
|
|
157
|
+
readonly lowR: boolean;
|
|
158
|
+
|
|
159
|
+
sign(hash: Bytes32, lowR?: boolean): Signature;
|
|
160
|
+
|
|
161
|
+
verify(hash: Bytes32, signature: Signature): boolean;
|
|
162
|
+
|
|
163
|
+
signSchnorr(hash: Bytes32): SchnorrSignature;
|
|
164
|
+
|
|
165
|
+
verifySchnorr(hash: Bytes32, signature: SchnorrSignature): boolean;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Basic signer interface for synchronous signing.
|
|
170
|
+
*/
|
|
171
|
+
export interface Signer {
|
|
172
|
+
readonly publicKey: PublicKey;
|
|
173
|
+
readonly network?: Network | undefined;
|
|
174
|
+
|
|
175
|
+
sign(hash: Bytes32, lowR?: boolean): Signature;
|
|
176
|
+
|
|
177
|
+
signSchnorr?(hash: Bytes32): SchnorrSignature;
|
|
178
|
+
|
|
179
|
+
getPublicKey?(): PublicKey;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Basic signer interface for asynchronous signing.
|
|
184
|
+
*/
|
|
185
|
+
export interface SignerAsync {
|
|
186
|
+
readonly publicKey: PublicKey;
|
|
187
|
+
readonly network?: Network | undefined;
|
|
188
|
+
|
|
189
|
+
sign(hash: Bytes32, lowR?: boolean): Promise<Signature>;
|
|
190
|
+
|
|
191
|
+
signSchnorr?(hash: Bytes32): Promise<SchnorrSignature>;
|
|
192
|
+
|
|
193
|
+
getPublicKey?(): PublicKey;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Minimal key pair interface for checking Taproot hashes.
|
|
198
|
+
* Only requires publicKey and optional signSchnorr presence check.
|
|
199
|
+
* Used by checkTaprootHashesForSig to accept broader key pair types (e.g., worker key pairs).
|
|
200
|
+
*/
|
|
201
|
+
export interface TaprootHashCheckSigner {
|
|
202
|
+
readonly publicKey: Uint8Array;
|
|
203
|
+
signSchnorr?(hash: Uint8Array): Uint8Array | Promise<Uint8Array>;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Internal PSBT cache for computed values.
|
|
208
|
+
*/
|
|
209
|
+
export interface PsbtCache {
|
|
210
|
+
nonWitnessUtxoTxCache: Transaction[];
|
|
211
|
+
nonWitnessUtxoBufCache: Uint8Array[];
|
|
212
|
+
txInCache: TxInCacheMap;
|
|
213
|
+
tx: Transaction;
|
|
214
|
+
feeRate?: number | undefined;
|
|
215
|
+
fee?: number | undefined;
|
|
216
|
+
extractedTx?: Transaction | undefined;
|
|
217
|
+
unsafeSignNonSegwit: boolean;
|
|
218
|
+
/** Cached flag: true if any input has signatures (avoids O(n) check) */
|
|
219
|
+
hasSignatures: boolean;
|
|
220
|
+
/** Cached prevOuts for Taproot signing (computed once) */
|
|
221
|
+
prevOuts?: readonly PrevOut[] | undefined;
|
|
222
|
+
/** Cached signing scripts */
|
|
223
|
+
signingScripts?: readonly Script[] | undefined;
|
|
224
|
+
/** Cached values */
|
|
225
|
+
values?: readonly Satoshi[] | undefined;
|
|
226
|
+
/** Cached intermediate hashes for Taproot sighash (computed once per PSBT) */
|
|
227
|
+
taprootHashCache?: TaprootHashCache | undefined;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Keys for cached numeric values in the transaction cache.
|
|
232
|
+
*/
|
|
233
|
+
export type TxCacheNumberKey = 'feeRate' | 'fee';
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Script types for classification.
|
|
237
|
+
*/
|
|
238
|
+
export type ScriptType = 'witnesspubkeyhash' | 'pubkeyhash' | 'multisig' | 'pubkey' | 'nonstandard';
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* All possible script types including witness types.
|
|
242
|
+
* Note: P2WPKH can't be wrapped in P2WSH (already a witness program)
|
|
243
|
+
*/
|
|
244
|
+
export type AllScriptType =
|
|
245
|
+
| 'witnesspubkeyhash'
|
|
246
|
+
| 'pubkeyhash'
|
|
247
|
+
| 'multisig'
|
|
248
|
+
| 'pubkey'
|
|
249
|
+
| 'nonstandard'
|
|
250
|
+
| 'p2sh-witnesspubkeyhash'
|
|
251
|
+
| 'p2sh-pubkeyhash'
|
|
252
|
+
| 'p2sh-multisig'
|
|
253
|
+
| 'p2sh-pubkey'
|
|
254
|
+
| 'p2sh-nonstandard'
|
|
255
|
+
| 'p2wsh-pubkeyhash'
|
|
256
|
+
| 'p2wsh-multisig'
|
|
257
|
+
| 'p2wsh-pubkey'
|
|
258
|
+
| 'p2wsh-nonstandard'
|
|
259
|
+
| 'p2sh-p2wsh-pubkeyhash'
|
|
260
|
+
| 'p2sh-p2wsh-multisig'
|
|
261
|
+
| 'p2sh-p2wsh-pubkey'
|
|
262
|
+
| 'p2sh-p2wsh-nonstandard';
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Return type for getScriptFromInput function.
|
|
266
|
+
*/
|
|
267
|
+
export interface GetScriptReturn {
|
|
268
|
+
script: Script | null;
|
|
269
|
+
isSegwit: boolean;
|
|
270
|
+
isP2SH: boolean;
|
|
271
|
+
isP2WSH: boolean;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Index map for transaction input cache.
|
|
276
|
+
*/
|
|
277
|
+
export interface TxInCacheMap {
|
|
278
|
+
readonly [index: string]: number;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Previous output data for signing.
|
|
283
|
+
*/
|
|
284
|
+
export interface PrevOut {
|
|
285
|
+
readonly script: Script;
|
|
286
|
+
readonly value: Satoshi;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Result from getTaprootHashesForSig containing hash and optional leaf hash.
|
|
291
|
+
*/
|
|
292
|
+
export interface TaprootHashResult {
|
|
293
|
+
readonly hash: Bytes32;
|
|
294
|
+
readonly leafHash?: Bytes32 | undefined;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Extended Taproot hash result with pubkey for validation.
|
|
299
|
+
*/
|
|
300
|
+
export interface TaprootSigningHash {
|
|
301
|
+
readonly pubkey: PublicKey;
|
|
302
|
+
readonly hash: Bytes32;
|
|
303
|
+
readonly leafHash?: Bytes32 | undefined;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Function type for final scripts computation.
|
|
308
|
+
*/
|
|
309
|
+
export type FinalScriptsFunc = (
|
|
310
|
+
inputIndex: number,
|
|
311
|
+
input: PsbtInput,
|
|
312
|
+
script: Script,
|
|
313
|
+
isSegwit: boolean,
|
|
314
|
+
isP2SH: boolean,
|
|
315
|
+
isP2WSH: boolean,
|
|
316
|
+
canRunChecks: boolean,
|
|
317
|
+
) => {
|
|
318
|
+
finalScriptSig: Script | undefined;
|
|
319
|
+
finalScriptWitness: Uint8Array | undefined;
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Function type for final Taproot scripts computation.
|
|
324
|
+
*/
|
|
325
|
+
export type FinalTaprootScriptsFunc = (
|
|
326
|
+
inputIndex: number,
|
|
327
|
+
input: PsbtInput,
|
|
328
|
+
tapLeafHashToFinalize?: Bytes32,
|
|
329
|
+
) => {
|
|
330
|
+
finalScriptWitness: Uint8Array | undefined;
|
|
331
|
+
};
|