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