@btc-vision/bitcoin 6.5.6 → 7.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HOW_TO_WRITE_GOOD_CODE.md +2436 -0
- package/benchmark/psbt-2000-inputs.bench.ts +178 -0
- package/benchmark/signing.bench.ts +147 -0
- package/browser/address.d.ts +56 -9
- package/browser/address.d.ts.map +1 -0
- package/browser/bech32utils.d.ts +9 -1
- package/browser/bech32utils.d.ts.map +1 -0
- package/browser/bip66.d.ts +11 -6
- package/browser/bip66.d.ts.map +1 -0
- package/browser/block.d.ts +117 -11
- package/browser/block.d.ts.map +1 -0
- package/browser/branded.d.ts +20 -0
- package/browser/branded.d.ts.map +1 -0
- package/browser/crypto/crypto.d.ts +1 -0
- package/browser/crypto/crypto.d.ts.map +1 -0
- package/browser/crypto.d.ts +46 -7
- package/browser/crypto.d.ts.map +1 -0
- package/browser/ecc/context.d.ts +129 -0
- package/browser/ecc/context.d.ts.map +1 -0
- package/browser/ecc/index.d.ts +11 -0
- package/browser/ecc/index.d.ts.map +1 -0
- package/browser/ecc/types.d.ts +128 -0
- package/browser/ecc/types.d.ts.map +1 -0
- package/browser/ecpair.d.ts +99 -0
- package/browser/errors.d.ts +124 -0
- package/browser/errors.d.ts.map +1 -0
- package/browser/index.d.ts +32 -5
- package/browser/index.d.ts.map +1 -0
- package/browser/index.js +12482 -101
- package/browser/io/BinaryReader.d.ts +276 -0
- package/browser/io/BinaryReader.d.ts.map +1 -0
- package/browser/io/BinaryWriter.d.ts +391 -0
- package/browser/io/BinaryWriter.d.ts.map +1 -0
- package/browser/io/MemoryPool.d.ts +220 -0
- package/browser/io/MemoryPool.d.ts.map +1 -0
- package/browser/io/base64.d.ts +13 -0
- package/browser/io/base64.d.ts.map +1 -0
- package/browser/io/hex.d.ts +67 -0
- package/browser/io/hex.d.ts.map +1 -0
- package/browser/io/index.d.ts +17 -0
- package/browser/io/index.d.ts.map +1 -0
- package/browser/io/utils.d.ts +199 -0
- package/browser/io/utils.d.ts.map +1 -0
- package/browser/merkle.d.ts +10 -1
- package/browser/merkle.d.ts.map +1 -0
- package/browser/networks.d.ts +70 -9
- package/browser/networks.d.ts.map +1 -0
- package/browser/opcodes.d.ts +1 -0
- package/browser/opcodes.d.ts.map +1 -0
- package/browser/payments/bip341.d.ts +35 -9
- package/browser/payments/bip341.d.ts.map +1 -0
- package/browser/payments/embed.d.ts +112 -1
- package/browser/payments/embed.d.ts.map +1 -0
- package/browser/payments/index.d.ts +17 -10
- package/browser/payments/index.d.ts.map +1 -0
- package/browser/payments/p2ms.d.ts +150 -0
- package/browser/payments/p2ms.d.ts.map +1 -0
- package/browser/payments/p2op.d.ts +150 -24
- package/browser/payments/p2op.d.ts.map +1 -0
- package/browser/payments/p2pk.d.ts +154 -1
- package/browser/payments/p2pk.d.ts.map +1 -0
- package/browser/payments/p2pkh.d.ts +176 -1
- package/browser/payments/p2pkh.d.ts.map +1 -0
- package/browser/payments/p2sh.d.ts +150 -1
- package/browser/payments/p2sh.d.ts.map +1 -0
- package/browser/payments/p2tr.d.ts +185 -1
- package/browser/payments/p2tr.d.ts.map +1 -0
- package/browser/payments/p2wpkh.d.ts +161 -1
- package/browser/payments/p2wpkh.d.ts.map +1 -0
- package/browser/payments/p2wsh.d.ts +146 -1
- package/browser/payments/p2wsh.d.ts.map +1 -0
- package/browser/payments/types.d.ts +94 -64
- package/browser/payments/types.d.ts.map +1 -0
- package/browser/psbt/bip371.d.ts +34 -8
- package/browser/psbt/bip371.d.ts.map +1 -0
- package/browser/psbt/psbtutils.d.ts +56 -16
- package/browser/psbt/psbtutils.d.ts.map +1 -0
- package/browser/psbt/types.d.ts +245 -0
- package/browser/psbt/types.d.ts.map +1 -0
- package/browser/psbt/utils.d.ts +64 -0
- package/browser/psbt/utils.d.ts.map +1 -0
- package/browser/psbt/validation.d.ts +84 -0
- package/browser/psbt/validation.d.ts.map +1 -0
- package/browser/psbt.d.ts +82 -118
- package/browser/psbt.d.ts.map +1 -0
- package/browser/pubkey.d.ts +27 -6
- package/browser/pubkey.d.ts.map +1 -0
- package/browser/push_data.d.ts +24 -2
- package/browser/push_data.d.ts.map +1 -0
- package/browser/script.d.ts +33 -8
- package/browser/script.d.ts.map +1 -0
- package/browser/script_number.d.ts +17 -0
- package/browser/script_number.d.ts.map +1 -0
- package/browser/script_signature.d.ts +23 -5
- package/browser/script_signature.d.ts.map +1 -0
- package/browser/transaction.d.ts +160 -18
- package/browser/transaction.d.ts.map +1 -0
- package/browser/types.d.ts +36 -38
- package/browser/types.d.ts.map +1 -0
- package/browser/workers/WorkerSigningPool.d.ts +143 -0
- package/browser/workers/WorkerSigningPool.d.ts.map +1 -0
- package/browser/workers/WorkerSigningPool.node.d.ts +116 -0
- package/browser/workers/WorkerSigningPool.node.d.ts.map +1 -0
- package/browser/workers/ecc-bundle.d.ts +25 -0
- package/browser/workers/ecc-bundle.d.ts.map +1 -0
- package/browser/workers/index.d.ts +91 -0
- package/browser/workers/index.d.ts.map +1 -0
- package/browser/workers/psbt-parallel.d.ts +88 -0
- package/browser/workers/psbt-parallel.d.ts.map +1 -0
- package/browser/workers/signing-worker.d.ts +37 -0
- package/browser/workers/signing-worker.d.ts.map +1 -0
- package/browser/workers/types.d.ts +365 -0
- package/browser/workers/types.d.ts.map +1 -0
- package/build/address.d.ts +57 -10
- package/build/address.d.ts.map +1 -0
- package/build/address.js +80 -24
- package/build/address.js.map +1 -0
- package/build/bech32utils.d.ts +9 -1
- package/build/bech32utils.d.ts.map +1 -0
- package/build/bech32utils.js +10 -2
- package/build/bech32utils.js.map +1 -0
- package/build/bip66.d.ts +11 -6
- package/build/bip66.d.ts.map +1 -0
- package/build/bip66.js +32 -3
- package/build/bip66.js.map +1 -0
- package/build/block.d.ts +117 -11
- package/build/block.d.ts.map +1 -0
- package/build/block.js +204 -72
- package/build/block.js.map +1 -0
- package/build/branded.d.ts +20 -0
- package/build/branded.d.ts.map +1 -0
- package/build/branded.js +7 -0
- package/build/branded.js.map +1 -0
- package/build/crypto/crypto.d.ts +1 -0
- package/build/crypto/crypto.d.ts.map +1 -0
- package/build/crypto/crypto.js +1 -0
- package/build/crypto/crypto.js.map +1 -0
- package/build/crypto.d.ts +46 -7
- package/build/crypto.d.ts.map +1 -0
- package/build/crypto.js +65 -20
- package/build/crypto.js.map +1 -0
- package/build/ecc/context.d.ts +135 -0
- package/build/ecc/context.d.ts.map +1 -0
- package/build/ecc/context.js +232 -0
- package/build/ecc/context.js.map +1 -0
- package/build/ecc/index.d.ts +11 -0
- package/build/ecc/index.d.ts.map +1 -0
- package/build/ecc/index.js +11 -0
- package/build/ecc/index.js.map +1 -0
- package/build/ecc/types.d.ts +134 -0
- package/build/ecc/types.d.ts.map +1 -0
- package/build/ecc/types.js +8 -0
- package/build/ecc/types.js.map +1 -0
- package/build/errors.d.ts +124 -0
- package/build/errors.d.ts.map +1 -0
- package/build/errors.js +155 -0
- package/build/errors.js.map +1 -0
- package/build/index.d.ts +32 -5
- package/build/index.d.ts.map +1 -0
- package/build/index.js +26 -3
- package/build/index.js.map +1 -0
- package/build/io/BinaryReader.d.ts +276 -0
- package/build/io/BinaryReader.d.ts.map +1 -0
- package/build/io/BinaryReader.js +425 -0
- package/build/io/BinaryReader.js.map +1 -0
- package/build/io/BinaryWriter.d.ts +391 -0
- package/build/io/BinaryWriter.d.ts.map +1 -0
- package/build/io/BinaryWriter.js +611 -0
- package/build/io/BinaryWriter.js.map +1 -0
- package/build/io/MemoryPool.d.ts +220 -0
- package/build/io/MemoryPool.d.ts.map +1 -0
- package/build/io/MemoryPool.js +309 -0
- package/build/io/MemoryPool.js.map +1 -0
- package/build/io/base64.d.ts +13 -0
- package/build/io/base64.d.ts.map +1 -0
- package/build/io/base64.js +20 -0
- package/build/io/base64.js.map +1 -0
- package/build/io/hex.d.ts +67 -0
- package/build/io/hex.d.ts.map +1 -0
- package/build/io/hex.js +138 -0
- package/build/io/hex.js.map +1 -0
- package/build/io/index.d.ts +17 -0
- package/build/io/index.d.ts.map +1 -0
- package/build/io/index.js +23 -0
- package/build/io/index.js.map +1 -0
- package/build/io/utils.d.ts +199 -0
- package/build/io/utils.d.ts.map +1 -0
- package/build/io/utils.js +271 -0
- package/build/io/utils.js.map +1 -0
- package/build/merkle.d.ts +10 -1
- package/build/merkle.d.ts.map +1 -0
- package/build/merkle.js +12 -1
- package/build/merkle.js.map +1 -0
- package/build/networks.d.ts +70 -9
- package/build/networks.d.ts.map +1 -0
- package/build/networks.js +90 -4
- package/build/networks.js.map +1 -0
- package/build/opcodes.d.ts +1 -0
- package/build/opcodes.d.ts.map +1 -0
- package/build/opcodes.js +1 -0
- package/build/opcodes.js.map +1 -0
- package/build/payments/bip341.d.ts +36 -9
- package/build/payments/bip341.d.ts.map +1 -0
- package/build/payments/bip341.js +35 -15
- package/build/payments/bip341.js.map +1 -0
- package/build/payments/embed.d.ts +120 -1
- package/build/payments/embed.d.ts.map +1 -0
- package/build/payments/embed.js +215 -34
- package/build/payments/embed.js.map +1 -0
- package/build/payments/index.d.ts +17 -10
- package/build/payments/index.d.ts.map +1 -0
- package/build/payments/index.js +20 -10
- package/build/payments/index.js.map +1 -0
- package/build/payments/p2ms.d.ts +159 -1
- package/build/payments/p2ms.d.ts.map +1 -0
- package/build/payments/p2ms.js +427 -108
- package/build/payments/p2ms.js.map +1 -0
- package/build/payments/p2op.d.ts +158 -24
- package/build/payments/p2op.d.ts.map +1 -0
- package/build/payments/p2op.js +379 -93
- package/build/payments/p2op.js.map +1 -0
- package/build/payments/p2pk.d.ts +162 -1
- package/build/payments/p2pk.d.ts.map +1 -0
- package/build/payments/p2pk.js +327 -58
- package/build/payments/p2pk.js.map +1 -0
- package/build/payments/p2pkh.d.ts +185 -1
- package/build/payments/p2pkh.d.ts.map +1 -0
- package/build/payments/p2pkh.js +467 -114
- package/build/payments/p2pkh.js.map +1 -0
- package/build/payments/p2sh.d.ts +159 -1
- package/build/payments/p2sh.d.ts.map +1 -0
- package/build/payments/p2sh.js +500 -152
- package/build/payments/p2sh.js.map +1 -0
- package/build/payments/p2tr.d.ts +193 -1
- package/build/payments/p2tr.d.ts.map +1 -0
- package/build/payments/p2tr.js +592 -174
- package/build/payments/p2tr.js.map +1 -0
- package/build/payments/p2wpkh.d.ts +170 -1
- package/build/payments/p2wpkh.d.ts.map +1 -0
- package/build/payments/p2wpkh.js +429 -104
- package/build/payments/p2wpkh.js.map +1 -0
- package/build/payments/p2wsh.d.ts +155 -1
- package/build/payments/p2wsh.d.ts.map +1 -0
- package/build/payments/p2wsh.js +466 -144
- package/build/payments/p2wsh.js.map +1 -0
- package/build/payments/types.d.ts +98 -64
- package/build/payments/types.d.ts.map +1 -0
- package/build/payments/types.js +17 -13
- package/build/payments/types.js.map +1 -0
- package/build/psbt/bip371.d.ts +35 -9
- package/build/psbt/bip371.d.ts.map +1 -0
- package/build/psbt/bip371.js +113 -28
- package/build/psbt/bip371.js.map +1 -0
- package/build/psbt/psbtutils.d.ts +56 -16
- package/build/psbt/psbtutils.d.ts.map +1 -0
- package/build/psbt/psbtutils.js +71 -16
- package/build/psbt/psbtutils.js.map +1 -0
- package/build/psbt/types.d.ts +249 -0
- package/build/psbt/types.d.ts.map +1 -0
- package/build/psbt/types.js +6 -0
- package/build/psbt/types.js.map +1 -0
- package/build/psbt/utils.d.ts +68 -0
- package/build/psbt/utils.d.ts.map +1 -0
- package/build/psbt/utils.js +171 -0
- package/build/psbt/utils.js.map +1 -0
- package/build/psbt/validation.d.ts +88 -0
- package/build/psbt/validation.d.ts.map +1 -0
- package/build/psbt/validation.js +149 -0
- package/build/psbt/validation.js.map +1 -0
- package/build/psbt.d.ts +84 -120
- package/build/psbt.d.ts.map +1 -0
- package/build/psbt.js +411 -412
- package/build/psbt.js.map +1 -0
- package/build/pubkey.d.ts +27 -6
- package/build/pubkey.d.ts.map +1 -0
- package/build/pubkey.js +36 -12
- package/build/pubkey.js.map +1 -0
- package/build/push_data.d.ts +24 -2
- package/build/push_data.d.ts.map +1 -0
- package/build/push_data.js +44 -12
- package/build/push_data.js.map +1 -0
- package/build/script.d.ts +33 -8
- package/build/script.d.ts.map +1 -0
- package/build/script.js +100 -36
- package/build/script.js.map +1 -0
- package/build/script_number.d.ts +17 -0
- package/build/script_number.d.ts.map +1 -0
- package/build/script_number.js +19 -0
- package/build/script_number.js.map +1 -0
- package/build/script_signature.d.ts +23 -5
- package/build/script_signature.d.ts.map +1 -0
- package/build/script_signature.js +48 -15
- package/build/script_signature.js.map +1 -0
- package/build/transaction.d.ts +160 -18
- package/build/transaction.d.ts.map +1 -0
- package/build/transaction.js +443 -176
- package/build/transaction.js.map +1 -0
- package/build/tsconfig.build.tsbuildinfo +1 -0
- package/build/types.d.ts +36 -38
- package/build/types.d.ts.map +1 -0
- package/build/types.js +175 -57
- package/build/types.js.map +1 -0
- package/build/workers/WorkerSigningPool.d.ts +174 -0
- package/build/workers/WorkerSigningPool.d.ts.map +1 -0
- package/build/workers/WorkerSigningPool.js +553 -0
- package/build/workers/WorkerSigningPool.js.map +1 -0
- package/build/workers/WorkerSigningPool.node.d.ts +124 -0
- package/build/workers/WorkerSigningPool.node.d.ts.map +1 -0
- package/build/workers/WorkerSigningPool.node.js +753 -0
- package/build/workers/WorkerSigningPool.node.js.map +1 -0
- package/build/workers/ecc-bundle.d.ts +25 -0
- package/build/workers/ecc-bundle.d.ts.map +1 -0
- package/build/workers/ecc-bundle.js +25 -0
- package/build/workers/ecc-bundle.js.map +1 -0
- package/build/workers/index.d.ts +91 -0
- package/build/workers/index.d.ts.map +1 -0
- package/build/workers/index.js +114 -0
- package/build/workers/index.js.map +1 -0
- package/build/workers/psbt-parallel.d.ts +117 -0
- package/build/workers/psbt-parallel.d.ts.map +1 -0
- package/build/workers/psbt-parallel.js +233 -0
- package/build/workers/psbt-parallel.js.map +1 -0
- package/build/workers/signing-worker.d.ts +37 -0
- package/build/workers/signing-worker.d.ts.map +1 -0
- package/build/workers/signing-worker.js +350 -0
- package/build/workers/signing-worker.js.map +1 -0
- package/build/workers/types.d.ts +365 -0
- package/build/workers/types.d.ts.map +1 -0
- package/build/workers/types.js +60 -0
- package/build/workers/types.js.map +1 -0
- package/package.json +66 -8
- package/scripts/bundle-ecc.ts +111 -0
- package/src/address.ts +81 -44
- package/src/bech32utils.ts +3 -3
- package/src/bip66.ts +34 -24
- package/src/block.ts +196 -84
- package/src/branded.ts +18 -0
- package/src/crypto.ts +64 -26
- package/src/ecc/context.ts +277 -0
- package/src/ecc/index.ts +14 -0
- package/src/ecc/types.ts +154 -0
- package/src/ecpair.d.ts +99 -0
- package/src/errors.ts +163 -0
- package/src/index.ts +113 -9
- package/src/io/BinaryReader.ts +461 -0
- package/src/io/BinaryWriter.ts +696 -0
- package/src/io/MemoryPool.ts +343 -0
- package/src/io/base64.ts +20 -0
- package/src/io/hex.ts +155 -0
- package/src/io/index.ts +41 -0
- package/src/io/utils.ts +283 -0
- package/src/merkle.ts +14 -9
- package/src/networks.ts +9 -9
- package/src/payments/bip341.ts +34 -33
- package/src/payments/embed.ts +244 -41
- package/src/payments/index.ts +12 -10
- package/src/payments/p2ms.ts +490 -118
- package/src/payments/p2op.ts +431 -133
- package/src/payments/p2pk.ts +370 -72
- package/src/payments/p2pkh.ts +524 -130
- package/src/payments/p2sh.ts +572 -172
- package/src/payments/p2tr.ts +686 -194
- package/src/payments/p2wpkh.ts +484 -107
- package/src/payments/p2wsh.ts +526 -164
- package/src/payments/types.ts +80 -66
- package/src/psbt/bip371.ts +68 -51
- package/src/psbt/psbtutils.ts +39 -40
- package/src/psbt/types.ts +331 -0
- package/src/psbt/utils.ts +188 -0
- package/src/psbt/validation.ts +192 -0
- package/src/psbt.ts +566 -809
- package/src/pubkey.ts +22 -23
- package/src/push_data.ts +18 -16
- package/src/script.ts +82 -64
- package/src/script_number.ts +6 -6
- package/src/script_signature.ts +33 -36
- package/src/transaction.ts +458 -238
- package/src/types.ts +231 -100
- package/src/workers/WorkerSigningPool.node.ts +887 -0
- package/src/workers/WorkerSigningPool.ts +670 -0
- package/src/workers/ecc-bundle.ts +26 -0
- package/src/workers/index.ts +165 -0
- package/src/workers/psbt-parallel.ts +332 -0
- package/src/workers/signing-worker.ts +353 -0
- package/src/workers/types.ts +413 -0
- package/test/address.spec.ts +9 -6
- package/test/bitcoin.core.spec.ts +16 -17
- package/test/block.spec.ts +8 -7
- package/test/bufferutils.spec.ts +228 -214
- package/test/crypto.spec.ts +19 -11
- package/test/fixtures/p2pk.json +0 -8
- package/test/fixtures/p2pkh.json +1 -1
- package/test/fixtures/p2sh.json +1 -1
- package/test/fixtures/script.json +1 -1
- package/test/fixtures/transaction.json +2 -2
- package/test/integration/_regtest.ts +25 -0
- package/test/integration/addresses.spec.ts +4 -3
- package/test/integration/bip32.spec.ts +2 -1
- package/test/integration/blocks.spec.ts +1 -1
- package/test/integration/cltv.spec.ts +18 -16
- package/test/integration/csv.spec.ts +37 -64
- package/test/integration/payments.spec.ts +5 -3
- package/test/integration/taproot.spec.ts +76 -83
- package/test/integration/transactions.spec.ts +38 -35
- package/test/payments.spec.ts +35 -13
- package/test/payments.utils.ts +17 -16
- package/test/psbt.spec.ts +111 -100
- package/test/script.spec.ts +11 -10
- package/test/script_signature.spec.ts +9 -11
- package/test/taproot-cache.spec.ts +694 -0
- package/test/transaction.spec.ts +32 -40
- package/test/types.spec.ts +74 -29
- package/test/workers-pool.spec.ts +963 -0
- package/test/workers-signing.spec.ts +635 -0
- package/test/workers.spec.ts +1390 -0
- package/tsconfig.base.json +34 -18
- package/tsconfig.browser.json +15 -0
- package/tsconfig.build.json +5 -0
- package/tsconfig.json +5 -14
- package/vite.config.browser.ts +3 -42
- package/vitest.config.integration.ts +2 -0
- package/browser/bufferutils.d.ts +0 -34
- package/browser/chunks/crypto-BhCpKpek.js +0 -2033
- package/browser/chunks/payments-B1wlSccx.js +0 -1089
- package/browser/chunks/psbt-BCNk7JUx.js +0 -4055
- package/browser/chunks/script-DyPItFEl.js +0 -318
- package/browser/chunks/transaction-C_UbhMGn.js +0 -432
- package/browser/chunks/utils-DNZi-T5W.js +0 -761
- package/browser/ecc_lib.d.ts +0 -3
- package/browser/hooks/AdvancedSignatureManager.d.ts +0 -16
- package/browser/hooks/HookedSigner.d.ts +0 -4
- package/browser/hooks/SignatureManager.d.ts +0 -13
- package/browser/payments/lazy.d.ts +0 -2
- package/browser/typeforce.d.ts +0 -38
- package/build/bufferutils.d.ts +0 -34
- package/build/bufferutils.js +0 -141
- package/build/ecc_lib.d.ts +0 -3
- package/build/ecc_lib.js +0 -61
- package/build/hooks/AdvancedSignatureManager.d.ts +0 -16
- package/build/hooks/AdvancedSignatureManager.js +0 -52
- package/build/hooks/HookedSigner.d.ts +0 -4
- package/build/hooks/HookedSigner.js +0 -64
- package/build/hooks/SignatureManager.d.ts +0 -13
- package/build/hooks/SignatureManager.js +0 -45
- package/build/payments/lazy.d.ts +0 -2
- package/build/payments/lazy.js +0 -28
- package/build/tsconfig.tsbuildinfo +0 -1
- package/src/bufferutils.ts +0 -188
- package/src/ecc_lib.ts +0 -94
- package/src/hooks/AdvancedSignatureManager.ts +0 -104
- package/src/hooks/HookedSigner.ts +0 -108
- package/src/hooks/SignatureManager.ts +0 -84
- package/src/payments/lazy.ts +0 -28
- package/src/typeforce.d.ts +0 -38
- package/tsconfig.webpack.json +0 -18
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"p2tr.d.ts","sourceRoot":"","sources":["../../src/payments/p2tr.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,EAA8B,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE1E,OAAO,EAGH,KAAK,OAAO,EACZ,KAAK,MAAM,EACX,KAAK,gBAAgB,EACrB,KAAK,OAAO,EACZ,KAAK,cAAc,EACtB,MAAM,aAAa,CAAC;AAWrB,OAAO,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAMhG;;;;;;;;;;;;;;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Y,GAAG,SAAS,CAMrC;IAED;;OAEG;IACH,IAAI,aAAa,IAAI,MAAM,CAM1B;IAED;;;;OAIG;IACH,IAAI,OAAO,IAAI,UAAU,EAAE,GAAG,SAAS,CAMtC;IAID;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,CAAC,kBAAkB,CACrB,cAAc,EAAE,cAAc,EAC9B,UAAU,CAAC,EAAE,OAAO,EACpB,OAAO,CAAC,EAAE,OAAO,GAClB,IAAI;IAIP;;;;;;OAMG;IACH,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI;IAI5D;;;;;;OAMG;IACH,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI;IAI9D;;;;;;;OAOG;IACH,MAAM,CAAC,aAAa,CAChB,SAAS,EAAE,gBAAgB,EAC3B,cAAc,CAAC,EAAE,cAAc,EAC/B,OAAO,CAAC,EAAE,OAAO,GAClB,IAAI;IA+WP;;;;OAIG;IACH,SAAS,IAAI,WAAW;CAgB3B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,WAAW,CA8BlF"}
|
|
@@ -1,2 +1,162 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Network } from '../networks.js';
|
|
2
|
+
import { Bytes20, PublicKey, Script, Signature } from '../types.js';
|
|
3
|
+
import { PaymentType, P2WPKHPayment, PaymentOpts } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Pay-to-Witness-Public-Key-Hash (P2WPKH) payment class.
|
|
6
|
+
*
|
|
7
|
+
* Creates locking scripts of the form: `OP_0 {hash160(pubkey)}`
|
|
8
|
+
* Spending witness: `[{signature}, {pubkey}]`
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { P2WPKH } from '@btc-vision/bitcoin';
|
|
13
|
+
*
|
|
14
|
+
* // Create from public key
|
|
15
|
+
* const payment = P2WPKH.fromPubkey(pubkey);
|
|
16
|
+
* console.log(payment.address); // bc1q... bech32 address
|
|
17
|
+
* console.log(payment.output); // scriptPubKey
|
|
18
|
+
*
|
|
19
|
+
* // Create from bech32 address
|
|
20
|
+
* const fromAddr = P2WPKH.fromAddress('bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4');
|
|
21
|
+
* console.log(fromAddr.hash); // 20-byte witness program
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare class P2WPKH {
|
|
25
|
+
#private;
|
|
26
|
+
static readonly NAME: "p2wpkh";
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new P2WPKH payment instance.
|
|
29
|
+
*
|
|
30
|
+
* @param params - Payment parameters
|
|
31
|
+
* @param params.address - Bech32 encoded address
|
|
32
|
+
* @param params.hash - 20-byte witness program (pubkey hash)
|
|
33
|
+
* @param params.pubkey - The public key (must be 33 bytes compressed)
|
|
34
|
+
* @param params.signature - DER-encoded signature
|
|
35
|
+
* @param params.output - The scriptPubKey
|
|
36
|
+
* @param params.witness - The witness stack [signature, pubkey]
|
|
37
|
+
* @param params.network - Network parameters (defaults to mainnet)
|
|
38
|
+
* @param opts - Payment options
|
|
39
|
+
* @param opts.validate - Whether to validate inputs (default: true)
|
|
40
|
+
*
|
|
41
|
+
* @throws {TypeError} If validation is enabled and data is invalid
|
|
42
|
+
*/
|
|
43
|
+
constructor(params: {
|
|
44
|
+
address?: string | undefined;
|
|
45
|
+
hash?: Uint8Array | undefined;
|
|
46
|
+
pubkey?: Uint8Array | undefined;
|
|
47
|
+
signature?: Uint8Array | undefined;
|
|
48
|
+
output?: Uint8Array | undefined;
|
|
49
|
+
witness?: Uint8Array[] | undefined;
|
|
50
|
+
network?: Network | undefined;
|
|
51
|
+
}, opts?: PaymentOpts);
|
|
52
|
+
/**
|
|
53
|
+
* Payment type discriminant.
|
|
54
|
+
*/
|
|
55
|
+
get name(): typeof PaymentType.P2WPKH;
|
|
56
|
+
/**
|
|
57
|
+
* Network parameters.
|
|
58
|
+
*/
|
|
59
|
+
get network(): Network;
|
|
60
|
+
/**
|
|
61
|
+
* Bech32 encoded address (bc1q... for mainnet).
|
|
62
|
+
*/
|
|
63
|
+
get address(): string | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* 20-byte witness program (RIPEMD160(SHA256(pubkey))).
|
|
66
|
+
*/
|
|
67
|
+
get hash(): Bytes20 | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* The public key (33 bytes compressed).
|
|
70
|
+
*/
|
|
71
|
+
get pubkey(): PublicKey | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* The DER-encoded signature.
|
|
74
|
+
*/
|
|
75
|
+
get signature(): Signature | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* The scriptPubKey: `OP_0 {20-byte hash}`
|
|
78
|
+
*/
|
|
79
|
+
get output(): Script | undefined;
|
|
80
|
+
/**
|
|
81
|
+
* The scriptSig (always empty for native SegWit).
|
|
82
|
+
*/
|
|
83
|
+
get input(): Script | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Witness stack: `[signature, pubkey]`
|
|
86
|
+
*/
|
|
87
|
+
get witness(): Uint8Array[] | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Creates a P2WPKH payment from a compressed public key.
|
|
90
|
+
*
|
|
91
|
+
* @param pubkey - The public key (must be 33 bytes compressed)
|
|
92
|
+
* @param network - Network parameters (defaults to mainnet)
|
|
93
|
+
* @returns A new P2WPKH payment instance
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* const payment = P2WPKH.fromPubkey(pubkey);
|
|
98
|
+
* const address = payment.address; // bc1q...
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
static fromPubkey(pubkey: PublicKey, network?: Network): P2WPKH;
|
|
102
|
+
/**
|
|
103
|
+
* Creates a P2WPKH payment from a bech32 address.
|
|
104
|
+
*
|
|
105
|
+
* @param address - Bech32 encoded address
|
|
106
|
+
* @param network - Network parameters (defaults to mainnet)
|
|
107
|
+
* @returns A new P2WPKH payment instance
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* const payment = P2WPKH.fromAddress('bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4');
|
|
112
|
+
* const hash = payment.hash;
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
static fromAddress(address: string, network?: Network): P2WPKH;
|
|
116
|
+
/**
|
|
117
|
+
* Creates a P2WPKH payment from a 20-byte witness program.
|
|
118
|
+
*
|
|
119
|
+
* @param hash - 20-byte witness program (pubkey hash)
|
|
120
|
+
* @param network - Network parameters (defaults to mainnet)
|
|
121
|
+
* @returns A new P2WPKH payment instance
|
|
122
|
+
*/
|
|
123
|
+
static fromHash(hash: Bytes20, network?: Network): P2WPKH;
|
|
124
|
+
/**
|
|
125
|
+
* Creates a P2WPKH payment from a scriptPubKey.
|
|
126
|
+
*
|
|
127
|
+
* @param output - The scriptPubKey
|
|
128
|
+
* @param network - Network parameters (defaults to mainnet)
|
|
129
|
+
* @returns A new P2WPKH payment instance
|
|
130
|
+
*/
|
|
131
|
+
static fromOutput(output: Uint8Array, network?: Network): P2WPKH;
|
|
132
|
+
/**
|
|
133
|
+
* Converts to a plain P2WPKHPayment object for backwards compatibility.
|
|
134
|
+
*
|
|
135
|
+
* @returns A P2WPKHPayment object
|
|
136
|
+
*/
|
|
137
|
+
toPayment(): P2WPKHPayment;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Creates a Pay-to-Witness-Public-Key-Hash (P2WPKH) payment object.
|
|
141
|
+
*
|
|
142
|
+
* This is the legacy factory function for backwards compatibility.
|
|
143
|
+
* For new code, prefer using the P2WPKH class directly.
|
|
144
|
+
*
|
|
145
|
+
* @param a - The payment object containing the necessary data
|
|
146
|
+
* @param opts - Optional payment options
|
|
147
|
+
* @returns The P2WPKH payment object
|
|
148
|
+
* @throws {TypeError} If the required data is not provided or if the data is invalid
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```typescript
|
|
152
|
+
* import { p2wpkh } from '@btc-vision/bitcoin';
|
|
153
|
+
*
|
|
154
|
+
* // Create from public key
|
|
155
|
+
* const payment = p2wpkh({ pubkey });
|
|
156
|
+
*
|
|
157
|
+
* // Create from address
|
|
158
|
+
* const fromAddr = p2wpkh({ address: 'bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4' });
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
2
161
|
export declare function p2wpkh(a: Omit<P2WPKHPayment, 'name'>, opts?: PaymentOpts): P2WPKHPayment;
|
|
162
|
+
//# sourceMappingURL=p2wpkh.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"p2wpkh.d.ts","sourceRoot":"","sources":["../../src/payments/p2wpkh.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAA8B,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAG1E,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEzE,OAAO,EAAE,WAAW,EAAE,KAAK,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAK/E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,MAAM;;IAEf,MAAM,CAAC,QAAQ,CAAC,IAAI,WAAsB;IAoC1C;;;;;;;;;;;;;;;OAeG;gBAEC,MAAM,EAAE;QACJ,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC7B,IAAI,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;QAC9B,MAAM,CAAC,EAAE,UAAU,GA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,MAAM;IAuLhE;;;;OAIG;IACH,SAAS,IAAI,aAAa;CAa7B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,aAAa,CAoBxF"}
|
|
@@ -1,2 +1,147 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Network } from '../networks.js';
|
|
2
|
+
import { Bytes32, Script } from '../types.js';
|
|
3
|
+
import { P2WSHPayment, PaymentOpts, ScriptRedeem } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Pay-to-Witness-Script-Hash (P2WSH) payment class.
|
|
6
|
+
*
|
|
7
|
+
* Creates locking scripts of the form: `OP_0 {sha256(redeemScript)}`
|
|
8
|
+
* Spending witness: `[{redeemScriptSig...}, {redeemScript}]`
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { P2WSH, P2MS } from '@btc-vision/bitcoin';
|
|
13
|
+
*
|
|
14
|
+
* // Wrap a multisig in P2WSH
|
|
15
|
+
* const multisig = P2MS.fromPubkeys(2, [pubkey1, pubkey2, pubkey3]);
|
|
16
|
+
* const p2wsh = P2WSH.fromRedeem({ output: multisig.output });
|
|
17
|
+
* console.log(p2wsh.address); // bc1q... bech32 address
|
|
18
|
+
*
|
|
19
|
+
* // Decode an existing output
|
|
20
|
+
* const decoded = P2WSH.fromOutput(scriptPubKey);
|
|
21
|
+
* console.log(decoded.hash); // 32-byte witness program
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare class P2WSH {
|
|
25
|
+
#private;
|
|
26
|
+
static readonly NAME: "p2wsh";
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new P2WSH payment instance.
|
|
29
|
+
*
|
|
30
|
+
* @param params - Payment parameters
|
|
31
|
+
* @param params.address - Bech32 encoded address
|
|
32
|
+
* @param params.hash - 32-byte witness program (SHA256 of script)
|
|
33
|
+
* @param params.output - The scriptPubKey
|
|
34
|
+
* @param params.redeem - The redeem script information
|
|
35
|
+
* @param params.witness - The witness stack
|
|
36
|
+
* @param params.network - Network parameters (defaults to mainnet)
|
|
37
|
+
* @param opts - Payment options
|
|
38
|
+
* @param opts.validate - Whether to validate inputs (default: true)
|
|
39
|
+
*
|
|
40
|
+
* @throws {TypeError} If validation is enabled and data is invalid
|
|
41
|
+
*/
|
|
42
|
+
constructor(params: {
|
|
43
|
+
address?: string | undefined;
|
|
44
|
+
hash?: Uint8Array | undefined;
|
|
45
|
+
output?: Uint8Array | undefined;
|
|
46
|
+
redeem?: ScriptRedeem | undefined;
|
|
47
|
+
witness?: Uint8Array[] | undefined;
|
|
48
|
+
network?: Network | undefined;
|
|
49
|
+
}, opts?: PaymentOpts);
|
|
50
|
+
/**
|
|
51
|
+
* Payment type discriminant.
|
|
52
|
+
*/
|
|
53
|
+
get name(): string;
|
|
54
|
+
/**
|
|
55
|
+
* Network parameters.
|
|
56
|
+
*/
|
|
57
|
+
get network(): Network;
|
|
58
|
+
/**
|
|
59
|
+
* Bech32 encoded address (bc1q... for mainnet).
|
|
60
|
+
*/
|
|
61
|
+
get address(): string | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* 32-byte witness program (SHA256 of redeem script).
|
|
64
|
+
*/
|
|
65
|
+
get hash(): Bytes32 | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* The scriptPubKey: `OP_0 {32-byte hash}`
|
|
68
|
+
*/
|
|
69
|
+
get output(): Script | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* The scriptSig (always empty for native SegWit).
|
|
72
|
+
*/
|
|
73
|
+
get input(): Script | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* The redeem script information.
|
|
76
|
+
*/
|
|
77
|
+
get redeem(): ScriptRedeem | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Witness stack: `[{scriptSig...}, {redeemScript}]`
|
|
80
|
+
*/
|
|
81
|
+
get witness(): Uint8Array[] | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* Creates a P2WSH payment from a redeem script.
|
|
84
|
+
*
|
|
85
|
+
* @param redeem - The redeem script information
|
|
86
|
+
* @param network - Network parameters (defaults to mainnet)
|
|
87
|
+
* @returns A new P2WSH payment instance
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* const p2wsh = P2WSH.fromRedeem({ output: redeemScript });
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
static fromRedeem(redeem: ScriptRedeem, network?: Network): P2WSH;
|
|
95
|
+
/**
|
|
96
|
+
* Creates a P2WSH payment from a bech32 address.
|
|
97
|
+
*
|
|
98
|
+
* @param address - Bech32 encoded address
|
|
99
|
+
* @param network - Network parameters (defaults to mainnet)
|
|
100
|
+
* @returns A new P2WSH payment instance
|
|
101
|
+
*/
|
|
102
|
+
static fromAddress(address: string, network?: Network): P2WSH;
|
|
103
|
+
/**
|
|
104
|
+
* Creates a P2WSH payment from a 32-byte witness program.
|
|
105
|
+
*
|
|
106
|
+
* @param hash - 32-byte witness program (SHA256 of script)
|
|
107
|
+
* @param network - Network parameters (defaults to mainnet)
|
|
108
|
+
* @returns A new P2WSH payment instance
|
|
109
|
+
*/
|
|
110
|
+
static fromHash(hash: Bytes32, network?: Network): P2WSH;
|
|
111
|
+
/**
|
|
112
|
+
* Creates a P2WSH payment from a scriptPubKey.
|
|
113
|
+
*
|
|
114
|
+
* @param output - The scriptPubKey
|
|
115
|
+
* @param network - Network parameters (defaults to mainnet)
|
|
116
|
+
* @returns A new P2WSH payment instance
|
|
117
|
+
*/
|
|
118
|
+
static fromOutput(output: Uint8Array, network?: Network): P2WSH;
|
|
119
|
+
/**
|
|
120
|
+
* Converts to a plain P2WSHPayment object for backwards compatibility.
|
|
121
|
+
*
|
|
122
|
+
* @returns A P2WSHPayment object
|
|
123
|
+
*/
|
|
124
|
+
toPayment(): P2WSHPayment;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Creates a Pay-to-Witness-Script-Hash (P2WSH) payment object.
|
|
128
|
+
*
|
|
129
|
+
* This is the legacy factory function for backwards compatibility.
|
|
130
|
+
* For new code, prefer using the P2WSH class directly.
|
|
131
|
+
*
|
|
132
|
+
* @param a - The payment object containing the necessary data
|
|
133
|
+
* @param opts - Optional payment options
|
|
134
|
+
* @returns The P2WSH payment object
|
|
135
|
+
* @throws {TypeError} If the required data is not provided or if the data is invalid
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* import { p2wsh, p2ms } from '@btc-vision/bitcoin';
|
|
140
|
+
*
|
|
141
|
+
* // Wrap a multisig in P2WSH
|
|
142
|
+
* const multisig = p2ms({ m: 2, pubkeys: [pk1, pk2, pk3] });
|
|
143
|
+
* const payment = p2wsh({ redeem: multisig });
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
2
146
|
export declare function p2wsh(a: Omit<P2WSHPayment, 'name'>, opts?: PaymentOpts): P2WSHPayment;
|
|
147
|
+
//# sourceMappingURL=p2wsh.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"p2wsh.d.ts","sourceRoot":"","sources":["../../src/payments/p2wsh.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAA8B,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAG1E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAAe,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAejG;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,KAAK;;IAEd,MAAM,CAAC,QAAQ,CAAC,IAAI,UAAqB;IAqCzC;;;;;;;;;;;;;;OAcG;gBAEC,MAAM,EAAE;QACJ,OAAO,CAAC,EAAE,MAAM,GAAG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AI,YAAY;CAe5B;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,YAAY,CAqBrF"}
|
|
@@ -1,93 +1,123 @@
|
|
|
1
1
|
import { Network } from '../networks.js';
|
|
2
|
-
import { Taptree } from '../types.js';
|
|
3
|
-
export declare
|
|
4
|
-
P2PK
|
|
5
|
-
P2PKH
|
|
6
|
-
P2SH
|
|
7
|
-
P2MS
|
|
8
|
-
P2WPKH
|
|
9
|
-
P2WSH
|
|
10
|
-
P2TR
|
|
11
|
-
P2OP
|
|
12
|
-
Embed
|
|
13
|
-
ScriptRedeem
|
|
14
|
-
}
|
|
2
|
+
import { Bytes20, Bytes32, PublicKey, Script, Signature, SchnorrSignature, Taptree, XOnlyPublicKey } from '../types.js';
|
|
3
|
+
export declare const PaymentType: {
|
|
4
|
+
readonly P2PK: "p2pk";
|
|
5
|
+
readonly P2PKH: "p2pkh";
|
|
6
|
+
readonly P2SH: "p2sh";
|
|
7
|
+
readonly P2MS: "p2ms";
|
|
8
|
+
readonly P2WPKH: "p2wpkh";
|
|
9
|
+
readonly P2WSH: "p2wsh";
|
|
10
|
+
readonly P2TR: "p2tr";
|
|
11
|
+
readonly P2OP: "p2op";
|
|
12
|
+
readonly Embed: "embed";
|
|
13
|
+
readonly ScriptRedeem: "scriptRedeem";
|
|
14
|
+
};
|
|
15
|
+
export type PaymentType = (typeof PaymentType)[keyof typeof PaymentType];
|
|
15
16
|
export interface BasePayment {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
/** Convenience label, also the discriminant for the union. Can be dynamic for nested types. */
|
|
18
|
+
readonly name?: string | undefined;
|
|
19
|
+
/** Network parameters (mainnet if omitted). */
|
|
20
|
+
readonly network?: Network | undefined;
|
|
21
|
+
/** Fully-assembled scriptPubKey (if already known). */
|
|
22
|
+
readonly output?: Script | undefined;
|
|
23
|
+
/** Raw scriptSig (legacy script types only). */
|
|
24
|
+
readonly input?: Script | undefined;
|
|
25
|
+
/** Human-readable address (if already known). */
|
|
26
|
+
readonly address?: string | undefined;
|
|
27
|
+
/** Segwit stack (empty for legacy). */
|
|
28
|
+
readonly witness?: Uint8Array[] | undefined;
|
|
29
|
+
/** Script template for P2SH, P2WSH, P2TR, etc. */
|
|
30
|
+
readonly redeem?: ScriptRedeem | undefined;
|
|
31
|
+
/** Non-standard options used by some wallets. */
|
|
32
|
+
readonly useHybrid?: boolean | undefined;
|
|
33
|
+
readonly useUncompressed?: boolean | undefined;
|
|
25
34
|
}
|
|
35
|
+
/** Helper used by redeeming script-template outputs (P2SH, P2WSH). */
|
|
26
36
|
export interface ScriptRedeem extends BasePayment {
|
|
27
|
-
output?:
|
|
28
|
-
redeemVersion?: number;
|
|
29
|
-
network?: Network;
|
|
37
|
+
readonly output?: Script | undefined;
|
|
38
|
+
readonly redeemVersion?: number | undefined;
|
|
39
|
+
readonly network?: Network | undefined;
|
|
30
40
|
}
|
|
31
41
|
export interface P2PKPayment extends BasePayment {
|
|
32
|
-
name: PaymentType.P2PK;
|
|
33
|
-
pubkey?:
|
|
34
|
-
|
|
42
|
+
readonly name: typeof PaymentType.P2PK;
|
|
43
|
+
readonly pubkey?: PublicKey | undefined;
|
|
44
|
+
/** DER-encoded sig – empty until signed. */
|
|
45
|
+
readonly signature?: Signature | undefined;
|
|
35
46
|
}
|
|
36
47
|
export interface P2PKHPayment extends BasePayment {
|
|
37
|
-
name: PaymentType.P2PKH;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
48
|
+
readonly name: typeof PaymentType.P2PKH;
|
|
49
|
+
/** RIPEMD-160(SHA-256(pubkey)) – 20 bytes. */
|
|
50
|
+
readonly hash?: Bytes20 | undefined;
|
|
51
|
+
readonly pubkey?: PublicKey | undefined;
|
|
52
|
+
readonly signature?: Signature | undefined;
|
|
41
53
|
}
|
|
42
54
|
export interface P2SHPayment extends BasePayment {
|
|
43
|
-
name
|
|
44
|
-
|
|
45
|
-
|
|
55
|
+
/** Dynamic name like 'p2sh' or 'p2sh-p2wpkh' for nested types */
|
|
56
|
+
readonly name: string;
|
|
57
|
+
/** Hash160 of a redeem script. */
|
|
58
|
+
readonly hash?: Bytes20 | undefined;
|
|
59
|
+
/** The entire signature stack when spending a P2SH (non-segwit). */
|
|
60
|
+
readonly signatures?: Uint8Array[] | undefined;
|
|
46
61
|
}
|
|
47
62
|
export interface P2MSPayment extends BasePayment {
|
|
48
|
-
name
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
63
|
+
/** Dynamic name like 'p2ms' or 'p2ms(2 of 3)' with M-of-N parameters */
|
|
64
|
+
readonly name: string;
|
|
65
|
+
/** M-of-N parameters. */
|
|
66
|
+
readonly m?: number | undefined;
|
|
67
|
+
readonly n?: number | undefined;
|
|
68
|
+
readonly pubkeys?: PublicKey[] | undefined;
|
|
69
|
+
readonly signatures?: Signature[] | undefined;
|
|
53
70
|
}
|
|
54
71
|
export interface P2WPKHPayment extends BasePayment {
|
|
55
|
-
name: PaymentType.P2WPKH;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
72
|
+
readonly name: typeof PaymentType.P2WPKH;
|
|
73
|
+
/** 20-byte witness program. */
|
|
74
|
+
readonly hash?: Bytes20 | undefined;
|
|
75
|
+
readonly pubkey?: PublicKey | undefined;
|
|
76
|
+
readonly signature?: Signature | undefined;
|
|
59
77
|
}
|
|
60
78
|
export interface P2WSHPayment extends BasePayment {
|
|
61
|
-
name
|
|
62
|
-
|
|
63
|
-
|
|
79
|
+
/** Dynamic name like 'p2wsh' or 'p2wsh-p2pk' for nested types */
|
|
80
|
+
readonly name: string;
|
|
81
|
+
/** 32-byte witness program. */
|
|
82
|
+
readonly hash?: Bytes32 | undefined;
|
|
83
|
+
readonly redeem?: ScriptRedeem | undefined;
|
|
64
84
|
}
|
|
65
85
|
export interface P2TRPayment extends BasePayment {
|
|
66
|
-
name: PaymentType.P2TR;
|
|
67
|
-
pubkey
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
86
|
+
readonly name: typeof PaymentType.P2TR;
|
|
87
|
+
/** x-only pubkey that commits to the tree. */
|
|
88
|
+
readonly pubkey?: XOnlyPublicKey | undefined;
|
|
89
|
+
/** Internal (untweaked) x-only pubkey. */
|
|
90
|
+
readonly internalPubkey?: XOnlyPublicKey | undefined;
|
|
91
|
+
/** Merkle-root tweak, present when a script path exists. */
|
|
92
|
+
readonly hash?: Bytes32 | undefined;
|
|
93
|
+
/** Full taptree description (optional, dev-side). */
|
|
94
|
+
readonly scriptTree?: Taptree | undefined;
|
|
95
|
+
/** Key-path sig or leading stack elem. */
|
|
96
|
+
readonly signature?: SchnorrSignature | undefined;
|
|
97
|
+
readonly redeemVersion?: number | undefined;
|
|
98
|
+
readonly redeem?: ScriptRedeem | undefined;
|
|
74
99
|
}
|
|
75
100
|
export interface P2OPPayment extends BasePayment {
|
|
76
|
-
name: PaymentType.P2OP;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
101
|
+
readonly name: typeof PaymentType.P2OP;
|
|
102
|
+
/** <deploymentVersion || HASH160(payload)> (2–40 bytes). */
|
|
103
|
+
readonly program?: Uint8Array | undefined;
|
|
104
|
+
readonly deploymentVersion?: number | undefined;
|
|
105
|
+
/** Convenience slice of `program` (20 bytes for current spec). */
|
|
106
|
+
readonly hash160?: Bytes20 | undefined;
|
|
80
107
|
}
|
|
81
108
|
export interface P2OPPaymentParams extends Omit<P2OPPayment, 'name' | 'deploymentVersion'> {
|
|
82
|
-
deploymentVersion?: number;
|
|
109
|
+
readonly deploymentVersion?: number | undefined;
|
|
83
110
|
}
|
|
111
|
+
/** OP_RETURN data-carrying output */
|
|
84
112
|
export interface EmbedPayment extends BasePayment {
|
|
85
|
-
name: PaymentType.Embed;
|
|
86
|
-
|
|
113
|
+
readonly name: typeof PaymentType.Embed;
|
|
114
|
+
/** Raw pushed chunks after OP_RETURN. */
|
|
115
|
+
readonly data: Uint8Array[];
|
|
87
116
|
}
|
|
88
117
|
export type Payment = P2PKPayment | P2PKHPayment | P2SHPayment | P2MSPayment | P2WPKHPayment | P2WSHPayment | P2TRPayment | P2OPPayment | EmbedPayment | ScriptRedeem;
|
|
89
118
|
export type PaymentCreator = <T extends BasePayment>(a: T, opts?: PaymentOpts) => T;
|
|
90
119
|
export interface PaymentOpts {
|
|
91
|
-
validate?: boolean;
|
|
92
|
-
allowIncomplete?: boolean;
|
|
120
|
+
readonly validate?: boolean;
|
|
121
|
+
readonly allowIncomplete?: boolean;
|
|
93
122
|
}
|
|
123
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/payments/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EACR,OAAO,EACP,OAAO,EACP,SAAS,EACT,MAAM,EACN,SAAS,EACT,gBAAgB,EAChB,OAAO,EACP,cAAc,EACjB,MAAM,aAAa,CAAC;AAErB,eAAO,MAAM,WAAW;;;;;;;;;;;CAWd,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAEzE,MAAM,WAAW,WAAW;IACxB,+FAA+F;IAC/F,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,+CAA+C;IAC/C,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACvC,uDAAuD;IACvD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,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AAE,UAAU,EAAE,CAAC;CAE/B;AAED,MAAM,MAAM,OAAO,GACb,WAAW,GACX,YAAY,GACZ,WAAW,GACX,WAAW,GACX,aAAa,GACb,YAAY,GACZ,WAAW,GACX,WAAW,GACX,YAAY,GACZ,YAAY,CAAC;AAEnB,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,SAAS,WAAW,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,CAAC,CAAC;AAEpF,MAAM,WAAW,WAAW;IACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;CACtC"}
|
package/browser/psbt/bip371.d.ts
CHANGED
|
@@ -1,19 +1,45 @@
|
|
|
1
|
-
import { PsbtInput, PsbtOutput, TapLeaf } from 'bip174
|
|
1
|
+
import { PsbtInput, PsbtOutput, TapLeaf } from 'bip174';
|
|
2
2
|
import { Taptree } from '../types.js';
|
|
3
3
|
interface PsbtOutputWithScript extends PsbtOutput {
|
|
4
|
-
script?:
|
|
4
|
+
script?: Uint8Array;
|
|
5
5
|
}
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Default tapscript finalizer. It searches for the `tapLeafHashToFinalize` if provided.
|
|
8
|
+
* Otherwise it will search for the tapleaf that has at least one signature and has the shortest path.
|
|
9
|
+
* @param inputIndex the position of the PSBT input.
|
|
10
|
+
* @param input the PSBT input.
|
|
11
|
+
* @param tapLeafHashToFinalize optional, if provided the finalizer will search for a tapleaf that has this hash
|
|
12
|
+
* and will try to build the finalScriptWitness.
|
|
13
|
+
* @returns the finalScriptWitness or throws an exception if no tapleaf found.
|
|
14
|
+
*/
|
|
15
|
+
export declare function tapScriptFinalizer(inputIndex: number, input: PsbtInput, tapLeafHashToFinalize?: Uint8Array): {
|
|
16
|
+
finalScriptWitness: Uint8Array | undefined;
|
|
8
17
|
};
|
|
9
|
-
export declare function serializeTaprootSignature(sig:
|
|
18
|
+
export declare function serializeTaprootSignature(sig: Uint8Array, sighashType?: number): Uint8Array;
|
|
10
19
|
export declare function isTaprootInput(input: PsbtInput): boolean;
|
|
11
|
-
export declare function isTaprootOutput(output: PsbtOutput, script?:
|
|
20
|
+
export declare function isTaprootOutput(output: PsbtOutput, script?: Uint8Array): boolean;
|
|
12
21
|
export declare function checkTaprootInputFields(inputData: PsbtInput, newInputData: PsbtInput, action: string): void;
|
|
13
22
|
export declare function checkTaprootOutputFields(outputData: PsbtOutputWithScript, newOutputData: PsbtOutput, action: string): void;
|
|
14
|
-
export declare function tweakInternalPubKey(inputIndex: number, input: PsbtInput):
|
|
23
|
+
export declare function tweakInternalPubKey(inputIndex: number, input: PsbtInput): Uint8Array;
|
|
24
|
+
/**
|
|
25
|
+
* Convert a binary tree to a BIP371 type list. Each element of the list is (according to BIP371):
|
|
26
|
+
* One or more tuples representing the depth, leaf version, and script for a leaf in the Taproot tree,
|
|
27
|
+
* allowing the entire tree to be reconstructed. The tuples must be in depth first search order so that
|
|
28
|
+
* the tree is correctly reconstructed.
|
|
29
|
+
* @param tree the binary tap tree
|
|
30
|
+
* @returns a list of BIP 371 tapleaves
|
|
31
|
+
*/
|
|
15
32
|
export declare function tapTreeToList(tree: Taptree): TapLeaf[];
|
|
33
|
+
/**
|
|
34
|
+
* Convert a BIP371 TapLeaf list to a TapTree (binary).
|
|
35
|
+
* @param leaves a list of tapleaves where each element of the list is (according to BIP371):
|
|
36
|
+
* One or more tuples representing the depth, leaf version, and script for a leaf in the Taproot tree,
|
|
37
|
+
* allowing the entire tree to be reconstructed. The tuples must be in depth first search order so that
|
|
38
|
+
* the tree is correctly reconstructed.
|
|
39
|
+
* @returns the corresponding taptree, or throws an exception if the tree cannot be reconstructed
|
|
40
|
+
*/
|
|
16
41
|
export declare function tapTreeFromList(leaves?: TapLeaf[]): Taptree;
|
|
17
42
|
export declare function checkTaprootInputForSigs(input: PsbtInput, action: string): boolean;
|
|
18
|
-
export declare function getTapKeySigFromWitness(finalScriptWitness?:
|
|
43
|
+
export declare function getTapKeySigFromWitness(finalScriptWitness?: Uint8Array): Uint8Array | undefined;
|
|
19
44
|
export {};
|
|
45
|
+
//# sourceMappingURL=bip371.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bip371.d.ts","sourceRoot":"","sources":["../../src/psbt/bip371.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,SAAS,EACT,UAAU,EAEV,OAAO,EAIV,MAAM,QAAQ,CAAC;AAWhB,OAAO,KAAK,EAAW,OAAO,EAA2B,MAAM,aAAa,CAAC;AAS7E,UAAU,oBAAqB,SAAQ,UAAU;IAC7C,MAAM,CAAC,EAAE,UAAU,CAAC;CACvB;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAC9B,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,SAAS,EAChB,qBAAqB,CAAC,EAAE,UAAU,GACnC;IACC,kBAAkB,EAAE,UAAU,GAAG,SAAS,CAAC;CAC9C,CAYA;AAED,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,UAAU,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,UAAU,CAI3F;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAWxD;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,UAAU,GAAG,OAAO,CAUhF;AAED,wBAAgB,uBAAuB,CACnC,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,SAAS,EACvB,MAAM,EAAE,MAAM,GACf,IAAI,CAGN;AAED,wBAAgB,wBAAwB,CACpC,UAAU,EAAE,oBAAoB,EAChC,aAAa,EAAE,UAAU,EACzB,MAAM,EAAE,MAAM,GACf,IAAI,CAGN;AA6BD,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,UAAU,CAgBpF;AAED;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