@btc-vision/transaction 1.8.0-beta.3 → 1.8.0-beta.4
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/browser/_version.d.ts +1 -0
- package/browser/_version.d.ts.map +1 -0
- package/browser/abi/ABICoder.d.ts +1 -1
- package/browser/abi/ABICoder.d.ts.map +1 -0
- package/browser/branded/Branded.d.ts +4 -0
- package/browser/branded/Branded.d.ts.map +1 -0
- package/browser/btc-vision-bitcoin.js +11999 -2647
- package/browser/buffer/BinaryReader.d.ts +120 -1
- package/browser/buffer/BinaryReader.d.ts.map +1 -0
- package/browser/buffer/BinaryWriter.d.ts +51 -1
- package/browser/buffer/BinaryWriter.d.ts.map +1 -0
- package/browser/bytecode/Compressor.d.ts +12 -0
- package/browser/bytecode/Compressor.d.ts.map +1 -0
- package/browser/chain/ChainData.d.ts +2 -2
- package/browser/chain/ChainData.d.ts.map +1 -0
- package/browser/consensus/Consensus.d.ts +11 -3
- package/browser/consensus/Consensus.d.ts.map +1 -0
- package/browser/consensus/ConsensusConfig.d.ts +1 -0
- package/browser/consensus/ConsensusConfig.d.ts.map +1 -0
- package/browser/consensus/IConsensusConfig.d.ts +1 -0
- package/browser/consensus/IConsensusConfig.d.ts.map +1 -0
- package/browser/consensus/metadata/RoswellConsensus.d.ts +1 -0
- package/browser/consensus/metadata/RoswellConsensus.d.ts.map +1 -0
- package/browser/crypto/crypto.d.ts +1 -0
- package/browser/crypto/crypto.d.ts.map +1 -0
- package/browser/deterministic/AddressMap.d.ts +6 -1
- package/browser/deterministic/AddressMap.d.ts.map +1 -0
- package/browser/deterministic/AddressSet.d.ts +3 -1
- package/browser/deterministic/AddressSet.d.ts.map +1 -0
- package/browser/deterministic/CustomMap.d.ts +3 -1
- package/browser/deterministic/CustomMap.d.ts.map +1 -0
- package/browser/deterministic/DeterministicMap.d.ts +3 -1
- package/browser/deterministic/DeterministicMap.d.ts.map +1 -0
- package/browser/deterministic/DeterministicSet.d.ts +3 -1
- package/browser/deterministic/DeterministicSet.d.ts.map +1 -0
- package/browser/deterministic/ExtendedAddressMap.d.ts +7 -1
- package/browser/deterministic/ExtendedAddressMap.d.ts.map +1 -0
- package/browser/deterministic/FastMap.d.ts +7 -1
- package/browser/deterministic/FastMap.d.ts.map +1 -0
- package/browser/ecc/backend.d.ts +13 -0
- package/browser/ecc/backend.d.ts.map +1 -0
- package/browser/epoch/ChallengeSolution.d.ts +33 -1
- package/browser/epoch/ChallengeSolution.d.ts.map +1 -0
- package/browser/epoch/interfaces/IChallengeSolution.d.ts +14 -13
- package/browser/epoch/interfaces/IChallengeSolution.d.ts.map +1 -0
- package/browser/epoch/validator/EpochValidator.d.ts +37 -7
- package/browser/epoch/validator/EpochValidator.d.ts.map +1 -0
- package/browser/event/NetEvent.d.ts +1 -0
- package/browser/event/NetEvent.d.ts.map +1 -0
- package/browser/generators/AddressGenerator.d.ts +4 -3
- package/browser/generators/AddressGenerator.d.ts.map +1 -0
- package/browser/generators/Features.d.ts +1 -0
- package/browser/generators/Features.d.ts.map +1 -0
- package/browser/generators/Generator.d.ts +46 -10
- package/browser/generators/Generator.d.ts.map +1 -0
- package/browser/generators/MLDSAData.d.ts +1 -0
- package/browser/generators/MLDSAData.d.ts.map +1 -0
- package/browser/generators/builders/CalldataGenerator.d.ts +25 -4
- package/browser/generators/builders/CalldataGenerator.d.ts.map +1 -0
- package/browser/generators/builders/CustomGenerator.d.ts +13 -3
- package/browser/generators/builders/CustomGenerator.d.ts.map +1 -0
- package/browser/generators/builders/DeploymentGenerator.d.ts +15 -4
- package/browser/generators/builders/DeploymentGenerator.d.ts.map +1 -0
- package/browser/generators/builders/HashCommitmentGenerator.d.ts +164 -12
- package/browser/generators/builders/HashCommitmentGenerator.d.ts.map +1 -0
- package/browser/generators/builders/LegacyCalldataGenerator.d.ts +26 -4
- package/browser/generators/builders/LegacyCalldataGenerator.d.ts.map +1 -0
- package/browser/generators/builders/MultiSignGenerator.d.ts +6 -1
- package/browser/generators/builders/MultiSignGenerator.d.ts.map +1 -0
- package/browser/generators/builders/P2WDAGenerator.d.ts +42 -4
- package/browser/generators/builders/P2WDAGenerator.d.ts.map +1 -0
- package/browser/index.d.ts +1 -0
- package/browser/index.d.ts.map +1 -0
- package/browser/index.js +3583 -3184
- package/browser/keypair/Address.d.ts +283 -13
- package/browser/keypair/Address.d.ts.map +1 -0
- package/browser/keypair/AddressVerificator.d.ts +7 -6
- package/browser/keypair/AddressVerificator.d.ts.map +1 -0
- package/browser/keypair/EcKeyPair.d.ts +183 -21
- package/browser/keypair/EcKeyPair.d.ts.map +1 -0
- package/browser/keypair/MessageSigner.d.ts +17 -16
- package/browser/keypair/MessageSigner.d.ts.map +1 -0
- package/browser/keypair/Secp256k1PointDeriver.d.ts +55 -0
- package/browser/keypair/Secp256k1PointDeriver.d.ts.map +1 -0
- package/browser/keypair/Wallet.d.ts +27 -13
- package/browser/keypair/Wallet.d.ts.map +1 -0
- package/browser/keypair/interfaces/IWallet.d.ts +19 -0
- package/browser/keypair/interfaces/IWallet.d.ts.map +1 -0
- package/browser/metadata/ContractBaseMetadata.d.ts +10 -2
- package/browser/metadata/ContractBaseMetadata.d.ts.map +1 -0
- package/browser/mnemonic/BIPStandard.d.ts +59 -0
- package/browser/mnemonic/BIPStandard.d.ts.map +1 -0
- package/browser/mnemonic/Mnemonic.d.ts +15 -3
- package/browser/mnemonic/Mnemonic.d.ts.map +1 -0
- package/browser/mnemonic/MnemonicStrength.d.ts +6 -0
- package/browser/mnemonic/MnemonicStrength.d.ts.map +1 -0
- package/browser/network/ChainId.d.ts +1 -0
- package/browser/network/ChainId.d.ts.map +1 -0
- package/browser/noble-curves.js +844 -2746
- package/browser/noble-hashes.js +1338 -2067
- package/browser/opnet.d.ts +22 -1
- package/browser/opnet.d.ts.map +1 -0
- package/browser/p2wda/P2WDADetector.d.ts +36 -9
- package/browser/p2wda/P2WDADetector.d.ts.map +1 -0
- package/browser/polyfill/disposable.d.ts +16 -0
- package/browser/polyfill/disposable.d.ts.map +1 -0
- package/browser/signer/AddressRotation.d.ts +36 -0
- package/browser/signer/AddressRotation.d.ts.map +1 -0
- package/browser/signer/IRotationSigner.d.ts +27 -3
- package/browser/signer/IRotationSigner.d.ts.map +1 -0
- package/browser/signer/ParallelSignerAdapter.d.ts +14 -0
- package/browser/signer/ParallelSignerAdapter.d.ts.map +1 -0
- package/browser/signer/SignerUtils.d.ts +11 -4
- package/browser/signer/SignerUtils.d.ts.map +1 -0
- package/browser/signer/TweakedSigner.d.ts +28 -4
- package/browser/signer/TweakedSigner.d.ts.map +1 -0
- package/browser/transaction/ContractAddress.d.ts +2 -2
- package/browser/transaction/ContractAddress.d.ts.map +1 -0
- package/browser/transaction/TransactionFactory.d.ts +140 -2
- package/browser/transaction/TransactionFactory.d.ts.map +1 -0
- package/browser/transaction/browser/BrowserSignerBase.d.ts +12 -6
- package/browser/transaction/browser/BrowserSignerBase.d.ts.map +1 -0
- package/browser/transaction/browser/WalletNetworks.d.ts +1 -0
- package/browser/transaction/browser/WalletNetworks.d.ts.map +1 -0
- package/browser/transaction/browser/Web3Provider.d.ts +27 -0
- package/browser/transaction/browser/Web3Provider.d.ts.map +1 -0
- package/browser/transaction/browser/extensions/UnisatSigner.d.ts +9 -7
- package/browser/transaction/browser/extensions/UnisatSigner.d.ts.map +1 -0
- package/browser/transaction/browser/extensions/XverseSigner.d.ts +9 -7
- package/browser/transaction/browser/extensions/XverseSigner.d.ts.map +1 -0
- package/browser/transaction/browser/types/OPWallet.d.ts +10 -0
- package/browser/transaction/browser/types/OPWallet.d.ts.map +1 -0
- package/browser/transaction/browser/types/Unisat.d.ts +1 -0
- package/browser/transaction/browser/types/Unisat.d.ts.map +1 -0
- package/browser/transaction/browser/types/Xverse.d.ts +1 -0
- package/browser/transaction/browser/types/Xverse.d.ts.map +1 -0
- package/browser/transaction/builders/CancelTransaction.d.ts +29 -4
- package/browser/transaction/builders/CancelTransaction.d.ts.map +1 -0
- package/browser/transaction/builders/ChallengeSolutionTransaction.d.ts +1 -0
- package/browser/transaction/builders/ChallengeSolutionTransaction.d.ts.map +1 -0
- package/browser/transaction/builders/ConsolidatedInteractionTransaction.d.ts +137 -10
- package/browser/transaction/builders/ConsolidatedInteractionTransaction.d.ts.map +1 -0
- package/browser/transaction/builders/CustomScriptTransaction.d.ts +106 -6
- package/browser/transaction/builders/CustomScriptTransaction.d.ts.map +1 -0
- package/browser/transaction/builders/DeploymentTransaction.d.ts +116 -5
- package/browser/transaction/builders/DeploymentTransaction.d.ts.map +1 -0
- package/browser/transaction/builders/FundingTransaction.d.ts +4 -3
- package/browser/transaction/builders/FundingTransaction.d.ts.map +1 -0
- package/browser/transaction/builders/InteractionTransaction.d.ts +12 -3
- package/browser/transaction/builders/InteractionTransaction.d.ts.map +1 -0
- package/browser/transaction/builders/InteractionTransactionP2WDA.d.ts +56 -5
- package/browser/transaction/builders/InteractionTransactionP2WDA.d.ts.map +1 -0
- package/browser/transaction/builders/MultiSignTransaction.d.ts +125 -16
- package/browser/transaction/builders/MultiSignTransaction.d.ts.map +1 -0
- package/browser/transaction/builders/SharedInteractionTransaction.d.ts +103 -15
- package/browser/transaction/builders/SharedInteractionTransaction.d.ts.map +1 -0
- package/browser/transaction/builders/TransactionBuilder.d.ts +243 -14
- package/browser/transaction/builders/TransactionBuilder.d.ts.map +1 -0
- package/browser/transaction/enums/TransactionType.d.ts +1 -0
- package/browser/transaction/enums/TransactionType.d.ts.map +1 -0
- package/browser/transaction/interfaces/ICancelTransactionParameters.d.ts +2 -1
- package/browser/transaction/interfaces/ICancelTransactionParameters.d.ts.map +1 -0
- package/browser/transaction/interfaces/IConsolidatedTransactionParameters.d.ts +46 -3
- package/browser/transaction/interfaces/IConsolidatedTransactionParameters.d.ts.map +1 -0
- package/browser/transaction/interfaces/ICustomTransactionParameters.d.ts +6 -4
- package/browser/transaction/interfaces/ICustomTransactionParameters.d.ts.map +1 -0
- package/browser/transaction/interfaces/ITransactionParameters.d.ts +22 -10
- package/browser/transaction/interfaces/ITransactionParameters.d.ts.map +1 -0
- package/browser/transaction/interfaces/ITransactionResponses.d.ts +1 -0
- package/browser/transaction/interfaces/ITransactionResponses.d.ts.map +1 -0
- package/browser/transaction/interfaces/ITweakedTransactionData.d.ts +18 -5
- package/browser/transaction/interfaces/ITweakedTransactionData.d.ts.map +1 -0
- package/browser/transaction/interfaces/IWeb3ProviderTypes.d.ts +26 -0
- package/browser/transaction/interfaces/IWeb3ProviderTypes.d.ts.map +1 -0
- package/browser/transaction/interfaces/Tap.d.ts +4 -3
- package/browser/transaction/interfaces/Tap.d.ts.map +1 -0
- package/browser/transaction/mineable/IP2WSHAddress.d.ts +2 -1
- package/browser/transaction/mineable/IP2WSHAddress.d.ts.map +1 -0
- package/browser/transaction/mineable/TimelockGenerator.d.ts +12 -3
- package/browser/transaction/mineable/TimelockGenerator.d.ts.map +1 -0
- package/browser/transaction/offline/OfflineTransactionManager.d.ts +190 -9
- package/browser/transaction/offline/OfflineTransactionManager.d.ts.map +1 -0
- package/browser/transaction/offline/TransactionReconstructor.d.ts +53 -3
- package/browser/transaction/offline/TransactionReconstructor.d.ts.map +1 -0
- package/browser/transaction/offline/TransactionSerializer.d.ts +53 -2
- package/browser/transaction/offline/TransactionSerializer.d.ts.map +1 -0
- package/browser/transaction/offline/TransactionStateCapture.d.ts +64 -5
- package/browser/transaction/offline/TransactionStateCapture.d.ts.map +1 -0
- package/browser/transaction/offline/interfaces/ISerializableState.d.ts +71 -0
- package/browser/transaction/offline/interfaces/ISerializableState.d.ts.map +1 -0
- package/browser/transaction/offline/interfaces/ITypeSpecificData.d.ts +76 -0
- package/browser/transaction/offline/interfaces/ITypeSpecificData.d.ts.map +1 -0
- package/browser/transaction/psbt/PSBTTypes.d.ts +1 -0
- package/browser/transaction/psbt/PSBTTypes.d.ts.map +1 -0
- package/browser/transaction/shared/P2TR_MS.d.ts +11 -2
- package/browser/transaction/shared/P2TR_MS.d.ts.map +1 -0
- package/browser/transaction/shared/TweakedTransaction.d.ts +275 -33
- package/browser/transaction/shared/TweakedTransaction.d.ts.map +1 -0
- package/browser/transaction/utils/WitnessUtils.d.ts +7 -1
- package/browser/transaction/utils/WitnessUtils.d.ts.map +1 -0
- package/browser/utils/BitcoinUtils.d.ts +19 -0
- package/browser/utils/BitcoinUtils.d.ts.map +1 -0
- package/browser/utils/BufferHelper.d.ts +1 -0
- package/browser/utils/BufferHelper.d.ts.map +1 -0
- package/browser/utils/StringToBuffer.d.ts +1 -0
- package/browser/utils/StringToBuffer.d.ts.map +1 -0
- package/browser/utils/lengths.d.ts +1 -0
- package/browser/utils/lengths.d.ts.map +1 -0
- package/browser/utils/types.d.ts +1 -0
- package/browser/utils/types.d.ts.map +1 -0
- package/browser/utxo/OPNetLimitedProvider.d.ts +37 -1
- package/browser/utxo/OPNetLimitedProvider.d.ts.map +1 -0
- package/browser/utxo/interfaces/BroadcastResponse.d.ts +1 -0
- package/browser/utxo/interfaces/BroadcastResponse.d.ts.map +1 -0
- package/browser/utxo/interfaces/IUTXO.d.ts +11 -5
- package/browser/utxo/interfaces/IUTXO.d.ts.map +1 -0
- package/browser/vendors.js +14351 -10031
- package/browser/verification/TapscriptVerificator.d.ts +10 -8
- package/browser/verification/TapscriptVerificator.d.ts.map +1 -0
- package/build/_version.d.ts +1 -0
- package/build/_version.d.ts.map +1 -0
- package/build/_version.js +1 -0
- package/build/_version.js.map +1 -0
- package/build/abi/ABICoder.d.ts +1 -1
- package/build/abi/ABICoder.d.ts.map +1 -0
- package/build/abi/ABICoder.js +9 -10
- package/build/abi/ABICoder.js.map +1 -0
- package/build/branded/Branded.d.ts +4 -0
- package/build/branded/Branded.d.ts.map +1 -0
- package/build/branded/Branded.js +2 -0
- package/build/branded/Branded.js.map +1 -0
- package/build/buffer/BinaryReader.d.ts +121 -2
- package/build/buffer/BinaryReader.d.ts.map +1 -0
- package/build/buffer/BinaryReader.js +129 -5
- package/build/buffer/BinaryReader.js.map +1 -0
- package/build/buffer/BinaryWriter.d.ts +52 -2
- package/build/buffer/BinaryWriter.d.ts.map +1 -0
- package/build/buffer/BinaryWriter.js +62 -2
- package/build/buffer/BinaryWriter.js.map +1 -0
- package/build/bytecode/Compressor.d.ts +12 -0
- package/build/bytecode/Compressor.d.ts.map +1 -0
- package/build/bytecode/Compressor.js +17 -5
- package/build/bytecode/Compressor.js.map +1 -0
- package/build/chain/ChainData.d.ts +2 -2
- package/build/chain/ChainData.d.ts.map +1 -0
- package/build/chain/ChainData.js +35 -17
- package/build/chain/ChainData.js.map +1 -0
- package/build/consensus/Consensus.d.ts +11 -3
- package/build/consensus/Consensus.d.ts.map +1 -0
- package/build/consensus/Consensus.js +8 -0
- package/build/consensus/Consensus.js.map +1 -0
- package/build/consensus/ConsensusConfig.d.ts +2 -1
- package/build/consensus/ConsensusConfig.d.ts.map +1 -0
- package/build/consensus/ConsensusConfig.js +1 -0
- package/build/consensus/ConsensusConfig.js.map +1 -0
- package/build/consensus/IConsensusConfig.d.ts +1 -0
- package/build/consensus/IConsensusConfig.d.ts.map +1 -0
- package/build/consensus/IConsensusConfig.js +2 -1
- package/build/consensus/IConsensusConfig.js.map +1 -0
- package/build/consensus/metadata/RoswellConsensus.d.ts +2 -1
- package/build/consensus/metadata/RoswellConsensus.d.ts.map +1 -0
- package/build/consensus/metadata/RoswellConsensus.js +2 -0
- package/build/consensus/metadata/RoswellConsensus.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/deterministic/AddressMap.d.ts +6 -1
- package/build/deterministic/AddressMap.d.ts.map +1 -0
- package/build/deterministic/AddressMap.js +8 -0
- package/build/deterministic/AddressMap.js.map +1 -0
- package/build/deterministic/AddressSet.d.ts +3 -1
- package/build/deterministic/AddressSet.d.ts.map +1 -0
- package/build/deterministic/AddressSet.js +7 -0
- package/build/deterministic/AddressSet.js.map +1 -0
- package/build/deterministic/CustomMap.d.ts +3 -1
- package/build/deterministic/CustomMap.d.ts.map +1 -0
- package/build/deterministic/CustomMap.js +65 -47
- package/build/deterministic/CustomMap.js.map +1 -0
- package/build/deterministic/DeterministicMap.d.ts +4 -2
- package/build/deterministic/DeterministicMap.d.ts.map +1 -0
- package/build/deterministic/DeterministicMap.js +24 -27
- package/build/deterministic/DeterministicMap.js.map +1 -0
- package/build/deterministic/DeterministicSet.d.ts +3 -1
- package/build/deterministic/DeterministicSet.d.ts.map +1 -0
- package/build/deterministic/DeterministicSet.js +6 -0
- package/build/deterministic/DeterministicSet.js.map +1 -0
- package/build/deterministic/ExtendedAddressMap.d.ts +7 -1
- package/build/deterministic/ExtendedAddressMap.d.ts.map +1 -0
- package/build/deterministic/ExtendedAddressMap.js +18 -2
- package/build/deterministic/ExtendedAddressMap.js.map +1 -0
- package/build/deterministic/FastMap.d.ts +7 -1
- package/build/deterministic/FastMap.d.ts.map +1 -0
- package/build/deterministic/FastMap.js +7 -2
- package/build/deterministic/FastMap.js.map +1 -0
- package/build/ecc/backend.d.ts +13 -0
- package/build/ecc/backend.d.ts.map +1 -0
- package/build/ecc/backend.js +15 -0
- package/build/ecc/backend.js.map +1 -0
- package/build/epoch/ChallengeSolution.d.ts +34 -2
- package/build/epoch/ChallengeSolution.d.ts.map +1 -0
- package/build/epoch/ChallengeSolution.js +52 -0
- package/build/epoch/ChallengeSolution.js.map +1 -0
- package/build/epoch/interfaces/IChallengeSolution.d.ts +14 -13
- package/build/epoch/interfaces/IChallengeSolution.d.ts.map +1 -0
- package/build/epoch/interfaces/IChallengeSolution.js +2 -1
- package/build/epoch/interfaces/IChallengeSolution.js.map +1 -0
- package/build/epoch/validator/EpochValidator.d.ts +38 -8
- package/build/epoch/validator/EpochValidator.d.ts.map +1 -0
- package/build/epoch/validator/EpochValidator.js +45 -19
- package/build/epoch/validator/EpochValidator.js.map +1 -0
- package/build/event/NetEvent.d.ts +1 -0
- package/build/event/NetEvent.d.ts.map +1 -0
- package/build/event/NetEvent.js +3 -0
- package/build/event/NetEvent.js.map +1 -0
- package/build/generators/AddressGenerator.d.ts +4 -3
- package/build/generators/AddressGenerator.d.ts.map +1 -0
- package/build/generators/AddressGenerator.js +10 -3
- package/build/generators/AddressGenerator.js.map +1 -0
- package/build/generators/Features.d.ts +4 -3
- package/build/generators/Features.d.ts.map +1 -0
- package/build/generators/Features.js +1 -0
- package/build/generators/Features.js.map +1 -0
- package/build/generators/Generator.d.ts +47 -11
- package/build/generators/Generator.d.ts.map +1 -0
- package/build/generators/Generator.js +48 -12
- package/build/generators/Generator.js.map +1 -0
- package/build/generators/MLDSAData.d.ts +1 -0
- package/build/generators/MLDSAData.d.ts.map +1 -0
- package/build/generators/MLDSAData.js +1 -0
- package/build/generators/MLDSAData.js.map +1 -0
- package/build/generators/builders/CalldataGenerator.d.ts +27 -6
- package/build/generators/builders/CalldataGenerator.d.ts.map +1 -0
- package/build/generators/builders/CalldataGenerator.js +33 -4
- package/build/generators/builders/CalldataGenerator.js.map +1 -0
- package/build/generators/builders/CustomGenerator.d.ts +13 -3
- package/build/generators/builders/CustomGenerator.d.ts.map +1 -0
- package/build/generators/builders/CustomGenerator.js +11 -0
- package/build/generators/builders/CustomGenerator.js.map +1 -0
- package/build/generators/builders/DeploymentGenerator.d.ts +17 -6
- package/build/generators/builders/DeploymentGenerator.d.ts.map +1 -0
- package/build/generators/builders/DeploymentGenerator.js +18 -2
- package/build/generators/builders/DeploymentGenerator.js.map +1 -0
- package/build/generators/builders/HashCommitmentGenerator.d.ts +166 -14
- package/build/generators/builders/HashCommitmentGenerator.d.ts.map +1 -0
- package/build/generators/builders/HashCommitmentGenerator.js +193 -27
- package/build/generators/builders/HashCommitmentGenerator.js.map +1 -0
- package/build/generators/builders/LegacyCalldataGenerator.d.ts +27 -5
- package/build/generators/builders/LegacyCalldataGenerator.d.ts.map +1 -0
- package/build/generators/builders/LegacyCalldataGenerator.js +35 -5
- package/build/generators/builders/LegacyCalldataGenerator.js.map +1 -0
- package/build/generators/builders/MultiSignGenerator.d.ts +6 -1
- package/build/generators/builders/MultiSignGenerator.d.ts.map +1 -0
- package/build/generators/builders/MultiSignGenerator.js +20 -10
- package/build/generators/builders/MultiSignGenerator.js.map +1 -0
- package/build/generators/builders/P2WDAGenerator.d.ts +44 -6
- package/build/generators/builders/P2WDAGenerator.d.ts.map +1 -0
- package/build/generators/builders/P2WDAGenerator.js +41 -2
- package/build/generators/builders/P2WDAGenerator.js.map +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +1 -0
- package/build/index.js.map +1 -0
- package/build/keypair/Address.d.ts +284 -14
- package/build/keypair/Address.d.ts.map +1 -0
- package/build/keypair/Address.js +446 -128
- package/build/keypair/Address.js.map +1 -0
- package/build/keypair/AddressVerificator.d.ts +7 -6
- package/build/keypair/AddressVerificator.d.ts.map +1 -0
- package/build/keypair/AddressVerificator.js +6 -5
- package/build/keypair/AddressVerificator.js.map +1 -0
- package/build/keypair/EcKeyPair.d.ts +185 -23
- package/build/keypair/EcKeyPair.d.ts.map +1 -0
- package/build/keypair/EcKeyPair.js +219 -50
- package/build/keypair/EcKeyPair.js.map +1 -0
- package/build/keypair/MessageSigner.d.ts +18 -17
- package/build/keypair/MessageSigner.d.ts.map +1 -0
- package/build/keypair/MessageSigner.js +34 -25
- package/build/keypair/MessageSigner.js.map +1 -0
- package/build/keypair/Secp256k1PointDeriver.d.ts +55 -0
- package/build/keypair/Secp256k1PointDeriver.d.ts.map +1 -0
- package/build/keypair/Secp256k1PointDeriver.js +66 -0
- package/build/keypair/Secp256k1PointDeriver.js.map +1 -0
- package/build/keypair/Wallet.d.ts +29 -15
- package/build/keypair/Wallet.d.ts.map +1 -0
- package/build/keypair/Wallet.js +48 -14
- package/build/keypair/Wallet.js.map +1 -0
- package/build/keypair/interfaces/IWallet.d.ts +19 -0
- package/build/keypair/interfaces/IWallet.d.ts.map +1 -0
- package/build/keypair/interfaces/IWallet.js +1 -0
- package/build/keypair/interfaces/IWallet.js.map +1 -0
- package/build/metadata/ContractBaseMetadata.d.ts +10 -2
- package/build/metadata/ContractBaseMetadata.d.ts.map +1 -0
- package/build/metadata/ContractBaseMetadata.js +10 -1
- package/build/metadata/ContractBaseMetadata.js.map +1 -0
- package/build/mnemonic/BIPStandard.d.ts +59 -0
- package/build/mnemonic/BIPStandard.d.ts.map +1 -0
- package/build/mnemonic/BIPStandard.js +59 -0
- package/build/mnemonic/BIPStandard.js.map +1 -0
- package/build/mnemonic/Mnemonic.d.ts +16 -4
- package/build/mnemonic/Mnemonic.d.ts.map +1 -0
- package/build/mnemonic/Mnemonic.js +36 -8
- package/build/mnemonic/Mnemonic.js.map +1 -0
- package/build/mnemonic/MnemonicStrength.d.ts +6 -0
- package/build/mnemonic/MnemonicStrength.d.ts.map +1 -0
- package/build/mnemonic/MnemonicStrength.js +6 -0
- package/build/mnemonic/MnemonicStrength.js.map +1 -0
- package/build/network/ChainId.d.ts +1 -0
- package/build/network/ChainId.d.ts.map +1 -0
- package/build/network/ChainId.js +1 -0
- package/build/network/ChainId.js.map +1 -0
- package/build/opnet.d.ts +26 -3
- package/build/opnet.d.ts.map +1 -0
- package/build/opnet.js +23 -0
- package/build/opnet.js.map +1 -0
- package/build/p2wda/P2WDADetector.d.ts +38 -11
- package/build/p2wda/P2WDADetector.d.ts.map +1 -0
- package/build/p2wda/P2WDADetector.js +43 -10
- package/build/p2wda/P2WDADetector.js.map +1 -0
- package/build/polyfill/disposable.d.ts +16 -0
- package/build/polyfill/disposable.d.ts.map +1 -0
- package/build/polyfill/disposable.js +23 -0
- package/build/polyfill/disposable.js.map +1 -0
- package/build/signer/AddressRotation.d.ts +37 -1
- package/build/signer/AddressRotation.d.ts.map +1 -0
- package/build/signer/AddressRotation.js +16 -0
- package/build/signer/AddressRotation.js.map +1 -0
- package/build/signer/IRotationSigner.d.ts +27 -3
- package/build/signer/IRotationSigner.d.ts.map +1 -0
- package/build/signer/IRotationSigner.js +2 -1
- package/build/signer/IRotationSigner.js.map +1 -0
- package/build/signer/ParallelSignerAdapter.d.ts +14 -0
- package/build/signer/ParallelSignerAdapter.d.ts.map +1 -0
- package/build/signer/ParallelSignerAdapter.js +51 -0
- package/build/signer/ParallelSignerAdapter.js.map +1 -0
- package/build/signer/SignerUtils.d.ts +11 -4
- package/build/signer/SignerUtils.d.ts.map +1 -0
- package/build/signer/SignerUtils.js +16 -0
- package/build/signer/SignerUtils.js.map +1 -0
- package/build/signer/TweakedSigner.d.ts +28 -4
- package/build/signer/TweakedSigner.d.ts.map +1 -0
- package/build/signer/TweakedSigner.js +24 -6
- package/build/signer/TweakedSigner.js.map +1 -0
- package/build/transaction/ContractAddress.d.ts +2 -2
- package/build/transaction/ContractAddress.d.ts.map +1 -0
- package/build/transaction/ContractAddress.js +4 -8
- package/build/transaction/ContractAddress.js.map +1 -0
- package/build/transaction/TransactionFactory.d.ts +147 -9
- package/build/transaction/TransactionFactory.d.ts.map +1 -0
- package/build/transaction/TransactionFactory.js +145 -26
- package/build/transaction/TransactionFactory.js.map +1 -0
- package/build/transaction/browser/BrowserSignerBase.d.ts +12 -6
- package/build/transaction/browser/BrowserSignerBase.d.ts.map +1 -0
- package/build/transaction/browser/BrowserSignerBase.js +7 -0
- package/build/transaction/browser/BrowserSignerBase.js.map +1 -0
- package/build/transaction/browser/WalletNetworks.d.ts +1 -0
- package/build/transaction/browser/WalletNetworks.d.ts.map +1 -0
- package/build/transaction/browser/WalletNetworks.js +1 -0
- package/build/transaction/browser/WalletNetworks.js.map +1 -0
- package/build/transaction/browser/Web3Provider.d.ts +30 -3
- package/build/transaction/browser/Web3Provider.d.ts.map +1 -0
- package/build/transaction/browser/Web3Provider.js +1 -0
- package/build/transaction/browser/Web3Provider.js.map +1 -0
- package/build/transaction/browser/extensions/UnisatSigner.d.ts +11 -9
- package/build/transaction/browser/extensions/UnisatSigner.d.ts.map +1 -0
- package/build/transaction/browser/extensions/UnisatSigner.js +27 -17
- package/build/transaction/browser/extensions/UnisatSigner.js.map +1 -0
- package/build/transaction/browser/extensions/XverseSigner.d.ts +10 -8
- package/build/transaction/browser/extensions/XverseSigner.d.ts.map +1 -0
- package/build/transaction/browser/extensions/XverseSigner.js +25 -15
- package/build/transaction/browser/extensions/XverseSigner.js.map +1 -0
- package/build/transaction/browser/types/OPWallet.d.ts +12 -2
- package/build/transaction/browser/types/OPWallet.d.ts.map +1 -0
- package/build/transaction/browser/types/OPWallet.js +4 -0
- package/build/transaction/browser/types/OPWallet.js.map +1 -0
- package/build/transaction/browser/types/Unisat.d.ts +2 -1
- package/build/transaction/browser/types/Unisat.d.ts.map +1 -0
- package/build/transaction/browser/types/Unisat.js +2 -0
- package/build/transaction/browser/types/Unisat.js.map +1 -0
- package/build/transaction/browser/types/Xverse.d.ts +1 -0
- package/build/transaction/browser/types/Xverse.d.ts.map +1 -0
- package/build/transaction/browser/types/Xverse.js +1 -0
- package/build/transaction/browser/types/Xverse.js.map +1 -0
- package/build/transaction/builders/CancelTransaction.d.ts +31 -6
- package/build/transaction/builders/CancelTransaction.d.ts.map +1 -0
- package/build/transaction/builders/CancelTransaction.js +116 -33
- package/build/transaction/builders/CancelTransaction.js.map +1 -0
- package/build/transaction/builders/ChallengeSolutionTransaction.d.ts +1 -0
- package/build/transaction/builders/ChallengeSolutionTransaction.d.ts.map +1 -0
- package/build/transaction/builders/ChallengeSolutionTransaction.js +88 -0
- package/build/transaction/builders/ChallengeSolutionTransaction.js.map +1 -0
- package/build/transaction/builders/ConsolidatedInteractionTransaction.d.ts +140 -13
- package/build/transaction/builders/ConsolidatedInteractionTransaction.d.ts.map +1 -0
- package/build/transaction/builders/ConsolidatedInteractionTransaction.js +197 -20
- package/build/transaction/builders/ConsolidatedInteractionTransaction.js.map +1 -0
- package/build/transaction/builders/CustomScriptTransaction.d.ts +108 -8
- package/build/transaction/builders/CustomScriptTransaction.d.ts.map +1 -0
- package/build/transaction/builders/CustomScriptTransaction.js +176 -39
- package/build/transaction/builders/CustomScriptTransaction.js.map +1 -0
- package/build/transaction/builders/DeploymentTransaction.d.ts +120 -9
- package/build/transaction/builders/DeploymentTransaction.d.ts.map +1 -0
- package/build/transaction/builders/DeploymentTransaction.js +194 -51
- package/build/transaction/builders/DeploymentTransaction.js.map +1 -0
- package/build/transaction/builders/FundingTransaction.d.ts +5 -4
- package/build/transaction/builders/FundingTransaction.d.ts.map +1 -0
- package/build/transaction/builders/FundingTransaction.js +15 -8
- package/build/transaction/builders/FundingTransaction.js.map +1 -0
- package/build/transaction/builders/InteractionTransaction.d.ts +14 -5
- package/build/transaction/builders/InteractionTransaction.d.ts.map +1 -0
- package/build/transaction/builders/InteractionTransaction.js +18 -5
- package/build/transaction/builders/InteractionTransaction.js.map +1 -0
- package/build/transaction/builders/InteractionTransactionP2WDA.d.ts +58 -7
- package/build/transaction/builders/InteractionTransactionP2WDA.d.ts.map +1 -0
- package/build/transaction/builders/InteractionTransactionP2WDA.js +95 -18
- package/build/transaction/builders/InteractionTransactionP2WDA.js.map +1 -0
- package/build/transaction/builders/MultiSignTransaction.d.ts +126 -17
- package/build/transaction/builders/MultiSignTransaction.d.ts.map +1 -0
- package/build/transaction/builders/MultiSignTransaction.js +201 -76
- package/build/transaction/builders/MultiSignTransaction.js.map +1 -0
- package/build/transaction/builders/SharedInteractionTransaction.d.ts +106 -18
- package/build/transaction/builders/SharedInteractionTransaction.d.ts.map +1 -0
- package/build/transaction/builders/SharedInteractionTransaction.js +158 -40
- package/build/transaction/builders/SharedInteractionTransaction.js.map +1 -0
- package/build/transaction/builders/TransactionBuilder.d.ts +249 -19
- package/build/transaction/builders/TransactionBuilder.d.ts.map +1 -0
- package/build/transaction/builders/TransactionBuilder.js +377 -60
- package/build/transaction/builders/TransactionBuilder.js.map +1 -0
- package/build/transaction/enums/TransactionType.d.ts +1 -0
- package/build/transaction/enums/TransactionType.d.ts.map +1 -0
- package/build/transaction/enums/TransactionType.js +1 -0
- package/build/transaction/enums/TransactionType.js.map +1 -0
- package/build/transaction/interfaces/ICancelTransactionParameters.d.ts +3 -2
- package/build/transaction/interfaces/ICancelTransactionParameters.d.ts.map +1 -0
- package/build/transaction/interfaces/ICancelTransactionParameters.js +1 -0
- package/build/transaction/interfaces/ICancelTransactionParameters.js.map +1 -0
- package/build/transaction/interfaces/IConsolidatedTransactionParameters.d.ts +48 -5
- package/build/transaction/interfaces/IConsolidatedTransactionParameters.d.ts.map +1 -0
- package/build/transaction/interfaces/IConsolidatedTransactionParameters.js +1 -0
- package/build/transaction/interfaces/IConsolidatedTransactionParameters.js.map +1 -0
- package/build/transaction/interfaces/ICustomTransactionParameters.d.ts +7 -5
- package/build/transaction/interfaces/ICustomTransactionParameters.d.ts.map +1 -0
- package/build/transaction/interfaces/ICustomTransactionParameters.js +1 -0
- package/build/transaction/interfaces/ICustomTransactionParameters.js.map +1 -0
- package/build/transaction/interfaces/ITransactionParameters.d.ts +27 -15
- package/build/transaction/interfaces/ITransactionParameters.d.ts.map +1 -0
- package/build/transaction/interfaces/ITransactionParameters.js +1 -0
- package/build/transaction/interfaces/ITransactionParameters.js.map +1 -0
- package/build/transaction/interfaces/ITransactionResponses.d.ts +3 -2
- package/build/transaction/interfaces/ITransactionResponses.d.ts.map +1 -0
- package/build/transaction/interfaces/ITransactionResponses.js +1 -0
- package/build/transaction/interfaces/ITransactionResponses.js.map +1 -0
- package/build/transaction/interfaces/ITweakedTransactionData.d.ts +21 -8
- package/build/transaction/interfaces/ITweakedTransactionData.d.ts.map +1 -0
- package/build/transaction/interfaces/ITweakedTransactionData.js +1 -0
- package/build/transaction/interfaces/ITweakedTransactionData.js.map +1 -0
- package/build/transaction/interfaces/IWeb3ProviderTypes.d.ts +29 -3
- package/build/transaction/interfaces/IWeb3ProviderTypes.d.ts.map +1 -0
- package/build/transaction/interfaces/IWeb3ProviderTypes.js +2 -1
- package/build/transaction/interfaces/IWeb3ProviderTypes.js.map +1 -0
- package/build/transaction/interfaces/Tap.d.ts +4 -3
- package/build/transaction/interfaces/Tap.d.ts.map +1 -0
- package/build/transaction/interfaces/Tap.js +1 -0
- package/build/transaction/interfaces/Tap.js.map +1 -0
- package/build/transaction/mineable/IP2WSHAddress.d.ts +2 -1
- package/build/transaction/mineable/IP2WSHAddress.d.ts.map +1 -0
- package/build/transaction/mineable/IP2WSHAddress.js +1 -0
- package/build/transaction/mineable/IP2WSHAddress.js.map +1 -0
- package/build/transaction/mineable/TimelockGenerator.d.ts +13 -4
- package/build/transaction/mineable/TimelockGenerator.d.ts.map +1 -0
- package/build/transaction/mineable/TimelockGenerator.js +12 -3
- package/build/transaction/mineable/TimelockGenerator.js.map +1 -0
- package/build/transaction/offline/OfflineTransactionManager.d.ts +193 -12
- package/build/transaction/offline/OfflineTransactionManager.d.ts.map +1 -0
- package/build/transaction/offline/OfflineTransactionManager.js +192 -8
- package/build/transaction/offline/OfflineTransactionManager.js.map +1 -0
- package/build/transaction/offline/TransactionReconstructor.d.ts +56 -6
- package/build/transaction/offline/TransactionReconstructor.d.ts.map +1 -0
- package/build/transaction/offline/TransactionReconstructor.js +111 -75
- package/build/transaction/offline/TransactionReconstructor.js.map +1 -0
- package/build/transaction/offline/TransactionSerializer.d.ts +54 -3
- package/build/transaction/offline/TransactionSerializer.d.ts.map +1 -0
- package/build/transaction/offline/TransactionSerializer.js +206 -95
- package/build/transaction/offline/TransactionSerializer.js.map +1 -0
- package/build/transaction/offline/TransactionStateCapture.d.ts +66 -7
- package/build/transaction/offline/TransactionStateCapture.d.ts.map +1 -0
- package/build/transaction/offline/TransactionStateCapture.js +124 -60
- package/build/transaction/offline/TransactionStateCapture.js.map +1 -0
- package/build/transaction/offline/interfaces/ISerializableState.d.ts +72 -1
- package/build/transaction/offline/interfaces/ISerializableState.d.ts.map +1 -0
- package/build/transaction/offline/interfaces/ISerializableState.js +10 -1
- package/build/transaction/offline/interfaces/ISerializableState.js.map +1 -0
- package/build/transaction/offline/interfaces/ITypeSpecificData.d.ts +77 -1
- package/build/transaction/offline/interfaces/ITypeSpecificData.d.ts.map +1 -0
- package/build/transaction/offline/interfaces/ITypeSpecificData.js +19 -0
- package/build/transaction/offline/interfaces/ITypeSpecificData.js.map +1 -0
- package/build/transaction/psbt/PSBTTypes.d.ts +1 -0
- package/build/transaction/psbt/PSBTTypes.d.ts.map +1 -0
- package/build/transaction/psbt/PSBTTypes.js +1 -0
- package/build/transaction/psbt/PSBTTypes.js.map +1 -0
- package/build/transaction/shared/P2TR_MS.d.ts +11 -2
- package/build/transaction/shared/P2TR_MS.d.ts.map +1 -0
- package/build/transaction/shared/P2TR_MS.js +10 -0
- package/build/transaction/shared/P2TR_MS.js.map +1 -0
- package/build/transaction/shared/TweakedTransaction.d.ts +281 -38
- package/build/transaction/shared/TweakedTransaction.d.ts.map +1 -0
- package/build/transaction/shared/TweakedTransaction.js +576 -114
- package/build/transaction/shared/TweakedTransaction.js.map +1 -0
- package/build/transaction/utils/WitnessUtils.d.ts +7 -1
- package/build/transaction/utils/WitnessUtils.d.ts.map +1 -0
- package/build/transaction/utils/WitnessUtils.js +17 -3
- package/build/transaction/utils/WitnessUtils.js.map +1 -0
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/build/utils/BitcoinUtils.d.ts +19 -0
- package/build/utils/BitcoinUtils.d.ts.map +1 -0
- package/build/utils/BitcoinUtils.js +19 -0
- package/build/utils/BitcoinUtils.js.map +1 -0
- package/build/utils/BufferHelper.d.ts +2 -1
- package/build/utils/BufferHelper.d.ts.map +1 -0
- package/build/utils/BufferHelper.js +38 -32
- package/build/utils/BufferHelper.js.map +1 -0
- package/build/utils/StringToBuffer.d.ts +1 -0
- package/build/utils/StringToBuffer.d.ts.map +1 -0
- package/build/utils/StringToBuffer.js +1 -0
- package/build/utils/StringToBuffer.js.map +1 -0
- package/build/utils/lengths.d.ts +1 -0
- package/build/utils/lengths.d.ts.map +1 -0
- package/build/utils/lengths.js +1 -0
- package/build/utils/lengths.js.map +1 -0
- package/build/utils/types.d.ts +1 -0
- package/build/utils/types.d.ts.map +1 -0
- package/build/utils/types.js +2 -1
- package/build/utils/types.js.map +1 -0
- package/build/utxo/OPNetLimitedProvider.d.ts +39 -3
- package/build/utxo/OPNetLimitedProvider.d.ts.map +1 -0
- package/build/utxo/OPNetLimitedProvider.js +41 -3
- package/build/utxo/OPNetLimitedProvider.js.map +1 -0
- package/build/utxo/interfaces/BroadcastResponse.d.ts +1 -0
- package/build/utxo/interfaces/BroadcastResponse.d.ts.map +1 -0
- package/build/utxo/interfaces/BroadcastResponse.js +1 -0
- package/build/utxo/interfaces/BroadcastResponse.js.map +1 -0
- package/build/utxo/interfaces/IUTXO.d.ts +13 -7
- package/build/utxo/interfaces/IUTXO.d.ts.map +1 -0
- package/build/utxo/interfaces/IUTXO.js +1 -0
- package/build/utxo/interfaces/IUTXO.js.map +1 -0
- package/build/verification/TapscriptVerificator.d.ts +12 -10
- package/build/verification/TapscriptVerificator.d.ts.map +1 -0
- package/build/verification/TapscriptVerificator.js +28 -38
- package/build/verification/TapscriptVerificator.js.map +1 -0
- package/eslint.config.js +0 -1
- package/package.json +12 -35
- package/src/abi/ABICoder.ts +0 -13
- package/src/branded/Branded.ts +5 -0
- package/src/buffer/BinaryReader.ts +7 -7
- package/src/buffer/BinaryWriter.ts +29 -24
- package/src/bytecode/Compressor.ts +1 -1
- package/src/chain/ChainData.ts +34 -27
- package/src/consensus/ConsensusConfig.ts +1 -1
- package/src/consensus/IConsensusConfig.ts +0 -17
- package/src/consensus/metadata/RoswellConsensus.ts +1 -17
- package/src/deterministic/AddressMap.ts +5 -1
- package/src/deterministic/AddressSet.ts +5 -1
- package/src/deterministic/CustomMap.ts +6 -2
- package/src/deterministic/DeterministicMap.ts +8 -4
- package/src/deterministic/DeterministicSet.ts +6 -2
- package/src/deterministic/ExtendedAddressMap.ts +9 -4
- package/src/deterministic/FastMap.ts +9 -5
- package/src/ecc/backend.ts +17 -0
- package/src/epoch/ChallengeSolution.ts +3 -3
- package/src/epoch/interfaces/IChallengeSolution.ts +13 -13
- package/src/epoch/validator/EpochValidator.ts +24 -43
- package/src/generators/AddressGenerator.ts +6 -6
- package/src/generators/Features.ts +3 -3
- package/src/generators/Generator.ts +42 -26
- package/src/generators/builders/CalldataGenerator.ts +26 -24
- package/src/generators/builders/CustomGenerator.ts +4 -4
- package/src/generators/builders/DeploymentGenerator.ts +25 -23
- package/src/generators/builders/HashCommitmentGenerator.ts +31 -31
- package/src/generators/builders/LegacyCalldataGenerator.ts +26 -24
- package/src/generators/builders/MultiSignGenerator.ts +12 -12
- package/src/generators/builders/P2WDAGenerator.ts +10 -10
- package/src/keypair/Address.ts +114 -71
- package/src/keypair/AddressVerificator.ts +16 -147
- package/src/keypair/EcKeyPair.ts +105 -114
- package/src/keypair/MessageSigner.ts +70 -150
- package/src/keypair/Wallet.ts +59 -240
- package/src/metadata/ContractBaseMetadata.ts +2 -2
- package/src/mnemonic/Mnemonic.ts +32 -221
- package/src/opnet.ts +12 -6
- package/src/p2wda/P2WDADetector.ts +23 -72
- package/src/polyfill/disposable.ts +29 -0
- package/src/signer/AddressRotation.ts +1 -1
- package/src/signer/IRotationSigner.ts +3 -3
- package/src/signer/ParallelSignerAdapter.ts +59 -0
- package/src/signer/SignerUtils.ts +4 -4
- package/src/signer/TweakedSigner.ts +28 -13
- package/src/transaction/ContractAddress.ts +3 -7
- package/src/transaction/TransactionFactory.ts +28 -50
- package/src/transaction/browser/BrowserSignerBase.ts +12 -6
- package/src/transaction/browser/Web3Provider.ts +3 -3
- package/src/transaction/browser/extensions/UnisatSigner.ts +52 -48
- package/src/transaction/browser/extensions/XverseSigner.ts +55 -38
- package/src/transaction/browser/types/OPWallet.ts +2 -2
- package/src/transaction/browser/types/Unisat.ts +1 -1
- package/src/transaction/builders/CancelTransaction.ts +59 -24
- package/src/transaction/builders/ChallengeSolutionTransaction.ts +3 -3
- package/src/transaction/builders/ConsolidatedInteractionTransaction.ts +39 -34
- package/src/transaction/builders/CustomScriptTransaction.ts +79 -56
- package/src/transaction/builders/DeploymentTransaction.ts +82 -63
- package/src/transaction/builders/FundingTransaction.ts +11 -11
- package/src/transaction/builders/InteractionTransaction.ts +10 -10
- package/src/transaction/builders/InteractionTransactionP2WDA.ts +38 -40
- package/src/transaction/builders/MultiSignTransaction.ts +68 -61
- package/src/transaction/builders/SharedInteractionTransaction.ts +81 -57
- package/src/transaction/builders/TransactionBuilder.ts +101 -79
- package/src/transaction/interfaces/ICancelTransactionParameters.ts +2 -2
- package/src/transaction/interfaces/IConsolidatedTransactionParameters.ts +5 -5
- package/src/transaction/interfaces/ICustomTransactionParameters.ts +5 -5
- package/src/transaction/interfaces/ITransactionParameters.ts +15 -15
- package/src/transaction/interfaces/ITransactionResponses.ts +2 -2
- package/src/transaction/interfaces/ITweakedTransactionData.ts +17 -8
- package/src/transaction/interfaces/IWeb3ProviderTypes.ts +3 -3
- package/src/transaction/interfaces/Tap.ts +3 -3
- package/src/transaction/mineable/IP2WSHAddress.ts +1 -1
- package/src/transaction/mineable/TimelockGenerator.ts +19 -12
- package/src/transaction/offline/OfflineTransactionManager.ts +22 -23
- package/src/transaction/offline/TransactionReconstructor.ts +83 -91
- package/src/transaction/offline/TransactionSerializer.ts +151 -101
- package/src/transaction/offline/TransactionStateCapture.ts +83 -79
- package/src/transaction/offline/interfaces/ISerializableState.ts +1 -1
- package/src/transaction/offline/interfaces/ITypeSpecificData.ts +1 -1
- package/src/transaction/shared/P2TR_MS.ts +4 -4
- package/src/transaction/shared/TweakedTransaction.ts +326 -124
- package/src/transaction/utils/WitnessUtils.ts +18 -9
- package/src/utils/BufferHelper.ts +39 -37
- package/src/utxo/OPNetLimitedProvider.ts +7 -7
- package/src/utxo/interfaces/IUTXO.ts +7 -7
- package/src/verification/TapscriptVerificator.ts +73 -86
- package/test/address-rotation.test.ts +24 -24
- package/test/address.test.ts +12 -12
- package/test/addressmap.test.ts +30 -30
- package/test/binary-reader-writer.test.ts +8 -8
- package/test/browser/offline-transaction.test.ts +2206 -0
- package/test/browser/parallel-signing.test.ts +316 -0
- package/test/browser/setup.ts +11 -0
- package/test/browser/transaction-signing.test.ts +416 -0
- package/test/buffer-helper.test.ts +287 -0
- package/test/derivePath.test.ts +4 -3
- package/test/disposable.test.ts +279 -0
- package/test/fastmap-setall.test.ts +1 -1
- package/test/fastmap.test.ts +3 -3
- package/test/messagesigner-mldsa.test.ts +3 -3
- package/test/messagesigner-schnorr.test.ts +9 -9
- package/test/offline-transaction.test.ts +461 -288
- package/test/old/FastBigIntMap.ts +3 -3
- package/test/oldfastmap.test.ts +6 -6
- package/test/transaction-builders.test.ts +321 -0
- package/tsconfig.base.json +34 -18
- package/tsconfig.browser.json +15 -0
- package/tsconfig.json +3 -8
- package/vite.config.browser.ts +4 -5
- package/vitest.config.browser.ts +68 -0
- package/vitest.config.ts +1 -1
- package/browser/valibot.js +0 -4948
- package/tsconfig.webpack.json +0 -18
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { Logger } from '@btc-vision/logger';
|
|
2
|
-
import { address as bitAddress, crypto as bitCrypto, getFinalScripts, isP2A, isP2MS, isP2PK, isP2PKH, isP2SHScript, isP2TR, isP2WPKH, isP2WSHScript, isUnknownSegwitVersion, opcodes, payments, PaymentType, script, toXOnly, varuint, } from '@btc-vision/bitcoin';
|
|
3
|
-
import { TweakedSigner } from '../../signer/TweakedSigner.js';
|
|
2
|
+
import { address as bitAddress, crypto as bitCrypto, fromHex, getFinalScripts, isP2A, isP2MS, isP2PK, isP2PKH, isP2SHScript, isP2TR, isP2WPKH, isP2WSHScript, isUnknownSegwitVersion, opcodes, payments, PaymentType, Psbt, script, toXOnly, Transaction, varuint, } from '@btc-vision/bitcoin';
|
|
3
|
+
import { isUniversalSigner, TweakedSigner } from '../../signer/TweakedSigner.js';
|
|
4
|
+
import {} from '@btc-vision/ecpair';
|
|
5
|
+
import { UnisatSigner } from '../browser/extensions/UnisatSigner.js';
|
|
4
6
|
import { canSignNonTaprootInput, isTaprootInput, pubkeyInScript, } from '../../signer/SignerUtils.js';
|
|
5
7
|
import { witnessStackToScriptWitness } from '../utils/WitnessUtils.js';
|
|
6
|
-
import { Buffer } from 'buffer';
|
|
7
8
|
import { P2WDADetector } from '../../p2wda/P2WDADetector.js';
|
|
8
9
|
import { MessageSigner } from '../../keypair/MessageSigner.js';
|
|
10
|
+
import {} from '../../signer/AddressRotation.js';
|
|
11
|
+
import { prepareSigningTasks, applySignaturesToPsbt, WorkerSigningPool, } from '@btc-vision/bitcoin/workers';
|
|
12
|
+
import { toTweakedParallelKeyPair } from '../../signer/ParallelSignerAdapter.js';
|
|
13
|
+
/**
|
|
14
|
+
* The transaction sequence
|
|
15
|
+
*/
|
|
9
16
|
export var TransactionSequence;
|
|
10
17
|
(function (TransactionSequence) {
|
|
11
18
|
TransactionSequence[TransactionSequence["REPLACE_BY_FEE"] = 4294967293] = "REPLACE_BY_FEE";
|
|
@@ -16,70 +23,112 @@ export var CSVModes;
|
|
|
16
23
|
CSVModes[CSVModes["BLOCKS"] = 0] = "BLOCKS";
|
|
17
24
|
CSVModes[CSVModes["TIMESTAMPS"] = 1] = "TIMESTAMPS";
|
|
18
25
|
})(CSVModes || (CSVModes = {}));
|
|
26
|
+
/**
|
|
27
|
+
* @description PSBT Transaction processor.
|
|
28
|
+
* */
|
|
19
29
|
export class TweakedTransaction extends Logger {
|
|
30
|
+
logColor = '#00ffe1';
|
|
31
|
+
finalized = false;
|
|
32
|
+
/**
|
|
33
|
+
* @description Was the transaction signed?
|
|
34
|
+
*/
|
|
35
|
+
signer;
|
|
36
|
+
/**
|
|
37
|
+
* @description Tweaked signer
|
|
38
|
+
*/
|
|
39
|
+
tweakedSigner;
|
|
40
|
+
/**
|
|
41
|
+
* @description The network of the transaction
|
|
42
|
+
*/
|
|
43
|
+
network;
|
|
44
|
+
/**
|
|
45
|
+
* @description Was the transaction signed?
|
|
46
|
+
*/
|
|
47
|
+
signed = false;
|
|
48
|
+
/**
|
|
49
|
+
* @description The sighash types of the transaction
|
|
50
|
+
* @protected
|
|
51
|
+
*/
|
|
52
|
+
sighashTypes;
|
|
53
|
+
/**
|
|
54
|
+
* @description The script data of the transaction
|
|
55
|
+
*/
|
|
56
|
+
scriptData = null;
|
|
57
|
+
/**
|
|
58
|
+
* @description The tap data of the transaction
|
|
59
|
+
*/
|
|
60
|
+
tapData = null;
|
|
61
|
+
/**
|
|
62
|
+
* @description The inputs of the transaction
|
|
63
|
+
*/
|
|
64
|
+
inputs = [];
|
|
65
|
+
/**
|
|
66
|
+
* @description The sequence of the transaction
|
|
67
|
+
* @protected
|
|
68
|
+
*/
|
|
69
|
+
sequence = TransactionSequence.REPLACE_BY_FEE;
|
|
70
|
+
/**
|
|
71
|
+
* The tap leaf script
|
|
72
|
+
* @protected
|
|
73
|
+
*/
|
|
74
|
+
tapLeafScript = null;
|
|
75
|
+
/**
|
|
76
|
+
* Add a non-witness utxo to the transaction
|
|
77
|
+
* @protected
|
|
78
|
+
*/
|
|
79
|
+
nonWitnessUtxo;
|
|
80
|
+
/**
|
|
81
|
+
* Is the transaction being generated inside a browser?
|
|
82
|
+
* @protected
|
|
83
|
+
*/
|
|
84
|
+
isBrowser = false;
|
|
85
|
+
/**
|
|
86
|
+
* Track which inputs contain CSV scripts
|
|
87
|
+
* @protected
|
|
88
|
+
*/
|
|
89
|
+
csvInputIndices = new Set();
|
|
90
|
+
anchorInputIndices = new Set();
|
|
91
|
+
regenerated = false;
|
|
92
|
+
ignoreSignatureErrors = false;
|
|
93
|
+
noSignatures = false;
|
|
94
|
+
unlockScript;
|
|
95
|
+
txVersion = 2;
|
|
96
|
+
_mldsaSigner = null;
|
|
97
|
+
_hashedPublicKey = null;
|
|
98
|
+
/**
|
|
99
|
+
* Whether address rotation mode is enabled.
|
|
100
|
+
* When true, each UTXO can be signed by a different signer.
|
|
101
|
+
*/
|
|
102
|
+
addressRotationEnabled = false;
|
|
103
|
+
/**
|
|
104
|
+
* Map of addresses to their respective signers for address rotation mode.
|
|
105
|
+
*/
|
|
106
|
+
signerMap = new Map();
|
|
107
|
+
/**
|
|
108
|
+
* Map of input indices to their signers (resolved from UTXOs or signerMap).
|
|
109
|
+
* Populated during input addition.
|
|
110
|
+
*/
|
|
111
|
+
inputSignerMap = new Map();
|
|
112
|
+
/**
|
|
113
|
+
* Cache of tweaked signers per input for address rotation mode.
|
|
114
|
+
*/
|
|
115
|
+
tweakedSignerCache = new Map();
|
|
116
|
+
/**
|
|
117
|
+
* Parallel signing configuration using worker threads.
|
|
118
|
+
* When set, key-path taproot inputs are signed in parallel via workers.
|
|
119
|
+
*/
|
|
120
|
+
parallelSigningConfig;
|
|
20
121
|
constructor(data) {
|
|
21
122
|
super();
|
|
22
|
-
this.logColor = '#00ffe1';
|
|
23
|
-
this.finalized = false;
|
|
24
|
-
this.signed = false;
|
|
25
|
-
this.scriptData = null;
|
|
26
|
-
this.tapData = null;
|
|
27
|
-
this.inputs = [];
|
|
28
|
-
this.sequence = TransactionSequence.REPLACE_BY_FEE;
|
|
29
|
-
this.tapLeafScript = null;
|
|
30
|
-
this.isBrowser = false;
|
|
31
|
-
this.csvInputIndices = new Set();
|
|
32
|
-
this.anchorInputIndices = new Set();
|
|
33
|
-
this.regenerated = false;
|
|
34
|
-
this.ignoreSignatureErrors = false;
|
|
35
|
-
this.noSignatures = false;
|
|
36
|
-
this.txVersion = 2;
|
|
37
|
-
this._mldsaSigner = null;
|
|
38
|
-
this._hashedPublicKey = null;
|
|
39
|
-
this.addressRotationEnabled = false;
|
|
40
|
-
this.signerMap = new Map();
|
|
41
|
-
this.inputSignerMap = new Map();
|
|
42
|
-
this.tweakedSignerCache = new Map();
|
|
43
|
-
this.customFinalizerP2SH = (inputIndex, input, scriptA, isSegwit, isP2SH, isP2WSH) => {
|
|
44
|
-
const inputDecoded = this.inputs[inputIndex];
|
|
45
|
-
if (isP2SH && input.partialSig && inputDecoded && inputDecoded.redeemScript) {
|
|
46
|
-
const signatures = input.partialSig.map((sig) => sig.signature) || [];
|
|
47
|
-
const scriptSig = script.compile([...signatures, inputDecoded.redeemScript]);
|
|
48
|
-
return {
|
|
49
|
-
finalScriptSig: scriptSig,
|
|
50
|
-
finalScriptWitness: undefined,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
if (this.anchorInputIndices.has(inputIndex)) {
|
|
54
|
-
return {
|
|
55
|
-
finalScriptSig: undefined,
|
|
56
|
-
finalScriptWitness: Buffer.from([0]),
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
if (isP2WSH && isSegwit && input.witnessScript) {
|
|
60
|
-
if (!input.partialSig || input.partialSig.length === 0) {
|
|
61
|
-
throw new Error(`No signatures for P2WSH input #${inputIndex}`);
|
|
62
|
-
}
|
|
63
|
-
const isP2WDA = P2WDADetector.isP2WDAWitnessScript(input.witnessScript);
|
|
64
|
-
if (isP2WDA) {
|
|
65
|
-
return this.finalizeSecondaryP2WDA(inputIndex, input);
|
|
66
|
-
}
|
|
67
|
-
const isCSVInput = this.csvInputIndices.has(inputIndex);
|
|
68
|
-
if (isCSVInput) {
|
|
69
|
-
const witnessStack = [input.partialSig[0].signature, input.witnessScript];
|
|
70
|
-
return {
|
|
71
|
-
finalScriptSig: undefined,
|
|
72
|
-
finalScriptWitness: witnessStackToScriptWitness(witnessStack),
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return getFinalScripts(inputIndex, input, scriptA, isSegwit, isP2SH, isP2WSH, true, this.unlockScript);
|
|
77
|
-
};
|
|
78
123
|
this.signer = data.signer;
|
|
79
124
|
this.network = data.network;
|
|
80
125
|
this.noSignatures = data.noSignatures || false;
|
|
81
|
-
|
|
82
|
-
|
|
126
|
+
if (data.nonWitnessUtxo !== undefined) {
|
|
127
|
+
this.nonWitnessUtxo = data.nonWitnessUtxo;
|
|
128
|
+
}
|
|
129
|
+
if (data.unlockScript !== undefined) {
|
|
130
|
+
this.unlockScript = data.unlockScript;
|
|
131
|
+
}
|
|
83
132
|
this.isBrowser = typeof window !== 'undefined';
|
|
84
133
|
if (data.txVersion) {
|
|
85
134
|
this.txVersion = data.txVersion;
|
|
@@ -88,27 +137,55 @@ export class TweakedTransaction extends Logger {
|
|
|
88
137
|
this._mldsaSigner = data.mldsaSigner;
|
|
89
138
|
this._hashedPublicKey = MessageSigner.sha256(this._mldsaSigner.publicKey);
|
|
90
139
|
}
|
|
140
|
+
// Initialize address rotation
|
|
91
141
|
if (data.addressRotation?.enabled) {
|
|
92
142
|
this.addressRotationEnabled = true;
|
|
93
143
|
this.signerMap = data.addressRotation.signerMap;
|
|
94
144
|
}
|
|
145
|
+
if (data.parallelSigning) {
|
|
146
|
+
this.parallelSigningConfig = data.parallelSigning;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
[Symbol.dispose]() {
|
|
150
|
+
this.inputs.length = 0;
|
|
151
|
+
this.scriptData = null;
|
|
152
|
+
this.tapData = null;
|
|
153
|
+
this.tapLeafScript = null;
|
|
154
|
+
delete this.tweakedSigner;
|
|
155
|
+
this.csvInputIndices.clear();
|
|
156
|
+
this.anchorInputIndices.clear();
|
|
157
|
+
this.inputSignerMap.clear();
|
|
158
|
+
this.tweakedSignerCache.clear();
|
|
159
|
+
delete this.parallelSigningConfig;
|
|
95
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Get the MLDSA signer
|
|
163
|
+
* @protected
|
|
164
|
+
*/
|
|
96
165
|
get mldsaSigner() {
|
|
97
166
|
if (!this._mldsaSigner) {
|
|
98
167
|
throw new Error('MLDSA Signer is not set');
|
|
99
168
|
}
|
|
100
169
|
return this._mldsaSigner;
|
|
101
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Get the hashed public key
|
|
173
|
+
* @protected
|
|
174
|
+
*/
|
|
102
175
|
get hashedPublicKey() {
|
|
103
176
|
if (!this._hashedPublicKey) {
|
|
104
177
|
throw new Error('Hashed public key is not set');
|
|
105
178
|
}
|
|
106
179
|
return this._hashedPublicKey;
|
|
107
180
|
}
|
|
181
|
+
/**
|
|
182
|
+
* Read witnesses
|
|
183
|
+
* @protected
|
|
184
|
+
*/
|
|
108
185
|
static readScriptWitnessToWitnessStack(buffer) {
|
|
109
186
|
let offset = 0;
|
|
110
187
|
function readSlice(n) {
|
|
111
|
-
const slice =
|
|
188
|
+
const slice = new Uint8Array(buffer.subarray(offset, offset + n));
|
|
112
189
|
offset += n;
|
|
113
190
|
return slice;
|
|
114
191
|
}
|
|
@@ -131,17 +208,33 @@ export class TweakedTransaction extends Logger {
|
|
|
131
208
|
}
|
|
132
209
|
return readVector();
|
|
133
210
|
}
|
|
134
|
-
|
|
211
|
+
/**
|
|
212
|
+
* Pre-estimate the transaction fees for a Taproot transaction
|
|
213
|
+
* @param {bigint} feeRate - The fee rate in satoshis per virtual byte
|
|
214
|
+
* @param {bigint} numInputs - The number of inputs
|
|
215
|
+
* @param {bigint} numOutputs - The number of outputs
|
|
216
|
+
* @param {bigint} numWitnessElements - The number of witness elements (e.g., number of control blocks and witnesses)
|
|
217
|
+
* @param {bigint} witnessElementSize - The average size of each witness element in bytes
|
|
218
|
+
* @param {bigint} emptyWitness - The amount of empty witnesses
|
|
219
|
+
* @param {bigint} [taprootControlWitnessSize=139n] - The size of the control block witness in bytes
|
|
220
|
+
* @param {bigint} [taprootScriptSize=32n] - The size of the taproot script in bytes
|
|
221
|
+
* @returns {bigint} - The estimated transaction fees
|
|
222
|
+
*/
|
|
223
|
+
static preEstimateTaprootTransactionFees(feeRate, // satoshis per virtual byte
|
|
224
|
+
numInputs, numOutputs, numWitnessElements, witnessElementSize, emptyWitness, taprootControlWitnessSize = 32n, taprootScriptSize = 139n) {
|
|
135
225
|
const txHeaderSize = 10n;
|
|
136
226
|
const inputBaseSize = 41n;
|
|
137
227
|
const outputSize = 68n;
|
|
138
|
-
const taprootWitnessBaseSize = 1n;
|
|
228
|
+
const taprootWitnessBaseSize = 1n; // Base witness size per input (without signatures and control blocks)
|
|
229
|
+
// Base transaction size (excluding witness data)
|
|
139
230
|
const baseTxSize = txHeaderSize + inputBaseSize * numInputs + outputSize * numOutputs;
|
|
231
|
+
// Witness data size for Taproot
|
|
140
232
|
const witnessSize = numInputs * taprootWitnessBaseSize +
|
|
141
233
|
numWitnessElements * witnessElementSize +
|
|
142
234
|
taprootControlWitnessSize * numInputs +
|
|
143
235
|
taprootScriptSize * numInputs +
|
|
144
236
|
emptyWitness;
|
|
237
|
+
// Total weight and virtual size
|
|
145
238
|
const weight = baseTxSize * 3n + (baseTxSize + witnessSize);
|
|
146
239
|
const vSize = weight / 4n;
|
|
147
240
|
return vSize * feeRate;
|
|
@@ -151,6 +244,12 @@ export class TweakedTransaction extends Logger {
|
|
|
151
244
|
input.sighashType = sighashTypes[0];
|
|
152
245
|
transaction.signInput(i, signer, sighashTypes.length ? sighashTypes : undefined);
|
|
153
246
|
}
|
|
247
|
+
/**
|
|
248
|
+
* Calculate the sign hash number
|
|
249
|
+
* @description Calculates the sign hash
|
|
250
|
+
* @protected
|
|
251
|
+
* @returns {number}
|
|
252
|
+
*/
|
|
154
253
|
static calculateSignHash(sighashTypes) {
|
|
155
254
|
if (!sighashTypes) {
|
|
156
255
|
throw new Error('Sighash types are required');
|
|
@@ -161,54 +260,98 @@ export class TweakedTransaction extends Logger {
|
|
|
161
260
|
}
|
|
162
261
|
return signHash || 0;
|
|
163
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
* Check if address rotation mode is enabled.
|
|
265
|
+
*/
|
|
164
266
|
isAddressRotationEnabled() {
|
|
165
267
|
return this.addressRotationEnabled;
|
|
166
268
|
}
|
|
167
269
|
ignoreSignatureError() {
|
|
168
270
|
this.ignoreSignatureErrors = true;
|
|
169
271
|
}
|
|
272
|
+
/**
|
|
273
|
+
* @description Returns the script address
|
|
274
|
+
* @returns {string}
|
|
275
|
+
*/
|
|
170
276
|
getScriptAddress() {
|
|
171
277
|
if (!this.scriptData || !this.scriptData.address) {
|
|
172
278
|
throw new Error('Tap data is required');
|
|
173
279
|
}
|
|
174
280
|
return this.scriptData.address;
|
|
175
281
|
}
|
|
282
|
+
/**
|
|
283
|
+
* @description Returns the transaction
|
|
284
|
+
* @returns {Transaction}
|
|
285
|
+
*/
|
|
176
286
|
getTransaction() {
|
|
177
287
|
return this.transaction.extractTransaction(false);
|
|
178
288
|
}
|
|
289
|
+
/**
|
|
290
|
+
* @description Returns the tap address
|
|
291
|
+
* @returns {string}
|
|
292
|
+
* @throws {Error} - If tap data is not set
|
|
293
|
+
*/
|
|
179
294
|
getTapAddress() {
|
|
180
295
|
if (!this.tapData || !this.tapData.address) {
|
|
181
296
|
throw new Error('Tap data is required');
|
|
182
297
|
}
|
|
183
298
|
return this.tapData.address;
|
|
184
299
|
}
|
|
300
|
+
/**
|
|
301
|
+
* @description Disables replace by fee on the transaction
|
|
302
|
+
*/
|
|
185
303
|
disableRBF() {
|
|
186
304
|
if (this.signed)
|
|
187
305
|
throw new Error('Transaction is already signed');
|
|
188
306
|
this.sequence = TransactionSequence.FINAL;
|
|
189
307
|
for (const input of this.inputs) {
|
|
308
|
+
// This would disable CSV! You need to check if the input has CSV
|
|
190
309
|
if (this.csvInputIndices.has(this.inputs.indexOf(input))) {
|
|
191
310
|
continue;
|
|
192
311
|
}
|
|
193
312
|
input.sequence = TransactionSequence.FINAL;
|
|
194
313
|
}
|
|
195
314
|
}
|
|
315
|
+
/**
|
|
316
|
+
* Get the tweaked hash
|
|
317
|
+
* @private
|
|
318
|
+
*
|
|
319
|
+
* @returns {Buffer | undefined} The tweaked hash
|
|
320
|
+
*/
|
|
196
321
|
getTweakerHash() {
|
|
197
322
|
return this.tapData?.hash;
|
|
198
323
|
}
|
|
199
|
-
|
|
324
|
+
/**
|
|
325
|
+
* Pre-estimate the transaction fees
|
|
326
|
+
* @param {bigint} feeRate - The fee rate
|
|
327
|
+
* @param {bigint} numInputs - The number of inputs
|
|
328
|
+
* @param {bigint} numOutputs - The number of outputs
|
|
329
|
+
* @param {bigint} numSignatures - The number of signatures
|
|
330
|
+
* @param {bigint} numPubkeys - The number of public keys
|
|
331
|
+
* @returns {bigint} - The estimated transaction fees
|
|
332
|
+
*/
|
|
333
|
+
preEstimateTransactionFees(feeRate, // satoshis per byte
|
|
334
|
+
numInputs, numOutputs, numSignatures, numPubkeys) {
|
|
200
335
|
const txHeaderSize = 10n;
|
|
201
336
|
const inputBaseSize = 41n;
|
|
202
337
|
const outputSize = 68n;
|
|
203
338
|
const signatureSize = 144n;
|
|
204
339
|
const pubkeySize = 34n;
|
|
340
|
+
// Base transaction size (excluding witness data)
|
|
205
341
|
const baseTxSize = txHeaderSize + inputBaseSize * numInputs + outputSize * numOutputs;
|
|
342
|
+
// Witness data size
|
|
206
343
|
const redeemScriptSize = 1n + numPubkeys * (1n + pubkeySize) + 1n + numSignatures;
|
|
207
344
|
const witnessSize = numSignatures * signatureSize + numPubkeys * pubkeySize + redeemScriptSize;
|
|
345
|
+
// Total weight and virtual size
|
|
208
346
|
const weight = baseTxSize * 3n + (baseTxSize + witnessSize);
|
|
209
347
|
const vSize = weight / 4n;
|
|
210
348
|
return vSize * feeRate;
|
|
211
349
|
}
|
|
350
|
+
/**
|
|
351
|
+
* Get the signer for a specific input index.
|
|
352
|
+
* Returns the input-specific signer if in rotation mode, otherwise the default signer.
|
|
353
|
+
* @param inputIndex - The index of the input
|
|
354
|
+
*/
|
|
212
355
|
getSignerForInput(inputIndex) {
|
|
213
356
|
if (this.addressRotationEnabled) {
|
|
214
357
|
const inputSigner = this.inputSignerMap.get(inputIndex);
|
|
@@ -218,14 +361,22 @@ export class TweakedTransaction extends Logger {
|
|
|
218
361
|
}
|
|
219
362
|
return this.signer;
|
|
220
363
|
}
|
|
364
|
+
/**
|
|
365
|
+
* Register a signer for a specific input index.
|
|
366
|
+
* Called during UTXO processing to map each input to its signer.
|
|
367
|
+
* @param inputIndex - The index of the input
|
|
368
|
+
* @param utxo - The UTXO being added
|
|
369
|
+
*/
|
|
221
370
|
registerInputSigner(inputIndex, utxo) {
|
|
222
371
|
if (!this.addressRotationEnabled) {
|
|
223
372
|
return;
|
|
224
373
|
}
|
|
374
|
+
// Priority 1: UTXO has an explicit signer attached
|
|
225
375
|
if (utxo.signer) {
|
|
226
376
|
this.inputSignerMap.set(inputIndex, utxo.signer);
|
|
227
377
|
return;
|
|
228
378
|
}
|
|
379
|
+
// Priority 2: Look up signer from signerMap by address
|
|
229
380
|
const address = utxo.scriptPubKey?.address;
|
|
230
381
|
if (address && this.signerMap.has(address)) {
|
|
231
382
|
const signer = this.signerMap.get(address);
|
|
@@ -234,19 +385,33 @@ export class TweakedTransaction extends Logger {
|
|
|
234
385
|
return;
|
|
235
386
|
}
|
|
236
387
|
}
|
|
388
|
+
// Fallback: Use default signer (no entry in inputSignerMap)
|
|
237
389
|
}
|
|
390
|
+
/**
|
|
391
|
+
* Get the x-only public key for a specific input's signer.
|
|
392
|
+
* Used for taproot inputs in address rotation mode.
|
|
393
|
+
* @param inputIndex - The index of the input
|
|
394
|
+
*/
|
|
238
395
|
internalPubKeyToXOnlyForInput(inputIndex) {
|
|
239
396
|
const signer = this.getSignerForInput(inputIndex);
|
|
240
|
-
return toXOnly(
|
|
397
|
+
return toXOnly(signer.publicKey);
|
|
241
398
|
}
|
|
399
|
+
/**
|
|
400
|
+
* Get the tweaked signer for a specific input.
|
|
401
|
+
* Caches the result for efficiency.
|
|
402
|
+
* @param inputIndex - The index of the input
|
|
403
|
+
* @param useTweakedHash - Whether to use the tweaked hash
|
|
404
|
+
*/
|
|
242
405
|
getTweakedSignerForInput(inputIndex, useTweakedHash = false) {
|
|
243
406
|
if (!this.addressRotationEnabled) {
|
|
407
|
+
// Fall back to original behavior
|
|
244
408
|
if (useTweakedHash) {
|
|
245
409
|
this.tweakSigner();
|
|
246
410
|
return this.tweakedSigner;
|
|
247
411
|
}
|
|
248
412
|
return this.getTweakedSigner(useTweakedHash);
|
|
249
413
|
}
|
|
414
|
+
// Check cache
|
|
250
415
|
const cacheKey = inputIndex * 2 + (useTweakedHash ? 1 : 0);
|
|
251
416
|
if (this.tweakedSignerCache.has(cacheKey)) {
|
|
252
417
|
return this.tweakedSignerCache.get(cacheKey);
|
|
@@ -263,6 +428,11 @@ export class TweakedTransaction extends Logger {
|
|
|
263
428
|
name: PaymentType.P2TR,
|
|
264
429
|
};
|
|
265
430
|
}
|
|
431
|
+
/**
|
|
432
|
+
* Generates the script address.
|
|
433
|
+
* @protected
|
|
434
|
+
* @returns {Payment}
|
|
435
|
+
*/
|
|
266
436
|
generateScriptAddress() {
|
|
267
437
|
return {
|
|
268
438
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
@@ -270,9 +440,24 @@ export class TweakedTransaction extends Logger {
|
|
|
270
440
|
name: PaymentType.P2TR,
|
|
271
441
|
};
|
|
272
442
|
}
|
|
443
|
+
/**
|
|
444
|
+
* Returns the signer key.
|
|
445
|
+
* @protected
|
|
446
|
+
* @returns {Signer | UniversalSigner}
|
|
447
|
+
*/
|
|
273
448
|
getSignerKey() {
|
|
274
449
|
return this.signer;
|
|
275
450
|
}
|
|
451
|
+
/**
|
|
452
|
+
* Signs an input of the transaction.
|
|
453
|
+
* @param {Psbt} transaction - The transaction to sign
|
|
454
|
+
* @param {PsbtInput} input - The input to sign
|
|
455
|
+
* @param {number} i - The index of the input
|
|
456
|
+
* @param {Signer} signer - The signer to use
|
|
457
|
+
* @param {boolean} [reverse=false] - Should the input be signed in reverse
|
|
458
|
+
* @param {boolean} [errored=false] - Was there an error
|
|
459
|
+
* @protected
|
|
460
|
+
*/
|
|
276
461
|
async signInput(transaction, input, i, signer, reverse = false, errored = false) {
|
|
277
462
|
if (this.anchorInputIndices.has(i))
|
|
278
463
|
return;
|
|
@@ -294,6 +479,7 @@ export class TweakedTransaction extends Logger {
|
|
|
294
479
|
}
|
|
295
480
|
}
|
|
296
481
|
else {
|
|
482
|
+
// Non-Taproot input
|
|
297
483
|
if (!reverse ? canSignNonTaprootInput(input, publicKey) : true) {
|
|
298
484
|
try {
|
|
299
485
|
await this.signNonTaprootInput(signer, transaction, i);
|
|
@@ -327,6 +513,12 @@ export class TweakedTransaction extends Logger {
|
|
|
327
513
|
}
|
|
328
514
|
return result;
|
|
329
515
|
}
|
|
516
|
+
/**
|
|
517
|
+
* Signs all the inputs of the transaction.
|
|
518
|
+
* @param {Psbt} transaction - The transaction to sign
|
|
519
|
+
* @protected
|
|
520
|
+
* @returns {Promise<void>}
|
|
521
|
+
*/
|
|
330
522
|
async signInputs(transaction) {
|
|
331
523
|
if ('multiSignPsbt' in this.signer) {
|
|
332
524
|
await this.signInputsWalletBased(transaction);
|
|
@@ -335,26 +527,23 @@ export class TweakedTransaction extends Logger {
|
|
|
335
527
|
await this.signInputsNonWalletBased(transaction);
|
|
336
528
|
}
|
|
337
529
|
async signInputsNonWalletBased(transaction) {
|
|
338
|
-
const txs = transaction.data.inputs;
|
|
339
|
-
const batchSize = 20;
|
|
340
|
-
const batches = this.splitArray(txs, batchSize);
|
|
341
530
|
if (!this.noSignatures) {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
const input = batch[j];
|
|
349
|
-
try {
|
|
350
|
-
const inputSigner = this.getSignerForInput(index);
|
|
351
|
-
promises.push(this.signInput(transaction, input, index, inputSigner));
|
|
352
|
-
}
|
|
353
|
-
catch (e) {
|
|
354
|
-
this.log(`Failed to sign input ${index}: ${e.stack}`);
|
|
531
|
+
if (this.canUseParallelSigning && isUniversalSigner(this.signer)) {
|
|
532
|
+
let parallelSignedIndices = new Set();
|
|
533
|
+
try {
|
|
534
|
+
const result = await this.signKeyPathInputsParallel(transaction);
|
|
535
|
+
if (result.success) {
|
|
536
|
+
parallelSignedIndices = new Set(result.signatures.keys());
|
|
355
537
|
}
|
|
356
538
|
}
|
|
357
|
-
|
|
539
|
+
catch (e) {
|
|
540
|
+
this.error(`Parallel signing failed, falling back to sequential: ${e.message}`);
|
|
541
|
+
}
|
|
542
|
+
// Sign remaining inputs (script-path, non-taproot, etc.) sequentially
|
|
543
|
+
await this.signRemainingInputsSequential(transaction, parallelSignedIndices);
|
|
544
|
+
}
|
|
545
|
+
else {
|
|
546
|
+
await this.signInputsSequential(transaction);
|
|
358
547
|
}
|
|
359
548
|
}
|
|
360
549
|
for (let i = 0; i < transaction.data.inputs.length; i++) {
|
|
@@ -362,35 +551,189 @@ export class TweakedTransaction extends Logger {
|
|
|
362
551
|
}
|
|
363
552
|
this.finalized = true;
|
|
364
553
|
}
|
|
554
|
+
/**
|
|
555
|
+
* Signs all inputs sequentially in batches of 20.
|
|
556
|
+
* This is the original signing logic, used as fallback when parallel signing is unavailable.
|
|
557
|
+
*/
|
|
558
|
+
async signInputsSequential(transaction) {
|
|
559
|
+
const txs = transaction.data.inputs;
|
|
560
|
+
const batchSize = 20;
|
|
561
|
+
const batches = this.splitArray(txs, batchSize);
|
|
562
|
+
for (let i = 0; i < batches.length; i++) {
|
|
563
|
+
const batch = batches[i];
|
|
564
|
+
const promises = [];
|
|
565
|
+
const offset = i * batchSize;
|
|
566
|
+
for (let j = 0; j < batch.length; j++) {
|
|
567
|
+
const index = offset + j;
|
|
568
|
+
const input = batch[j];
|
|
569
|
+
try {
|
|
570
|
+
// Use per-input signer in address rotation mode
|
|
571
|
+
const inputSigner = this.getSignerForInput(index);
|
|
572
|
+
promises.push(this.signInput(transaction, input, index, inputSigner));
|
|
573
|
+
}
|
|
574
|
+
catch (e) {
|
|
575
|
+
this.log(`Failed to sign input ${index}: ${e.stack}`);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
await Promise.all(promises);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Signs inputs that were not handled by parallel signing.
|
|
583
|
+
* After parallel key-path signing, script-path taproot inputs, non-taproot inputs,
|
|
584
|
+
* and any inputs that failed parallel signing need sequential signing.
|
|
585
|
+
*/
|
|
586
|
+
async signRemainingInputsSequential(transaction, signedIndices) {
|
|
587
|
+
const txs = transaction.data.inputs;
|
|
588
|
+
const unsignedIndices = [];
|
|
589
|
+
for (let i = 0; i < txs.length; i++) {
|
|
590
|
+
if (!signedIndices.has(i)) {
|
|
591
|
+
unsignedIndices.push(i);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
if (unsignedIndices.length === 0)
|
|
595
|
+
return;
|
|
596
|
+
const batchSize = 20;
|
|
597
|
+
const batches = this.splitArray(unsignedIndices, batchSize);
|
|
598
|
+
for (const batch of batches) {
|
|
599
|
+
const promises = [];
|
|
600
|
+
for (const index of batch) {
|
|
601
|
+
const input = txs[index];
|
|
602
|
+
try {
|
|
603
|
+
const inputSigner = this.getSignerForInput(index);
|
|
604
|
+
promises.push(this.signInput(transaction, input, index, inputSigner));
|
|
605
|
+
}
|
|
606
|
+
catch (e) {
|
|
607
|
+
this.log(`Failed to sign input ${index}: ${e.stack}`);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
await Promise.all(promises);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Converts the public key to x-only.
|
|
615
|
+
* @protected
|
|
616
|
+
* @returns {Buffer}
|
|
617
|
+
*/
|
|
365
618
|
internalPubKeyToXOnly() {
|
|
366
|
-
return toXOnly(
|
|
619
|
+
return toXOnly(this.signer.publicKey);
|
|
367
620
|
}
|
|
621
|
+
/**
|
|
622
|
+
* Internal init.
|
|
623
|
+
* @protected
|
|
624
|
+
*/
|
|
368
625
|
internalInit() {
|
|
369
626
|
this.scriptData = payments.p2tr(this.generateScriptAddress());
|
|
370
627
|
this.tapData = payments.p2tr(this.generateTapData());
|
|
371
628
|
}
|
|
629
|
+
/**
|
|
630
|
+
* Tweak the signer for the interaction
|
|
631
|
+
* @protected
|
|
632
|
+
*/
|
|
372
633
|
tweakSigner() {
|
|
373
634
|
if (this.tweakedSigner)
|
|
374
635
|
return;
|
|
375
|
-
|
|
636
|
+
// tweaked p2tr signer.
|
|
637
|
+
const tweaked = this.getTweakedSigner(true);
|
|
638
|
+
if (tweaked !== undefined) {
|
|
639
|
+
this.tweakedSigner = tweaked;
|
|
640
|
+
}
|
|
376
641
|
}
|
|
642
|
+
/**
|
|
643
|
+
* Get the tweaked signer
|
|
644
|
+
* @private
|
|
645
|
+
* @returns {UniversalSigner} The tweaked signer
|
|
646
|
+
*/
|
|
377
647
|
getTweakedSigner(useTweakedHash = false, signer = this.signer) {
|
|
378
648
|
const settings = {
|
|
379
649
|
network: this.network,
|
|
380
650
|
};
|
|
381
651
|
if (useTweakedHash) {
|
|
382
|
-
|
|
652
|
+
const tweakHash = this.getTweakerHash();
|
|
653
|
+
if (tweakHash !== undefined) {
|
|
654
|
+
settings.tweakHash = tweakHash;
|
|
655
|
+
}
|
|
383
656
|
}
|
|
384
|
-
if (!(
|
|
657
|
+
if (!isUniversalSigner(signer)) {
|
|
385
658
|
return;
|
|
386
659
|
}
|
|
387
660
|
return TweakedSigner.tweakSigner(signer, settings);
|
|
388
661
|
}
|
|
662
|
+
/**
|
|
663
|
+
* Whether parallel signing can be used for this transaction.
|
|
664
|
+
* Requires parallelSigningConfig and excludes browser, address rotation, and no-signature modes.
|
|
665
|
+
*/
|
|
666
|
+
get canUseParallelSigning() {
|
|
667
|
+
return (!!this.parallelSigningConfig &&
|
|
668
|
+
!this.addressRotationEnabled &&
|
|
669
|
+
!this.noSignatures);
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* Signs key-path taproot inputs in parallel using worker threads.
|
|
673
|
+
* @param transaction - The PSBT to sign
|
|
674
|
+
* @param excludeIndices - Input indices to skip (e.g., script-path inputs already signed)
|
|
675
|
+
* @returns The parallel signing result
|
|
676
|
+
*/
|
|
677
|
+
async signKeyPathInputsParallel(transaction, excludeIndices) {
|
|
678
|
+
const signer = this.signer;
|
|
679
|
+
// Get the tweaked signer for key-path
|
|
680
|
+
const tweakedSigner = this.getTweakedSigner(true);
|
|
681
|
+
if (!tweakedSigner) {
|
|
682
|
+
throw new Error('Cannot create tweaked signer for parallel signing');
|
|
683
|
+
}
|
|
684
|
+
// Create hybrid adapter: untweaked pubkey (for PSBT matching) + tweaked privkey
|
|
685
|
+
const adapter = toTweakedParallelKeyPair(signer, tweakedSigner);
|
|
686
|
+
// Prepare tasks from PSBT
|
|
687
|
+
const allTasks = prepareSigningTasks(transaction, adapter);
|
|
688
|
+
// Filter out excluded indices
|
|
689
|
+
const tasks = excludeIndices
|
|
690
|
+
? allTasks.filter((t) => !excludeIndices.has(t.inputIndex))
|
|
691
|
+
: allTasks;
|
|
692
|
+
if (tasks.length === 0) {
|
|
693
|
+
return {
|
|
694
|
+
success: true,
|
|
695
|
+
signatures: new Map(),
|
|
696
|
+
errors: new Map(),
|
|
697
|
+
durationMs: 0,
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
// Get or create pool
|
|
701
|
+
let pool;
|
|
702
|
+
let shouldShutdown = false;
|
|
703
|
+
if (this.parallelSigningConfig instanceof WorkerSigningPool) {
|
|
704
|
+
pool = this.parallelSigningConfig;
|
|
705
|
+
}
|
|
706
|
+
else {
|
|
707
|
+
pool = WorkerSigningPool.getInstance(this.parallelSigningConfig);
|
|
708
|
+
if (!pool.isPreservingWorkers)
|
|
709
|
+
shouldShutdown = true;
|
|
710
|
+
}
|
|
711
|
+
try {
|
|
712
|
+
await pool.initialize();
|
|
713
|
+
const result = await pool.signBatch(tasks, adapter);
|
|
714
|
+
if (result.success) {
|
|
715
|
+
applySignaturesToPsbt(transaction, result, adapter);
|
|
716
|
+
}
|
|
717
|
+
else {
|
|
718
|
+
const errorEntries = [...result.errors.entries()];
|
|
719
|
+
const errorMsg = errorEntries
|
|
720
|
+
.map(([idx, err]) => `Input ${idx}: ${err}`)
|
|
721
|
+
.join(', ');
|
|
722
|
+
this.error(`Parallel signing had errors: ${errorMsg}`);
|
|
723
|
+
}
|
|
724
|
+
return result;
|
|
725
|
+
}
|
|
726
|
+
finally {
|
|
727
|
+
if (shouldShutdown)
|
|
728
|
+
await pool.shutdown();
|
|
729
|
+
}
|
|
730
|
+
}
|
|
389
731
|
generateP2SHRedeemScript(customWitnessScript) {
|
|
390
732
|
const p2wsh = payments.p2wsh({
|
|
391
733
|
redeem: { output: customWitnessScript },
|
|
392
734
|
network: this.network,
|
|
393
735
|
});
|
|
736
|
+
// Step 2: Wrap the P2WSH inside a P2SH (Pay-to-Script-Hash)
|
|
394
737
|
const p2sh = payments.p2sh({
|
|
395
738
|
redeem: p2wsh,
|
|
396
739
|
network: this.network,
|
|
@@ -413,11 +756,12 @@ export class TweakedTransaction extends Logger {
|
|
|
413
756
|
opcodes.OP_EQUAL,
|
|
414
757
|
]);
|
|
415
758
|
const p2wsh = payments.p2wsh({
|
|
416
|
-
redeem: { output: redeemScript },
|
|
759
|
+
redeem: { output: redeemScript }, // Use the custom redeem script
|
|
417
760
|
network: this.network,
|
|
418
761
|
});
|
|
762
|
+
// Step 3: Wrap the P2WSH in a P2SH
|
|
419
763
|
const p2sh = payments.p2sh({
|
|
420
|
-
redeem: p2wsh,
|
|
764
|
+
redeem: p2wsh, // The P2WSH is wrapped inside the P2SH
|
|
421
765
|
network: this.network,
|
|
422
766
|
});
|
|
423
767
|
const address = bitAddress.fromOutputScript(outputScript, this.network);
|
|
@@ -430,12 +774,11 @@ export class TweakedTransaction extends Logger {
|
|
|
430
774
|
return;
|
|
431
775
|
}
|
|
432
776
|
generateP2SHP2PKHRedeemScript(inputAddr, inputIndex) {
|
|
777
|
+
// Use per-input signer in address rotation mode
|
|
433
778
|
const signer = this.addressRotationEnabled && inputIndex !== undefined
|
|
434
779
|
? this.getSignerForInput(inputIndex)
|
|
435
780
|
: this.signer;
|
|
436
|
-
const pubkey =
|
|
437
|
-
? signer.publicKey
|
|
438
|
-
: Buffer.from(signer.publicKey, 'hex');
|
|
781
|
+
const pubkey = signer.publicKey;
|
|
439
782
|
const w = payments.p2wpkh({
|
|
440
783
|
pubkey: pubkey,
|
|
441
784
|
network: this.network,
|
|
@@ -457,40 +800,60 @@ export class TweakedTransaction extends Logger {
|
|
|
457
800
|
}
|
|
458
801
|
return;
|
|
459
802
|
}
|
|
803
|
+
/**
|
|
804
|
+
* Generate the PSBT input extended, supporting various script types
|
|
805
|
+
* @param {UTXO} utxo The UTXO
|
|
806
|
+
* @param {number} i The index of the input
|
|
807
|
+
* @param {UTXO} _extra Extra UTXO
|
|
808
|
+
* @protected
|
|
809
|
+
* @returns {PsbtInputExtended} The PSBT input extended
|
|
810
|
+
*/
|
|
460
811
|
generatePsbtInputExtended(utxo, i, _extra = false) {
|
|
461
|
-
const scriptPub =
|
|
812
|
+
const scriptPub = fromHex(utxo.scriptPubKey.hex);
|
|
462
813
|
const input = {
|
|
463
814
|
hash: utxo.transactionId,
|
|
464
815
|
index: utxo.outputIndex,
|
|
465
816
|
sequence: this.sequence,
|
|
466
817
|
witnessUtxo: {
|
|
467
|
-
value:
|
|
818
|
+
value: utxo.value,
|
|
468
819
|
script: scriptPub,
|
|
469
820
|
},
|
|
470
821
|
};
|
|
822
|
+
// Handle P2PKH (Legacy)
|
|
471
823
|
if (isP2PKH(scriptPub)) {
|
|
824
|
+
// Legacy input requires nonWitnessUtxo
|
|
472
825
|
if (utxo.nonWitnessUtxo) {
|
|
473
|
-
input.
|
|
474
|
-
|
|
475
|
-
|
|
826
|
+
//delete input.witnessUtxo;
|
|
827
|
+
input.nonWitnessUtxo =
|
|
828
|
+
utxo.nonWitnessUtxo instanceof Uint8Array
|
|
829
|
+
? utxo.nonWitnessUtxo
|
|
830
|
+
: fromHex(utxo.nonWitnessUtxo);
|
|
476
831
|
}
|
|
477
832
|
else {
|
|
478
833
|
throw new Error('Missing nonWitnessUtxo for P2PKH UTXO');
|
|
479
834
|
}
|
|
480
835
|
}
|
|
836
|
+
// Handle P2WPKH (SegWit)
|
|
481
837
|
else if (isP2WPKH(scriptPub) || isUnknownSegwitVersion(scriptPub)) {
|
|
838
|
+
// No redeemScript required for pure P2WPKH
|
|
839
|
+
// witnessUtxo is enough, no nonWitnessUtxo needed.
|
|
482
840
|
}
|
|
841
|
+
// Handle P2WSH (SegWit)
|
|
483
842
|
else if (isP2WSHScript(scriptPub)) {
|
|
484
843
|
this.processP2WSHInput(utxo, input, i);
|
|
485
844
|
}
|
|
845
|
+
// Handle P2SH (Can be legacy or wrapping segwit)
|
|
486
846
|
else if (isP2SHScript(scriptPub)) {
|
|
847
|
+
// Redeem script is required for P2SH
|
|
487
848
|
let redeemScriptBuf;
|
|
488
849
|
if (utxo.redeemScript) {
|
|
489
|
-
redeemScriptBuf =
|
|
490
|
-
|
|
491
|
-
|
|
850
|
+
redeemScriptBuf =
|
|
851
|
+
utxo.redeemScript instanceof Uint8Array
|
|
852
|
+
? utxo.redeemScript
|
|
853
|
+
: fromHex(utxo.redeemScript);
|
|
492
854
|
}
|
|
493
855
|
else {
|
|
856
|
+
// Attempt to generate a redeem script if missing
|
|
494
857
|
if (!utxo.scriptPubKey.address) {
|
|
495
858
|
throw new Error('Missing redeemScript and no address to regenerate it for P2SH UTXO');
|
|
496
859
|
}
|
|
@@ -501,6 +864,7 @@ export class TweakedTransaction extends Logger {
|
|
|
501
864
|
redeemScriptBuf = legacyScripts.redeemScript;
|
|
502
865
|
}
|
|
503
866
|
input.redeemScript = redeemScriptBuf;
|
|
867
|
+
// Check if redeemScript is wrapping segwit (like P2SH-P2WPKH or P2SH-P2WSH)
|
|
504
868
|
const payment = payments.p2sh({ redeem: { output: input.redeemScript } });
|
|
505
869
|
if (!payment.redeem) {
|
|
506
870
|
throw new Error('Failed to extract redeem script from P2SH UTXO');
|
|
@@ -510,27 +874,39 @@ export class TweakedTransaction extends Logger {
|
|
|
510
874
|
throw new Error('Failed to extract redeem output from P2SH UTXO');
|
|
511
875
|
}
|
|
512
876
|
if (utxo.nonWitnessUtxo) {
|
|
513
|
-
input.nonWitnessUtxo =
|
|
514
|
-
|
|
515
|
-
|
|
877
|
+
input.nonWitnessUtxo =
|
|
878
|
+
utxo.nonWitnessUtxo instanceof Uint8Array
|
|
879
|
+
? utxo.nonWitnessUtxo
|
|
880
|
+
: fromHex(utxo.nonWitnessUtxo);
|
|
516
881
|
}
|
|
517
882
|
if (isP2WPKH(redeemOutput)) {
|
|
518
|
-
|
|
883
|
+
// P2SH-P2WPKH
|
|
884
|
+
// Use witnessUtxo + redeemScript
|
|
885
|
+
Reflect.deleteProperty(input, 'nonWitnessUtxo'); // ensure we do NOT have nonWitnessUtxo
|
|
886
|
+
// witnessScript is not needed
|
|
519
887
|
}
|
|
520
888
|
else if (isP2WSHScript(redeemOutput)) {
|
|
521
|
-
|
|
889
|
+
// P2SH-P2WSH
|
|
890
|
+
// Use witnessUtxo + redeemScript + witnessScript
|
|
891
|
+
Reflect.deleteProperty(input, 'nonWitnessUtxo'); // ensure we do NOT have nonWitnessUtxo
|
|
522
892
|
this.processP2WSHInput(utxo, input, i);
|
|
523
893
|
}
|
|
524
894
|
else {
|
|
525
|
-
|
|
895
|
+
// Legacy P2SH
|
|
896
|
+
// Use nonWitnessUtxo
|
|
897
|
+
Reflect.deleteProperty(input, 'witnessUtxo'); // ensure we do NOT have witnessUtxo
|
|
526
898
|
}
|
|
527
899
|
}
|
|
900
|
+
// Handle P2TR (Taproot)
|
|
528
901
|
else if (isP2TR(scriptPub)) {
|
|
902
|
+
// Taproot inputs do not require nonWitnessUtxo, witnessUtxo is sufficient.
|
|
903
|
+
// If there's a configured sighash type
|
|
529
904
|
if (this.sighashTypes) {
|
|
530
905
|
const inputSign = TweakedTransaction.calculateSignHash(this.sighashTypes);
|
|
531
906
|
if (inputSign)
|
|
532
907
|
input.sighashType = inputSign;
|
|
533
908
|
}
|
|
909
|
+
// Taproot internal key - use per-input signer in address rotation mode
|
|
534
910
|
if (this.addressRotationEnabled) {
|
|
535
911
|
input.tapInternalKey = this.internalPubKeyToXOnlyForInput(i);
|
|
536
912
|
}
|
|
@@ -539,15 +915,19 @@ export class TweakedTransaction extends Logger {
|
|
|
539
915
|
input.tapInternalKey = this.internalPubKeyToXOnly();
|
|
540
916
|
}
|
|
541
917
|
}
|
|
918
|
+
// Handle P2A (Any SegWit version, future versions)
|
|
542
919
|
else if (isP2A(scriptPub)) {
|
|
543
920
|
this.anchorInputIndices.add(i);
|
|
544
921
|
input.isPayToAnchor = true;
|
|
545
922
|
}
|
|
923
|
+
// Handle P2PK (legacy) or P2MS (bare multisig)
|
|
546
924
|
else if (isP2PK(scriptPub) || isP2MS(scriptPub)) {
|
|
925
|
+
// These are legacy scripts, need nonWitnessUtxo
|
|
547
926
|
if (utxo.nonWitnessUtxo) {
|
|
548
|
-
input.nonWitnessUtxo =
|
|
549
|
-
|
|
550
|
-
|
|
927
|
+
input.nonWitnessUtxo =
|
|
928
|
+
utxo.nonWitnessUtxo instanceof Uint8Array
|
|
929
|
+
? utxo.nonWitnessUtxo
|
|
930
|
+
: fromHex(utxo.nonWitnessUtxo);
|
|
551
931
|
}
|
|
552
932
|
else {
|
|
553
933
|
throw new Error('Missing nonWitnessUtxo for P2PK or P2MS UTXO');
|
|
@@ -557,6 +937,7 @@ export class TweakedTransaction extends Logger {
|
|
|
557
937
|
this.error(`Unknown or unsupported script type for output: ${utxo.scriptPubKey.hex}`);
|
|
558
938
|
}
|
|
559
939
|
if (i === 0) {
|
|
940
|
+
// TapLeafScript if available
|
|
560
941
|
if (this.tapLeafScript) {
|
|
561
942
|
input.tapLeafScript = [this.tapLeafScript];
|
|
562
943
|
}
|
|
@@ -564,21 +945,38 @@ export class TweakedTransaction extends Logger {
|
|
|
564
945
|
input.nonWitnessUtxo = this.nonWitnessUtxo;
|
|
565
946
|
}
|
|
566
947
|
}
|
|
948
|
+
/*if (utxo.nonWitnessUtxo && extra) {
|
|
949
|
+
const witness = Buffer.isBuffer(utxo.nonWitnessUtxo)
|
|
950
|
+
? utxo.nonWitnessUtxo
|
|
951
|
+
: typeof utxo.nonWitnessUtxo === 'string'
|
|
952
|
+
? Buffer.from(utxo.nonWitnessUtxo, 'hex')
|
|
953
|
+
: (utxo.nonWitnessUtxo as unknown) instanceof Uint8Array
|
|
954
|
+
? Buffer.from(utxo.nonWitnessUtxo)
|
|
955
|
+
: undefined;
|
|
956
|
+
|
|
957
|
+
input.nonWitnessUtxo = witness;
|
|
958
|
+
}*/
|
|
567
959
|
return input;
|
|
568
960
|
}
|
|
569
961
|
processP2WSHInput(utxo, input, i) {
|
|
962
|
+
// P2WSH requires a witnessScript
|
|
570
963
|
if (!utxo.witnessScript) {
|
|
964
|
+
// Can't just invent a witnessScript out of thin air. If not provided, it's an error.
|
|
571
965
|
throw new Error('Missing witnessScript for P2WSH UTXO');
|
|
572
966
|
}
|
|
573
|
-
input.witnessScript =
|
|
574
|
-
|
|
575
|
-
|
|
967
|
+
input.witnessScript =
|
|
968
|
+
utxo.witnessScript instanceof Uint8Array
|
|
969
|
+
? utxo.witnessScript
|
|
970
|
+
: fromHex(utxo.witnessScript);
|
|
971
|
+
// No nonWitnessUtxo needed for segwit
|
|
576
972
|
const decompiled = script.decompile(input.witnessScript);
|
|
577
973
|
if (decompiled && this.isCSVScript(decompiled)) {
|
|
578
974
|
const decompiled = script.decompile(input.witnessScript);
|
|
579
975
|
if (decompiled && this.isCSVScript(decompiled)) {
|
|
580
976
|
this.csvInputIndices.add(i);
|
|
977
|
+
// Extract CSV value from witness script
|
|
581
978
|
const csvBlocks = this.extractCSVBlocks(decompiled);
|
|
979
|
+
// Use the setCSVSequence method to properly set the sequence
|
|
582
980
|
input.sequence = this.setCSVSequence(csvBlocks, this.sequence);
|
|
583
981
|
}
|
|
584
982
|
}
|
|
@@ -599,6 +997,47 @@ export class TweakedTransaction extends Logger {
|
|
|
599
997
|
extractCSVValue(sequence) {
|
|
600
998
|
return sequence & 0x0000ffff;
|
|
601
999
|
}
|
|
1000
|
+
customFinalizerP2SH = (inputIndex, input, scriptA, isSegwit, isP2SH, isP2WSH, _canRunChecks) => {
|
|
1001
|
+
const inputDecoded = this.inputs[inputIndex];
|
|
1002
|
+
if (isP2SH && input.partialSig && inputDecoded && inputDecoded.redeemScript) {
|
|
1003
|
+
const signatures = input.partialSig.map((sig) => sig.signature) || [];
|
|
1004
|
+
const scriptSig = script.compile([...signatures, inputDecoded.redeemScript]);
|
|
1005
|
+
return {
|
|
1006
|
+
finalScriptSig: scriptSig,
|
|
1007
|
+
finalScriptWitness: undefined,
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
if (this.anchorInputIndices.has(inputIndex)) {
|
|
1011
|
+
return {
|
|
1012
|
+
finalScriptSig: undefined,
|
|
1013
|
+
finalScriptWitness: Uint8Array.from([0]),
|
|
1014
|
+
};
|
|
1015
|
+
}
|
|
1016
|
+
if (isP2WSH && isSegwit && input.witnessScript) {
|
|
1017
|
+
if (!input.partialSig || input.partialSig.length === 0) {
|
|
1018
|
+
throw new Error(`No signatures for P2WSH input #${inputIndex}`);
|
|
1019
|
+
}
|
|
1020
|
+
const isP2WDA = P2WDADetector.isP2WDAWitnessScript(input.witnessScript);
|
|
1021
|
+
if (isP2WDA) {
|
|
1022
|
+
return this.finalizeSecondaryP2WDA(inputIndex, input);
|
|
1023
|
+
}
|
|
1024
|
+
// Check if this is a CSV input
|
|
1025
|
+
const isCSVInput = this.csvInputIndices.has(inputIndex);
|
|
1026
|
+
if (isCSVInput) {
|
|
1027
|
+
// For CSV P2WSH, the witness stack should be: [signature, witnessScript]
|
|
1028
|
+
const witnessStack = [input.partialSig[0].signature, input.witnessScript];
|
|
1029
|
+
return {
|
|
1030
|
+
finalScriptSig: undefined,
|
|
1031
|
+
finalScriptWitness: witnessStackToScriptWitness(witnessStack),
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
1034
|
+
// For non-CSV P2WSH, use default finalization
|
|
1035
|
+
}
|
|
1036
|
+
return getFinalScripts(inputIndex, input, scriptA, isSegwit, isP2SH, isP2WSH, true, this.unlockScript);
|
|
1037
|
+
};
|
|
1038
|
+
/**
|
|
1039
|
+
* Finalize secondary P2WDA inputs with empty data
|
|
1040
|
+
*/
|
|
602
1041
|
finalizeSecondaryP2WDA(inputIndex, input) {
|
|
603
1042
|
if (!input.partialSig || input.partialSig.length === 0) {
|
|
604
1043
|
throw new Error(`No signature for P2WDA input #${inputIndex}`);
|
|
@@ -614,7 +1053,9 @@ export class TweakedTransaction extends Logger {
|
|
|
614
1053
|
}
|
|
615
1054
|
async signInputsWalletBased(transaction) {
|
|
616
1055
|
const signer = this.signer;
|
|
1056
|
+
// then, we sign all the remaining inputs with the wallet signer.
|
|
617
1057
|
await signer.multiSignPsbt([transaction]);
|
|
1058
|
+
// Then, we finalize every input.
|
|
618
1059
|
for (let i = 0; i < transaction.data.inputs.length; i++) {
|
|
619
1060
|
transaction.finalizeInput(i, this.customFinalizerP2SH.bind(this));
|
|
620
1061
|
}
|
|
@@ -630,28 +1071,44 @@ export class TweakedTransaction extends Logger {
|
|
|
630
1071
|
if (csvBlocks > 0xffff) {
|
|
631
1072
|
throw new Error(`CSV blocks ${csvBlocks} exceeds maximum of 65,535`);
|
|
632
1073
|
}
|
|
1074
|
+
// Layout of nSequence field (32 bits) when CSV is active (bit 31 = 0):
|
|
1075
|
+
// Bit 31: Must be 0 (CSV enable flag)
|
|
1076
|
+
// Bits 23-30: Unused by BIP68 (available for custom use)
|
|
1077
|
+
// Bit 22: Time flag (0 = blocks, 1 = time)
|
|
1078
|
+
// Bits 16-21: Unused by BIP68 (available for custom use)
|
|
1079
|
+
// Bits 0-15: CSV lock-time value
|
|
1080
|
+
// Extract the time flag if it's set in csvBlocks
|
|
633
1081
|
const isTimeBased = (csvBlocks & (1 << 22)) !== 0;
|
|
1082
|
+
// Start with the CSV value
|
|
634
1083
|
let sequence = csvBlocks & 0x0000ffff;
|
|
1084
|
+
// Preserve the time flag if set
|
|
635
1085
|
if (isTimeBased) {
|
|
636
1086
|
sequence |= 1 << 22;
|
|
637
1087
|
}
|
|
638
1088
|
if (currentSequence === TransactionSequence.REPLACE_BY_FEE) {
|
|
1089
|
+
// Set bit 25 as our explicit RBF flag
|
|
1090
|
+
// This is in the unused range (bits 23-30) when CSV is active
|
|
639
1091
|
sequence |= 1 << 25;
|
|
1092
|
+
// We could use other unused bits for version/features
|
|
1093
|
+
// sequence |= (1 << 26); // Could indicate tx flags if we wanted
|
|
640
1094
|
}
|
|
1095
|
+
// Final safety check: ensure bit 31 is 0 (CSV enabled)
|
|
641
1096
|
sequence = sequence & 0x7fffffff;
|
|
642
1097
|
return sequence;
|
|
643
1098
|
}
|
|
644
1099
|
getCSVType(csvValue) {
|
|
1100
|
+
// Bit 22 determines if it's time-based (1) or block-based (0)
|
|
645
1101
|
return csvValue & (1 << 22) ? CSVModes.TIMESTAMPS : CSVModes.BLOCKS;
|
|
646
1102
|
}
|
|
647
1103
|
extractCSVBlocks(decompiled) {
|
|
648
1104
|
for (let i = 0; i < decompiled.length; i++) {
|
|
649
1105
|
if (decompiled[i] === opcodes.OP_CHECKSEQUENCEVERIFY && i > 0) {
|
|
650
1106
|
const csvValue = decompiled[i - 1];
|
|
651
|
-
if (
|
|
1107
|
+
if (csvValue instanceof Uint8Array) {
|
|
652
1108
|
return script.number.decode(csvValue);
|
|
653
1109
|
}
|
|
654
1110
|
else if (typeof csvValue === 'number') {
|
|
1111
|
+
// Handle OP_N directly
|
|
655
1112
|
if (csvValue === opcodes.OP_0 || csvValue === opcodes.OP_FALSE) {
|
|
656
1113
|
return 0;
|
|
657
1114
|
}
|
|
@@ -662,6 +1119,8 @@ export class TweakedTransaction extends Logger {
|
|
|
662
1119
|
return csvValue - opcodes.OP_1 + 1;
|
|
663
1120
|
}
|
|
664
1121
|
else {
|
|
1122
|
+
// For other numbers, they should have been Buffers
|
|
1123
|
+
// This shouldn't happen in properly decompiled scripts
|
|
665
1124
|
throw new Error(`Unexpected raw number in script: ${csvValue}`);
|
|
666
1125
|
}
|
|
667
1126
|
}
|
|
@@ -703,8 +1162,10 @@ export class TweakedTransaction extends Logger {
|
|
|
703
1162
|
}
|
|
704
1163
|
isTaprootScriptSpend(input, publicKey) {
|
|
705
1164
|
if (input.tapLeafScript && input.tapLeafScript.length > 0) {
|
|
1165
|
+
// Check if the signer's public key is involved in any tapLeafScript
|
|
706
1166
|
for (const tapLeafScript of input.tapLeafScript) {
|
|
707
1167
|
if (pubkeyInScript(publicKey, tapLeafScript.script)) {
|
|
1168
|
+
// The public key is in the script; it's a script spend
|
|
708
1169
|
return true;
|
|
709
1170
|
}
|
|
710
1171
|
}
|
|
@@ -721,7 +1182,7 @@ export class TweakedTransaction extends Logger {
|
|
|
721
1182
|
}
|
|
722
1183
|
}
|
|
723
1184
|
else {
|
|
724
|
-
transaction.signTaprootInput(i, signer);
|
|
1185
|
+
transaction.signTaprootInput(i, signer); //tapLeafHash
|
|
725
1186
|
}
|
|
726
1187
|
}
|
|
727
1188
|
async signNonTaprootInput(signer, transaction, i) {
|
|
@@ -733,3 +1194,4 @@ export class TweakedTransaction extends Logger {
|
|
|
733
1194
|
}
|
|
734
1195
|
}
|
|
735
1196
|
}
|
|
1197
|
+
//# sourceMappingURL=TweakedTransaction.js.map
|