@btc-vision/transaction 1.8.0-beta.1 → 1.8.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/_version.d.ts +1 -0
- package/browser/_version.d.ts.map +1 -0
- package/browser/abi/ABICoder.d.ts +1 -1
- package/browser/abi/ABICoder.d.ts.map +1 -0
- package/browser/branded/Branded.d.ts +4 -0
- package/browser/branded/Branded.d.ts.map +1 -0
- package/browser/btc-vision-bitcoin.js +12420 -3637
- 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 +3602 -3203
- package/browser/keypair/Address.d.ts +283 -13
- package/browser/keypair/Address.d.ts.map +1 -0
- package/browser/keypair/AddressVerificator.d.ts +7 -6
- package/browser/keypair/AddressVerificator.d.ts.map +1 -0
- package/browser/keypair/EcKeyPair.d.ts +183 -21
- package/browser/keypair/EcKeyPair.d.ts.map +1 -0
- package/browser/keypair/MessageSigner.d.ts +17 -16
- package/browser/keypair/MessageSigner.d.ts.map +1 -0
- package/browser/keypair/Secp256k1PointDeriver.d.ts +55 -0
- package/browser/keypair/Secp256k1PointDeriver.d.ts.map +1 -0
- package/browser/keypair/Wallet.d.ts +27 -13
- package/browser/keypair/Wallet.d.ts.map +1 -0
- package/browser/keypair/interfaces/IWallet.d.ts +19 -0
- package/browser/keypair/interfaces/IWallet.d.ts.map +1 -0
- package/browser/metadata/ContractBaseMetadata.d.ts +10 -2
- package/browser/metadata/ContractBaseMetadata.d.ts.map +1 -0
- package/browser/mnemonic/BIPStandard.d.ts +59 -0
- package/browser/mnemonic/BIPStandard.d.ts.map +1 -0
- package/browser/mnemonic/Mnemonic.d.ts +15 -3
- package/browser/mnemonic/Mnemonic.d.ts.map +1 -0
- package/browser/mnemonic/MnemonicStrength.d.ts +6 -0
- package/browser/mnemonic/MnemonicStrength.d.ts.map +1 -0
- package/browser/network/ChainId.d.ts +1 -0
- package/browser/network/ChainId.d.ts.map +1 -0
- package/browser/noble-curves.js +920 -2966
- package/browser/noble-hashes.js +2067 -1038
- package/browser/opnet.d.ts +22 -1
- package/browser/opnet.d.ts.map +1 -0
- package/browser/p2wda/P2WDADetector.d.ts +36 -9
- package/browser/p2wda/P2WDADetector.d.ts.map +1 -0
- package/browser/polyfill/disposable.d.ts +16 -0
- package/browser/polyfill/disposable.d.ts.map +1 -0
- package/browser/signer/AddressRotation.d.ts +36 -0
- package/browser/signer/AddressRotation.d.ts.map +1 -0
- package/browser/signer/IRotationSigner.d.ts +27 -3
- package/browser/signer/IRotationSigner.d.ts.map +1 -0
- package/browser/signer/ParallelSignerAdapter.d.ts +14 -0
- package/browser/signer/ParallelSignerAdapter.d.ts.map +1 -0
- package/browser/signer/SignerUtils.d.ts +11 -4
- package/browser/signer/SignerUtils.d.ts.map +1 -0
- package/browser/signer/TweakedSigner.d.ts +28 -4
- package/browser/signer/TweakedSigner.d.ts.map +1 -0
- package/browser/transaction/ContractAddress.d.ts +2 -2
- package/browser/transaction/ContractAddress.d.ts.map +1 -0
- package/browser/transaction/TransactionFactory.d.ts +140 -2
- package/browser/transaction/TransactionFactory.d.ts.map +1 -0
- package/browser/transaction/browser/BrowserSignerBase.d.ts +12 -6
- package/browser/transaction/browser/BrowserSignerBase.d.ts.map +1 -0
- package/browser/transaction/browser/WalletNetworks.d.ts +1 -0
- package/browser/transaction/browser/WalletNetworks.d.ts.map +1 -0
- package/browser/transaction/browser/Web3Provider.d.ts +27 -0
- package/browser/transaction/browser/Web3Provider.d.ts.map +1 -0
- package/browser/transaction/browser/extensions/UnisatSigner.d.ts +9 -7
- package/browser/transaction/browser/extensions/UnisatSigner.d.ts.map +1 -0
- package/browser/transaction/browser/extensions/XverseSigner.d.ts +9 -7
- package/browser/transaction/browser/extensions/XverseSigner.d.ts.map +1 -0
- package/browser/transaction/browser/types/OPWallet.d.ts +10 -0
- package/browser/transaction/browser/types/OPWallet.d.ts.map +1 -0
- package/browser/transaction/browser/types/Unisat.d.ts +1 -0
- package/browser/transaction/browser/types/Unisat.d.ts.map +1 -0
- package/browser/transaction/browser/types/Xverse.d.ts +1 -0
- package/browser/transaction/browser/types/Xverse.d.ts.map +1 -0
- package/browser/transaction/builders/CancelTransaction.d.ts +29 -4
- package/browser/transaction/builders/CancelTransaction.d.ts.map +1 -0
- package/browser/transaction/builders/ChallengeSolutionTransaction.d.ts +1 -0
- package/browser/transaction/builders/ChallengeSolutionTransaction.d.ts.map +1 -0
- package/browser/transaction/builders/ConsolidatedInteractionTransaction.d.ts +137 -10
- package/browser/transaction/builders/ConsolidatedInteractionTransaction.d.ts.map +1 -0
- package/browser/transaction/builders/CustomScriptTransaction.d.ts +106 -6
- package/browser/transaction/builders/CustomScriptTransaction.d.ts.map +1 -0
- package/browser/transaction/builders/DeploymentTransaction.d.ts +116 -5
- package/browser/transaction/builders/DeploymentTransaction.d.ts.map +1 -0
- package/browser/transaction/builders/FundingTransaction.d.ts +4 -3
- package/browser/transaction/builders/FundingTransaction.d.ts.map +1 -0
- package/browser/transaction/builders/InteractionTransaction.d.ts +12 -3
- package/browser/transaction/builders/InteractionTransaction.d.ts.map +1 -0
- package/browser/transaction/builders/InteractionTransactionP2WDA.d.ts +56 -5
- package/browser/transaction/builders/InteractionTransactionP2WDA.d.ts.map +1 -0
- package/browser/transaction/builders/MultiSignTransaction.d.ts +125 -16
- package/browser/transaction/builders/MultiSignTransaction.d.ts.map +1 -0
- package/browser/transaction/builders/SharedInteractionTransaction.d.ts +103 -15
- package/browser/transaction/builders/SharedInteractionTransaction.d.ts.map +1 -0
- package/browser/transaction/builders/TransactionBuilder.d.ts +243 -14
- package/browser/transaction/builders/TransactionBuilder.d.ts.map +1 -0
- package/browser/transaction/enums/TransactionType.d.ts +1 -0
- package/browser/transaction/enums/TransactionType.d.ts.map +1 -0
- package/browser/transaction/interfaces/ICancelTransactionParameters.d.ts +2 -1
- package/browser/transaction/interfaces/ICancelTransactionParameters.d.ts.map +1 -0
- package/browser/transaction/interfaces/IConsolidatedTransactionParameters.d.ts +46 -3
- package/browser/transaction/interfaces/IConsolidatedTransactionParameters.d.ts.map +1 -0
- package/browser/transaction/interfaces/ICustomTransactionParameters.d.ts +6 -4
- package/browser/transaction/interfaces/ICustomTransactionParameters.d.ts.map +1 -0
- package/browser/transaction/interfaces/ITransactionParameters.d.ts +22 -10
- package/browser/transaction/interfaces/ITransactionParameters.d.ts.map +1 -0
- package/browser/transaction/interfaces/ITransactionResponses.d.ts +1 -0
- package/browser/transaction/interfaces/ITransactionResponses.d.ts.map +1 -0
- package/browser/transaction/interfaces/ITweakedTransactionData.d.ts +18 -5
- package/browser/transaction/interfaces/ITweakedTransactionData.d.ts.map +1 -0
- package/browser/transaction/interfaces/IWeb3ProviderTypes.d.ts +26 -0
- package/browser/transaction/interfaces/IWeb3ProviderTypes.d.ts.map +1 -0
- package/browser/transaction/interfaces/Tap.d.ts +4 -3
- package/browser/transaction/interfaces/Tap.d.ts.map +1 -0
- package/browser/transaction/mineable/IP2WSHAddress.d.ts +2 -1
- package/browser/transaction/mineable/IP2WSHAddress.d.ts.map +1 -0
- package/browser/transaction/mineable/TimelockGenerator.d.ts +12 -3
- package/browser/transaction/mineable/TimelockGenerator.d.ts.map +1 -0
- package/browser/transaction/offline/OfflineTransactionManager.d.ts +190 -9
- package/browser/transaction/offline/OfflineTransactionManager.d.ts.map +1 -0
- package/browser/transaction/offline/TransactionReconstructor.d.ts +53 -3
- package/browser/transaction/offline/TransactionReconstructor.d.ts.map +1 -0
- package/browser/transaction/offline/TransactionSerializer.d.ts +53 -2
- package/browser/transaction/offline/TransactionSerializer.d.ts.map +1 -0
- package/browser/transaction/offline/TransactionStateCapture.d.ts +64 -5
- package/browser/transaction/offline/TransactionStateCapture.d.ts.map +1 -0
- package/browser/transaction/offline/interfaces/ISerializableState.d.ts +71 -0
- package/browser/transaction/offline/interfaces/ISerializableState.d.ts.map +1 -0
- package/browser/transaction/offline/interfaces/ITypeSpecificData.d.ts +76 -0
- package/browser/transaction/offline/interfaces/ITypeSpecificData.d.ts.map +1 -0
- package/browser/transaction/psbt/PSBTTypes.d.ts +1 -0
- package/browser/transaction/psbt/PSBTTypes.d.ts.map +1 -0
- package/browser/transaction/shared/P2TR_MS.d.ts +11 -2
- package/browser/transaction/shared/P2TR_MS.d.ts.map +1 -0
- package/browser/transaction/shared/TweakedTransaction.d.ts +275 -33
- package/browser/transaction/shared/TweakedTransaction.d.ts.map +1 -0
- package/browser/transaction/utils/WitnessUtils.d.ts +7 -1
- package/browser/transaction/utils/WitnessUtils.d.ts.map +1 -0
- package/browser/utils/BitcoinUtils.d.ts +19 -0
- package/browser/utils/BitcoinUtils.d.ts.map +1 -0
- package/browser/utils/BufferHelper.d.ts +1 -0
- package/browser/utils/BufferHelper.d.ts.map +1 -0
- package/browser/utils/StringToBuffer.d.ts +1 -0
- package/browser/utils/StringToBuffer.d.ts.map +1 -0
- package/browser/utils/lengths.d.ts +1 -0
- package/browser/utils/lengths.d.ts.map +1 -0
- package/browser/utils/types.d.ts +1 -0
- package/browser/utils/types.d.ts.map +1 -0
- package/browser/utxo/OPNetLimitedProvider.d.ts +37 -1
- package/browser/utxo/OPNetLimitedProvider.d.ts.map +1 -0
- package/browser/utxo/interfaces/BroadcastResponse.d.ts +1 -0
- package/browser/utxo/interfaces/BroadcastResponse.d.ts.map +1 -0
- package/browser/utxo/interfaces/IUTXO.d.ts +11 -5
- package/browser/utxo/interfaces/IUTXO.d.ts.map +1 -0
- package/browser/vendors.js +13940 -9389
- package/browser/verification/TapscriptVerificator.d.ts +10 -8
- package/browser/verification/TapscriptVerificator.d.ts.map +1 -0
- package/build/_version.d.ts +1 -0
- package/build/_version.d.ts.map +1 -0
- package/build/_version.js +1 -0
- package/build/_version.js.map +1 -0
- package/build/abi/ABICoder.d.ts +1 -1
- package/build/abi/ABICoder.d.ts.map +1 -0
- package/build/abi/ABICoder.js +9 -10
- package/build/abi/ABICoder.js.map +1 -0
- package/build/branded/Branded.d.ts +4 -0
- package/build/branded/Branded.d.ts.map +1 -0
- package/build/branded/Branded.js +2 -0
- package/build/branded/Branded.js.map +1 -0
- package/build/buffer/BinaryReader.d.ts +121 -2
- package/build/buffer/BinaryReader.d.ts.map +1 -0
- package/build/buffer/BinaryReader.js +129 -5
- package/build/buffer/BinaryReader.js.map +1 -0
- package/build/buffer/BinaryWriter.d.ts +52 -2
- package/build/buffer/BinaryWriter.d.ts.map +1 -0
- package/build/buffer/BinaryWriter.js +62 -2
- package/build/buffer/BinaryWriter.js.map +1 -0
- package/build/bytecode/Compressor.d.ts +12 -0
- package/build/bytecode/Compressor.d.ts.map +1 -0
- package/build/bytecode/Compressor.js +17 -5
- package/build/bytecode/Compressor.js.map +1 -0
- package/build/chain/ChainData.d.ts +2 -2
- package/build/chain/ChainData.d.ts.map +1 -0
- package/build/chain/ChainData.js +35 -17
- package/build/chain/ChainData.js.map +1 -0
- package/build/consensus/Consensus.d.ts +11 -3
- package/build/consensus/Consensus.d.ts.map +1 -0
- package/build/consensus/Consensus.js +8 -0
- package/build/consensus/Consensus.js.map +1 -0
- package/build/consensus/ConsensusConfig.d.ts +2 -1
- package/build/consensus/ConsensusConfig.d.ts.map +1 -0
- package/build/consensus/ConsensusConfig.js +1 -0
- package/build/consensus/ConsensusConfig.js.map +1 -0
- package/build/consensus/IConsensusConfig.d.ts +1 -0
- package/build/consensus/IConsensusConfig.d.ts.map +1 -0
- package/build/consensus/IConsensusConfig.js +2 -1
- package/build/consensus/IConsensusConfig.js.map +1 -0
- package/build/consensus/metadata/RoswellConsensus.d.ts +2 -1
- package/build/consensus/metadata/RoswellConsensus.d.ts.map +1 -0
- package/build/consensus/metadata/RoswellConsensus.js +2 -0
- package/build/consensus/metadata/RoswellConsensus.js.map +1 -0
- package/build/crypto/crypto.d.ts +1 -0
- package/build/crypto/crypto.d.ts.map +1 -0
- package/build/crypto/crypto.js +1 -0
- package/build/crypto/crypto.js.map +1 -0
- package/build/deterministic/AddressMap.d.ts +6 -1
- package/build/deterministic/AddressMap.d.ts.map +1 -0
- package/build/deterministic/AddressMap.js +8 -0
- package/build/deterministic/AddressMap.js.map +1 -0
- package/build/deterministic/AddressSet.d.ts +3 -1
- package/build/deterministic/AddressSet.d.ts.map +1 -0
- package/build/deterministic/AddressSet.js +7 -0
- package/build/deterministic/AddressSet.js.map +1 -0
- package/build/deterministic/CustomMap.d.ts +3 -1
- package/build/deterministic/CustomMap.d.ts.map +1 -0
- package/build/deterministic/CustomMap.js +65 -47
- package/build/deterministic/CustomMap.js.map +1 -0
- package/build/deterministic/DeterministicMap.d.ts +4 -2
- package/build/deterministic/DeterministicMap.d.ts.map +1 -0
- package/build/deterministic/DeterministicMap.js +24 -27
- package/build/deterministic/DeterministicMap.js.map +1 -0
- package/build/deterministic/DeterministicSet.d.ts +3 -1
- package/build/deterministic/DeterministicSet.d.ts.map +1 -0
- package/build/deterministic/DeterministicSet.js +6 -0
- package/build/deterministic/DeterministicSet.js.map +1 -0
- package/build/deterministic/ExtendedAddressMap.d.ts +7 -1
- package/build/deterministic/ExtendedAddressMap.d.ts.map +1 -0
- package/build/deterministic/ExtendedAddressMap.js +18 -2
- package/build/deterministic/ExtendedAddressMap.js.map +1 -0
- package/build/deterministic/FastMap.d.ts +7 -1
- package/build/deterministic/FastMap.d.ts.map +1 -0
- package/build/deterministic/FastMap.js +7 -2
- package/build/deterministic/FastMap.js.map +1 -0
- package/build/ecc/backend.d.ts +13 -0
- package/build/ecc/backend.d.ts.map +1 -0
- package/build/ecc/backend.js +15 -0
- package/build/ecc/backend.js.map +1 -0
- package/build/epoch/ChallengeSolution.d.ts +34 -2
- package/build/epoch/ChallengeSolution.d.ts.map +1 -0
- package/build/epoch/ChallengeSolution.js +52 -0
- package/build/epoch/ChallengeSolution.js.map +1 -0
- package/build/epoch/interfaces/IChallengeSolution.d.ts +14 -13
- package/build/epoch/interfaces/IChallengeSolution.d.ts.map +1 -0
- package/build/epoch/interfaces/IChallengeSolution.js +2 -1
- package/build/epoch/interfaces/IChallengeSolution.js.map +1 -0
- package/build/epoch/validator/EpochValidator.d.ts +38 -8
- package/build/epoch/validator/EpochValidator.d.ts.map +1 -0
- package/build/epoch/validator/EpochValidator.js +45 -19
- package/build/epoch/validator/EpochValidator.js.map +1 -0
- package/build/event/NetEvent.d.ts +1 -0
- package/build/event/NetEvent.d.ts.map +1 -0
- package/build/event/NetEvent.js +3 -0
- package/build/event/NetEvent.js.map +1 -0
- package/build/generators/AddressGenerator.d.ts +4 -3
- package/build/generators/AddressGenerator.d.ts.map +1 -0
- package/build/generators/AddressGenerator.js +10 -3
- package/build/generators/AddressGenerator.js.map +1 -0
- package/build/generators/Features.d.ts +4 -3
- package/build/generators/Features.d.ts.map +1 -0
- package/build/generators/Features.js +1 -0
- package/build/generators/Features.js.map +1 -0
- package/build/generators/Generator.d.ts +47 -11
- package/build/generators/Generator.d.ts.map +1 -0
- package/build/generators/Generator.js +48 -12
- package/build/generators/Generator.js.map +1 -0
- package/build/generators/MLDSAData.d.ts +1 -0
- package/build/generators/MLDSAData.d.ts.map +1 -0
- package/build/generators/MLDSAData.js +1 -0
- package/build/generators/MLDSAData.js.map +1 -0
- package/build/generators/builders/CalldataGenerator.d.ts +27 -6
- package/build/generators/builders/CalldataGenerator.d.ts.map +1 -0
- package/build/generators/builders/CalldataGenerator.js +33 -4
- package/build/generators/builders/CalldataGenerator.js.map +1 -0
- package/build/generators/builders/CustomGenerator.d.ts +13 -3
- package/build/generators/builders/CustomGenerator.d.ts.map +1 -0
- package/build/generators/builders/CustomGenerator.js +11 -0
- package/build/generators/builders/CustomGenerator.js.map +1 -0
- package/build/generators/builders/DeploymentGenerator.d.ts +17 -6
- package/build/generators/builders/DeploymentGenerator.d.ts.map +1 -0
- package/build/generators/builders/DeploymentGenerator.js +18 -2
- package/build/generators/builders/DeploymentGenerator.js.map +1 -0
- package/build/generators/builders/HashCommitmentGenerator.d.ts +166 -14
- package/build/generators/builders/HashCommitmentGenerator.d.ts.map +1 -0
- package/build/generators/builders/HashCommitmentGenerator.js +193 -27
- package/build/generators/builders/HashCommitmentGenerator.js.map +1 -0
- package/build/generators/builders/LegacyCalldataGenerator.d.ts +27 -5
- package/build/generators/builders/LegacyCalldataGenerator.d.ts.map +1 -0
- package/build/generators/builders/LegacyCalldataGenerator.js +35 -5
- package/build/generators/builders/LegacyCalldataGenerator.js.map +1 -0
- package/build/generators/builders/MultiSignGenerator.d.ts +6 -1
- package/build/generators/builders/MultiSignGenerator.d.ts.map +1 -0
- package/build/generators/builders/MultiSignGenerator.js +20 -10
- package/build/generators/builders/MultiSignGenerator.js.map +1 -0
- package/build/generators/builders/P2WDAGenerator.d.ts +44 -6
- package/build/generators/builders/P2WDAGenerator.d.ts.map +1 -0
- package/build/generators/builders/P2WDAGenerator.js +41 -2
- package/build/generators/builders/P2WDAGenerator.js.map +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +1 -0
- package/build/index.js.map +1 -0
- package/build/keypair/Address.d.ts +284 -14
- package/build/keypair/Address.d.ts.map +1 -0
- package/build/keypair/Address.js +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 +6 -5
- package/build/keypair/AddressVerificator.js.map +1 -0
- package/build/keypair/EcKeyPair.d.ts +185 -23
- package/build/keypair/EcKeyPair.d.ts.map +1 -0
- package/build/keypair/EcKeyPair.js +223 -54
- package/build/keypair/EcKeyPair.js.map +1 -0
- package/build/keypair/MessageSigner.d.ts +18 -17
- package/build/keypair/MessageSigner.d.ts.map +1 -0
- package/build/keypair/MessageSigner.js +34 -25
- package/build/keypair/MessageSigner.js.map +1 -0
- package/build/keypair/Secp256k1PointDeriver.d.ts +55 -0
- package/build/keypair/Secp256k1PointDeriver.d.ts.map +1 -0
- package/build/keypair/Secp256k1PointDeriver.js +66 -0
- package/build/keypair/Secp256k1PointDeriver.js.map +1 -0
- package/build/keypair/Wallet.d.ts +29 -15
- package/build/keypair/Wallet.d.ts.map +1 -0
- package/build/keypair/Wallet.js +48 -14
- package/build/keypair/Wallet.js.map +1 -0
- package/build/keypair/interfaces/IWallet.d.ts +19 -0
- package/build/keypair/interfaces/IWallet.d.ts.map +1 -0
- package/build/keypair/interfaces/IWallet.js +1 -0
- package/build/keypair/interfaces/IWallet.js.map +1 -0
- package/build/metadata/ContractBaseMetadata.d.ts +10 -2
- package/build/metadata/ContractBaseMetadata.d.ts.map +1 -0
- package/build/metadata/ContractBaseMetadata.js +10 -1
- package/build/metadata/ContractBaseMetadata.js.map +1 -0
- package/build/mnemonic/BIPStandard.d.ts +59 -0
- package/build/mnemonic/BIPStandard.d.ts.map +1 -0
- package/build/mnemonic/BIPStandard.js +59 -0
- package/build/mnemonic/BIPStandard.js.map +1 -0
- package/build/mnemonic/Mnemonic.d.ts +16 -4
- package/build/mnemonic/Mnemonic.d.ts.map +1 -0
- package/build/mnemonic/Mnemonic.js +36 -8
- package/build/mnemonic/Mnemonic.js.map +1 -0
- package/build/mnemonic/MnemonicStrength.d.ts +6 -0
- package/build/mnemonic/MnemonicStrength.d.ts.map +1 -0
- package/build/mnemonic/MnemonicStrength.js +6 -0
- package/build/mnemonic/MnemonicStrength.js.map +1 -0
- package/build/network/ChainId.d.ts +1 -0
- package/build/network/ChainId.d.ts.map +1 -0
- package/build/network/ChainId.js +1 -0
- package/build/network/ChainId.js.map +1 -0
- package/build/opnet.d.ts +26 -3
- package/build/opnet.d.ts.map +1 -0
- package/build/opnet.js +23 -0
- package/build/opnet.js.map +1 -0
- package/build/p2wda/P2WDADetector.d.ts +38 -11
- package/build/p2wda/P2WDADetector.d.ts.map +1 -0
- package/build/p2wda/P2WDADetector.js +43 -10
- package/build/p2wda/P2WDADetector.js.map +1 -0
- package/build/polyfill/disposable.d.ts +16 -0
- package/build/polyfill/disposable.d.ts.map +1 -0
- package/build/polyfill/disposable.js +23 -0
- package/build/polyfill/disposable.js.map +1 -0
- package/build/signer/AddressRotation.d.ts +37 -1
- package/build/signer/AddressRotation.d.ts.map +1 -0
- package/build/signer/AddressRotation.js +16 -0
- package/build/signer/AddressRotation.js.map +1 -0
- package/build/signer/IRotationSigner.d.ts +27 -3
- package/build/signer/IRotationSigner.d.ts.map +1 -0
- package/build/signer/IRotationSigner.js +2 -1
- package/build/signer/IRotationSigner.js.map +1 -0
- package/build/signer/ParallelSignerAdapter.d.ts +14 -0
- package/build/signer/ParallelSignerAdapter.d.ts.map +1 -0
- package/build/signer/ParallelSignerAdapter.js +51 -0
- package/build/signer/ParallelSignerAdapter.js.map +1 -0
- package/build/signer/SignerUtils.d.ts +11 -4
- package/build/signer/SignerUtils.d.ts.map +1 -0
- package/build/signer/SignerUtils.js +16 -0
- package/build/signer/SignerUtils.js.map +1 -0
- package/build/signer/TweakedSigner.d.ts +28 -4
- package/build/signer/TweakedSigner.d.ts.map +1 -0
- package/build/signer/TweakedSigner.js +24 -6
- package/build/signer/TweakedSigner.js.map +1 -0
- package/build/transaction/ContractAddress.d.ts +2 -2
- package/build/transaction/ContractAddress.d.ts.map +1 -0
- package/build/transaction/ContractAddress.js +4 -8
- package/build/transaction/ContractAddress.js.map +1 -0
- package/build/transaction/TransactionFactory.d.ts +147 -9
- package/build/transaction/TransactionFactory.d.ts.map +1 -0
- package/build/transaction/TransactionFactory.js +145 -26
- package/build/transaction/TransactionFactory.js.map +1 -0
- package/build/transaction/browser/BrowserSignerBase.d.ts +12 -6
- package/build/transaction/browser/BrowserSignerBase.d.ts.map +1 -0
- package/build/transaction/browser/BrowserSignerBase.js +7 -0
- package/build/transaction/browser/BrowserSignerBase.js.map +1 -0
- package/build/transaction/browser/WalletNetworks.d.ts +1 -0
- package/build/transaction/browser/WalletNetworks.d.ts.map +1 -0
- package/build/transaction/browser/WalletNetworks.js +1 -0
- package/build/transaction/browser/WalletNetworks.js.map +1 -0
- package/build/transaction/browser/Web3Provider.d.ts +30 -3
- package/build/transaction/browser/Web3Provider.d.ts.map +1 -0
- package/build/transaction/browser/Web3Provider.js +1 -0
- package/build/transaction/browser/Web3Provider.js.map +1 -0
- package/build/transaction/browser/extensions/UnisatSigner.d.ts +11 -9
- package/build/transaction/browser/extensions/UnisatSigner.d.ts.map +1 -0
- package/build/transaction/browser/extensions/UnisatSigner.js +27 -17
- package/build/transaction/browser/extensions/UnisatSigner.js.map +1 -0
- package/build/transaction/browser/extensions/XverseSigner.d.ts +10 -8
- package/build/transaction/browser/extensions/XverseSigner.d.ts.map +1 -0
- package/build/transaction/browser/extensions/XverseSigner.js +25 -15
- package/build/transaction/browser/extensions/XverseSigner.js.map +1 -0
- package/build/transaction/browser/types/OPWallet.d.ts +12 -2
- package/build/transaction/browser/types/OPWallet.d.ts.map +1 -0
- package/build/transaction/browser/types/OPWallet.js +4 -0
- package/build/transaction/browser/types/OPWallet.js.map +1 -0
- package/build/transaction/browser/types/Unisat.d.ts +2 -1
- package/build/transaction/browser/types/Unisat.d.ts.map +1 -0
- package/build/transaction/browser/types/Unisat.js +2 -0
- package/build/transaction/browser/types/Unisat.js.map +1 -0
- package/build/transaction/browser/types/Xverse.d.ts +1 -0
- package/build/transaction/browser/types/Xverse.d.ts.map +1 -0
- package/build/transaction/browser/types/Xverse.js +1 -0
- package/build/transaction/browser/types/Xverse.js.map +1 -0
- package/build/transaction/builders/CancelTransaction.d.ts +31 -6
- package/build/transaction/builders/CancelTransaction.d.ts.map +1 -0
- package/build/transaction/builders/CancelTransaction.js +116 -33
- package/build/transaction/builders/CancelTransaction.js.map +1 -0
- package/build/transaction/builders/ChallengeSolutionTransaction.d.ts +1 -0
- package/build/transaction/builders/ChallengeSolutionTransaction.d.ts.map +1 -0
- package/build/transaction/builders/ChallengeSolutionTransaction.js +88 -0
- package/build/transaction/builders/ChallengeSolutionTransaction.js.map +1 -0
- package/build/transaction/builders/ConsolidatedInteractionTransaction.d.ts +140 -13
- package/build/transaction/builders/ConsolidatedInteractionTransaction.d.ts.map +1 -0
- package/build/transaction/builders/ConsolidatedInteractionTransaction.js +197 -20
- package/build/transaction/builders/ConsolidatedInteractionTransaction.js.map +1 -0
- package/build/transaction/builders/CustomScriptTransaction.d.ts +108 -8
- package/build/transaction/builders/CustomScriptTransaction.d.ts.map +1 -0
- package/build/transaction/builders/CustomScriptTransaction.js +176 -39
- package/build/transaction/builders/CustomScriptTransaction.js.map +1 -0
- package/build/transaction/builders/DeploymentTransaction.d.ts +120 -9
- package/build/transaction/builders/DeploymentTransaction.d.ts.map +1 -0
- package/build/transaction/builders/DeploymentTransaction.js +194 -51
- package/build/transaction/builders/DeploymentTransaction.js.map +1 -0
- package/build/transaction/builders/FundingTransaction.d.ts +5 -4
- package/build/transaction/builders/FundingTransaction.d.ts.map +1 -0
- package/build/transaction/builders/FundingTransaction.js +15 -8
- package/build/transaction/builders/FundingTransaction.js.map +1 -0
- package/build/transaction/builders/InteractionTransaction.d.ts +14 -5
- package/build/transaction/builders/InteractionTransaction.d.ts.map +1 -0
- package/build/transaction/builders/InteractionTransaction.js +18 -5
- package/build/transaction/builders/InteractionTransaction.js.map +1 -0
- package/build/transaction/builders/InteractionTransactionP2WDA.d.ts +58 -7
- package/build/transaction/builders/InteractionTransactionP2WDA.d.ts.map +1 -0
- package/build/transaction/builders/InteractionTransactionP2WDA.js +95 -18
- package/build/transaction/builders/InteractionTransactionP2WDA.js.map +1 -0
- package/build/transaction/builders/MultiSignTransaction.d.ts +126 -17
- package/build/transaction/builders/MultiSignTransaction.d.ts.map +1 -0
- package/build/transaction/builders/MultiSignTransaction.js +201 -76
- package/build/transaction/builders/MultiSignTransaction.js.map +1 -0
- package/build/transaction/builders/SharedInteractionTransaction.d.ts +106 -18
- package/build/transaction/builders/SharedInteractionTransaction.d.ts.map +1 -0
- package/build/transaction/builders/SharedInteractionTransaction.js +158 -40
- package/build/transaction/builders/SharedInteractionTransaction.js.map +1 -0
- package/build/transaction/builders/TransactionBuilder.d.ts +249 -19
- package/build/transaction/builders/TransactionBuilder.d.ts.map +1 -0
- package/build/transaction/builders/TransactionBuilder.js +377 -60
- package/build/transaction/builders/TransactionBuilder.js.map +1 -0
- package/build/transaction/enums/TransactionType.d.ts +1 -0
- package/build/transaction/enums/TransactionType.d.ts.map +1 -0
- package/build/transaction/enums/TransactionType.js +1 -0
- package/build/transaction/enums/TransactionType.js.map +1 -0
- package/build/transaction/interfaces/ICancelTransactionParameters.d.ts +3 -2
- package/build/transaction/interfaces/ICancelTransactionParameters.d.ts.map +1 -0
- package/build/transaction/interfaces/ICancelTransactionParameters.js +1 -0
- package/build/transaction/interfaces/ICancelTransactionParameters.js.map +1 -0
- package/build/transaction/interfaces/IConsolidatedTransactionParameters.d.ts +48 -5
- package/build/transaction/interfaces/IConsolidatedTransactionParameters.d.ts.map +1 -0
- package/build/transaction/interfaces/IConsolidatedTransactionParameters.js +1 -0
- package/build/transaction/interfaces/IConsolidatedTransactionParameters.js.map +1 -0
- package/build/transaction/interfaces/ICustomTransactionParameters.d.ts +7 -5
- package/build/transaction/interfaces/ICustomTransactionParameters.d.ts.map +1 -0
- package/build/transaction/interfaces/ICustomTransactionParameters.js +1 -0
- package/build/transaction/interfaces/ICustomTransactionParameters.js.map +1 -0
- package/build/transaction/interfaces/ITransactionParameters.d.ts +27 -15
- package/build/transaction/interfaces/ITransactionParameters.d.ts.map +1 -0
- package/build/transaction/interfaces/ITransactionParameters.js +1 -0
- package/build/transaction/interfaces/ITransactionParameters.js.map +1 -0
- package/build/transaction/interfaces/ITransactionResponses.d.ts +3 -2
- package/build/transaction/interfaces/ITransactionResponses.d.ts.map +1 -0
- package/build/transaction/interfaces/ITransactionResponses.js +1 -0
- package/build/transaction/interfaces/ITransactionResponses.js.map +1 -0
- package/build/transaction/interfaces/ITweakedTransactionData.d.ts +21 -8
- package/build/transaction/interfaces/ITweakedTransactionData.d.ts.map +1 -0
- package/build/transaction/interfaces/ITweakedTransactionData.js +1 -0
- package/build/transaction/interfaces/ITweakedTransactionData.js.map +1 -0
- package/build/transaction/interfaces/IWeb3ProviderTypes.d.ts +29 -3
- package/build/transaction/interfaces/IWeb3ProviderTypes.d.ts.map +1 -0
- package/build/transaction/interfaces/IWeb3ProviderTypes.js +2 -1
- package/build/transaction/interfaces/IWeb3ProviderTypes.js.map +1 -0
- package/build/transaction/interfaces/Tap.d.ts +4 -3
- package/build/transaction/interfaces/Tap.d.ts.map +1 -0
- package/build/transaction/interfaces/Tap.js +1 -0
- package/build/transaction/interfaces/Tap.js.map +1 -0
- package/build/transaction/mineable/IP2WSHAddress.d.ts +2 -1
- package/build/transaction/mineable/IP2WSHAddress.d.ts.map +1 -0
- package/build/transaction/mineable/IP2WSHAddress.js +1 -0
- package/build/transaction/mineable/IP2WSHAddress.js.map +1 -0
- package/build/transaction/mineable/TimelockGenerator.d.ts +13 -4
- package/build/transaction/mineable/TimelockGenerator.d.ts.map +1 -0
- package/build/transaction/mineable/TimelockGenerator.js +12 -3
- package/build/transaction/mineable/TimelockGenerator.js.map +1 -0
- package/build/transaction/offline/OfflineTransactionManager.d.ts +193 -12
- package/build/transaction/offline/OfflineTransactionManager.d.ts.map +1 -0
- package/build/transaction/offline/OfflineTransactionManager.js +192 -8
- package/build/transaction/offline/OfflineTransactionManager.js.map +1 -0
- package/build/transaction/offline/TransactionReconstructor.d.ts +56 -6
- package/build/transaction/offline/TransactionReconstructor.d.ts.map +1 -0
- package/build/transaction/offline/TransactionReconstructor.js +111 -75
- package/build/transaction/offline/TransactionReconstructor.js.map +1 -0
- package/build/transaction/offline/TransactionSerializer.d.ts +54 -3
- package/build/transaction/offline/TransactionSerializer.d.ts.map +1 -0
- package/build/transaction/offline/TransactionSerializer.js +206 -95
- package/build/transaction/offline/TransactionSerializer.js.map +1 -0
- package/build/transaction/offline/TransactionStateCapture.d.ts +66 -7
- package/build/transaction/offline/TransactionStateCapture.d.ts.map +1 -0
- package/build/transaction/offline/TransactionStateCapture.js +124 -60
- package/build/transaction/offline/TransactionStateCapture.js.map +1 -0
- package/build/transaction/offline/interfaces/ISerializableState.d.ts +72 -1
- package/build/transaction/offline/interfaces/ISerializableState.d.ts.map +1 -0
- package/build/transaction/offline/interfaces/ISerializableState.js +10 -1
- package/build/transaction/offline/interfaces/ISerializableState.js.map +1 -0
- package/build/transaction/offline/interfaces/ITypeSpecificData.d.ts +77 -1
- package/build/transaction/offline/interfaces/ITypeSpecificData.d.ts.map +1 -0
- package/build/transaction/offline/interfaces/ITypeSpecificData.js +19 -0
- package/build/transaction/offline/interfaces/ITypeSpecificData.js.map +1 -0
- package/build/transaction/psbt/PSBTTypes.d.ts +1 -0
- package/build/transaction/psbt/PSBTTypes.d.ts.map +1 -0
- package/build/transaction/psbt/PSBTTypes.js +1 -0
- package/build/transaction/psbt/PSBTTypes.js.map +1 -0
- package/build/transaction/shared/P2TR_MS.d.ts +11 -2
- package/build/transaction/shared/P2TR_MS.d.ts.map +1 -0
- package/build/transaction/shared/P2TR_MS.js +10 -0
- package/build/transaction/shared/P2TR_MS.js.map +1 -0
- package/build/transaction/shared/TweakedTransaction.d.ts +281 -38
- package/build/transaction/shared/TweakedTransaction.d.ts.map +1 -0
- package/build/transaction/shared/TweakedTransaction.js +576 -114
- package/build/transaction/shared/TweakedTransaction.js.map +1 -0
- package/build/transaction/utils/WitnessUtils.d.ts +7 -1
- package/build/transaction/utils/WitnessUtils.d.ts.map +1 -0
- package/build/transaction/utils/WitnessUtils.js +17 -3
- package/build/transaction/utils/WitnessUtils.js.map +1 -0
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/build/utils/BitcoinUtils.d.ts +19 -0
- package/build/utils/BitcoinUtils.d.ts.map +1 -0
- package/build/utils/BitcoinUtils.js +19 -0
- package/build/utils/BitcoinUtils.js.map +1 -0
- package/build/utils/BufferHelper.d.ts +2 -1
- package/build/utils/BufferHelper.d.ts.map +1 -0
- package/build/utils/BufferHelper.js +38 -32
- package/build/utils/BufferHelper.js.map +1 -0
- package/build/utils/StringToBuffer.d.ts +1 -0
- package/build/utils/StringToBuffer.d.ts.map +1 -0
- package/build/utils/StringToBuffer.js +1 -0
- package/build/utils/StringToBuffer.js.map +1 -0
- package/build/utils/lengths.d.ts +1 -0
- package/build/utils/lengths.d.ts.map +1 -0
- package/build/utils/lengths.js +1 -0
- package/build/utils/lengths.js.map +1 -0
- package/build/utils/types.d.ts +1 -0
- package/build/utils/types.d.ts.map +1 -0
- package/build/utils/types.js +2 -1
- package/build/utils/types.js.map +1 -0
- package/build/utxo/OPNetLimitedProvider.d.ts +39 -3
- package/build/utxo/OPNetLimitedProvider.d.ts.map +1 -0
- package/build/utxo/OPNetLimitedProvider.js +41 -3
- package/build/utxo/OPNetLimitedProvider.js.map +1 -0
- package/build/utxo/interfaces/BroadcastResponse.d.ts +1 -0
- package/build/utxo/interfaces/BroadcastResponse.d.ts.map +1 -0
- package/build/utxo/interfaces/BroadcastResponse.js +1 -0
- package/build/utxo/interfaces/BroadcastResponse.js.map +1 -0
- package/build/utxo/interfaces/IUTXO.d.ts +13 -7
- package/build/utxo/interfaces/IUTXO.d.ts.map +1 -0
- package/build/utxo/interfaces/IUTXO.js +1 -0
- package/build/utxo/interfaces/IUTXO.js.map +1 -0
- package/build/verification/TapscriptVerificator.d.ts +12 -10
- package/build/verification/TapscriptVerificator.d.ts.map +1 -0
- package/build/verification/TapscriptVerificator.js +28 -38
- package/build/verification/TapscriptVerificator.js.map +1 -0
- package/eslint.config.js +0 -1
- package/package.json +16 -39
- package/src/abi/ABICoder.ts +0 -13
- package/src/branded/Branded.ts +5 -0
- package/src/buffer/BinaryReader.ts +7 -7
- package/src/buffer/BinaryWriter.ts +29 -24
- package/src/bytecode/Compressor.ts +1 -1
- package/src/chain/ChainData.ts +34 -27
- package/src/consensus/ConsensusConfig.ts +1 -1
- package/src/consensus/IConsensusConfig.ts +0 -17
- package/src/consensus/metadata/RoswellConsensus.ts +1 -17
- package/src/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 +6 -6
- package/src/generators/Features.ts +3 -3
- package/src/generators/Generator.ts +42 -26
- package/src/generators/builders/CalldataGenerator.ts +26 -24
- package/src/generators/builders/CustomGenerator.ts +4 -4
- package/src/generators/builders/DeploymentGenerator.ts +25 -23
- package/src/generators/builders/HashCommitmentGenerator.ts +31 -31
- package/src/generators/builders/LegacyCalldataGenerator.ts +26 -24
- package/src/generators/builders/MultiSignGenerator.ts +12 -12
- package/src/generators/builders/P2WDAGenerator.ts +10 -10
- package/src/keypair/Address.ts +115 -72
- package/src/keypair/AddressVerificator.ts +16 -147
- package/src/keypair/EcKeyPair.ts +109 -118
- package/src/keypair/MessageSigner.ts +70 -150
- package/src/keypair/Wallet.ts +59 -240
- package/src/metadata/ContractBaseMetadata.ts +2 -2
- package/src/mnemonic/Mnemonic.ts +32 -221
- package/src/opnet.ts +12 -6
- package/src/p2wda/P2WDADetector.ts +23 -72
- package/src/polyfill/disposable.ts +29 -0
- package/src/signer/AddressRotation.ts +1 -1
- package/src/signer/IRotationSigner.ts +3 -3
- package/src/signer/ParallelSignerAdapter.ts +59 -0
- package/src/signer/SignerUtils.ts +4 -4
- package/src/signer/TweakedSigner.ts +28 -13
- package/src/transaction/ContractAddress.ts +3 -7
- package/src/transaction/TransactionFactory.ts +28 -50
- package/src/transaction/browser/BrowserSignerBase.ts +12 -6
- package/src/transaction/browser/Web3Provider.ts +3 -3
- package/src/transaction/browser/extensions/UnisatSigner.ts +52 -48
- package/src/transaction/browser/extensions/XverseSigner.ts +55 -38
- package/src/transaction/browser/types/OPWallet.ts +2 -2
- package/src/transaction/browser/types/Unisat.ts +1 -1
- package/src/transaction/builders/CancelTransaction.ts +59 -24
- package/src/transaction/builders/ChallengeSolutionTransaction.ts +3 -3
- package/src/transaction/builders/ConsolidatedInteractionTransaction.ts +39 -34
- package/src/transaction/builders/CustomScriptTransaction.ts +79 -56
- package/src/transaction/builders/DeploymentTransaction.ts +82 -63
- package/src/transaction/builders/FundingTransaction.ts +11 -11
- package/src/transaction/builders/InteractionTransaction.ts +10 -10
- package/src/transaction/builders/InteractionTransactionP2WDA.ts +38 -40
- package/src/transaction/builders/MultiSignTransaction.ts +68 -61
- package/src/transaction/builders/SharedInteractionTransaction.ts +81 -57
- package/src/transaction/builders/TransactionBuilder.ts +101 -79
- package/src/transaction/interfaces/ICancelTransactionParameters.ts +2 -2
- package/src/transaction/interfaces/IConsolidatedTransactionParameters.ts +5 -5
- package/src/transaction/interfaces/ICustomTransactionParameters.ts +5 -5
- package/src/transaction/interfaces/ITransactionParameters.ts +15 -15
- package/src/transaction/interfaces/ITransactionResponses.ts +2 -2
- package/src/transaction/interfaces/ITweakedTransactionData.ts +17 -8
- package/src/transaction/interfaces/IWeb3ProviderTypes.ts +3 -3
- package/src/transaction/interfaces/Tap.ts +3 -3
- package/src/transaction/mineable/IP2WSHAddress.ts +1 -1
- package/src/transaction/mineable/TimelockGenerator.ts +19 -12
- package/src/transaction/offline/OfflineTransactionManager.ts +22 -23
- package/src/transaction/offline/TransactionReconstructor.ts +83 -91
- package/src/transaction/offline/TransactionSerializer.ts +151 -101
- package/src/transaction/offline/TransactionStateCapture.ts +83 -79
- package/src/transaction/offline/interfaces/ISerializableState.ts +1 -1
- package/src/transaction/offline/interfaces/ITypeSpecificData.ts +1 -1
- package/src/transaction/shared/P2TR_MS.ts +4 -4
- package/src/transaction/shared/TweakedTransaction.ts +326 -124
- package/src/transaction/utils/WitnessUtils.ts +18 -9
- package/src/utils/BufferHelper.ts +39 -37
- package/src/utxo/OPNetLimitedProvider.ts +7 -7
- package/src/utxo/interfaces/IUTXO.ts +7 -7
- package/src/verification/TapscriptVerificator.ts +73 -86
- package/test/address-rotation.test.ts +24 -24
- package/test/address.test.ts +12 -12
- package/test/addressmap.test.ts +30 -30
- package/test/binary-reader-writer.test.ts +8 -8
- package/test/browser/offline-transaction.test.ts +2206 -0
- package/test/browser/parallel-signing.test.ts +316 -0
- package/test/browser/setup.ts +11 -0
- package/test/browser/transaction-signing.test.ts +416 -0
- package/test/buffer-helper.test.ts +287 -0
- package/test/derivePath.test.ts +4 -3
- package/test/disposable.test.ts +279 -0
- package/test/fastmap-setall.test.ts +1 -1
- package/test/fastmap.test.ts +3 -3
- package/test/messagesigner-mldsa.test.ts +3 -3
- package/test/messagesigner-schnorr.test.ts +9 -9
- package/test/offline-transaction.test.ts +461 -288
- package/test/old/FastBigIntMap.ts +3 -3
- package/test/oldfastmap.test.ts +6 -6
- package/test/transaction-builders.test.ts +321 -0
- package/tsconfig.base.json +34 -18
- package/tsconfig.browser.json +15 -0
- package/tsconfig.json +3 -8
- package/vite.config.browser.ts +4 -5
- package/vitest.config.browser.ts +68 -0
- package/vitest.config.ts +1 -1
- package/browser/valibot.js +0 -4948
- package/tsconfig.webpack.json +0 -18
package/build/keypair/Address.js
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
-
};
|
|
7
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
-
};
|
|
12
|
-
var _Address_p2tr, _Address_p2op, _Address_network, _Address_originalPublicKey, _Address_keyPair, _Address_uncompressed, _Address_tweakedUncompressed, _Address_p2wda, _Address_mldsaPublicKey, _Address_cachedBigInt, _Address_cachedBigIntTweaked, _Address_cachedUint64Array, _Address_originalMDLSAPublicKey, _Address_mldsaLevel, _Address_pendingLegacyKey, _Address_legacyProcessed, _Address_legacyPublicKey;
|
|
13
|
-
import { decompressPublicKey, toXOnly } from '@btc-vision/bitcoin';
|
|
1
|
+
import { decompressPublicKey, fromHex, toHex, toXOnly, } from '@btc-vision/bitcoin';
|
|
2
|
+
import {} from '@btc-vision/ecpair';
|
|
14
3
|
import { ADDRESS_BYTE_LENGTH } from '../utils/lengths.js';
|
|
15
4
|
import { AddressVerificator } from './AddressVerificator.js';
|
|
16
5
|
import { EcKeyPair } from './EcKeyPair.js';
|
|
@@ -18,73 +7,120 @@ import { ContractAddress } from '../transaction/ContractAddress.js';
|
|
|
18
7
|
import { BitcoinUtils } from '../utils/BitcoinUtils.js';
|
|
19
8
|
import { TimeLockGenerator } from '../transaction/mineable/TimelockGenerator.js';
|
|
20
9
|
import { P2WDADetector } from '../p2wda/P2WDADetector.js';
|
|
21
|
-
import { sha256 } from '@noble/hashes/sha2';
|
|
10
|
+
import { sha256 } from '@noble/hashes/sha2.js';
|
|
11
|
+
import { MLDSASecurityLevel } from '@btc-vision/bip32';
|
|
12
|
+
// ML-DSA-44 (Level 2): 1312 bytes public key
|
|
13
|
+
// ML-DSA-65 (Level 3): 1952 bytes public key
|
|
14
|
+
// ML-DSA-87 (Level 5): 2592 bytes public key
|
|
15
|
+
const validMLDSALengths = [1312, 1952, 2592];
|
|
16
|
+
/**
|
|
17
|
+
* Objects of type "Address" represent hashed ML-DSA (quantum) public keys (using SHA256 of quantum keys) and maintain classical public keys separately.
|
|
18
|
+
* This class supports a hybrid quantum-classical architecture, allowing conversion to different address formats and management of both key types.
|
|
19
|
+
*
|
|
20
|
+
* The Address internally stores the SHA256 hash of the ML-DSA public key as its primary content, while maintaining
|
|
21
|
+
* the classical public key in a separate field. This enables quantum-resistant addressing while preserving
|
|
22
|
+
* compatibility with traditional Bitcoin cryptography.
|
|
23
|
+
*
|
|
24
|
+
* @category KeyPair
|
|
25
|
+
*/
|
|
22
26
|
export class Address extends Uint8Array {
|
|
27
|
+
#p2tr;
|
|
28
|
+
#p2op;
|
|
29
|
+
#network;
|
|
30
|
+
#originalPublicKey;
|
|
31
|
+
#keyPair;
|
|
32
|
+
#uncompressed;
|
|
33
|
+
#tweakedUncompressed;
|
|
34
|
+
#p2wda;
|
|
35
|
+
#mldsaPublicKey;
|
|
36
|
+
#cachedBigInt;
|
|
37
|
+
#cachedBigIntTweaked;
|
|
38
|
+
#cachedUint64Array;
|
|
39
|
+
#originalMDLSAPublicKey;
|
|
40
|
+
#mldsaLevel;
|
|
41
|
+
// Lazy loading state - defers expensive EC operations until actually needed
|
|
42
|
+
#pendingLegacyKey;
|
|
43
|
+
#legacyProcessed = false;
|
|
44
|
+
// After processing, this is 32-byte tweaked x-only (same as original behavior)
|
|
45
|
+
#tweakedPublicKey;
|
|
23
46
|
constructor(mldsaPublicKey, publicKeyOrTweak) {
|
|
24
47
|
super(ADDRESS_BYTE_LENGTH);
|
|
25
|
-
_Address_p2tr.set(this, void 0);
|
|
26
|
-
_Address_p2op.set(this, void 0);
|
|
27
|
-
_Address_network.set(this, void 0);
|
|
28
|
-
_Address_originalPublicKey.set(this, void 0);
|
|
29
|
-
_Address_keyPair.set(this, void 0);
|
|
30
|
-
_Address_uncompressed.set(this, void 0);
|
|
31
|
-
_Address_tweakedUncompressed.set(this, void 0);
|
|
32
|
-
_Address_p2wda.set(this, void 0);
|
|
33
|
-
_Address_mldsaPublicKey.set(this, void 0);
|
|
34
|
-
_Address_cachedBigInt.set(this, void 0);
|
|
35
|
-
_Address_cachedBigIntTweaked.set(this, void 0);
|
|
36
|
-
_Address_cachedUint64Array.set(this, void 0);
|
|
37
|
-
_Address_originalMDLSAPublicKey.set(this, void 0);
|
|
38
|
-
_Address_mldsaLevel.set(this, void 0);
|
|
39
|
-
_Address_pendingLegacyKey.set(this, void 0);
|
|
40
|
-
_Address_legacyProcessed.set(this, false);
|
|
41
|
-
_Address_legacyPublicKey.set(this, void 0);
|
|
42
48
|
if (!mldsaPublicKey) {
|
|
43
49
|
return;
|
|
44
50
|
}
|
|
45
51
|
if (publicKeyOrTweak) {
|
|
52
|
+
// Validate length immediately (cheap check), defer EC operations
|
|
46
53
|
const validLengths = [ADDRESS_BYTE_LENGTH, 33, 65];
|
|
47
54
|
if (!validLengths.includes(publicKeyOrTweak.length)) {
|
|
48
55
|
throw new Error(`Invalid public key length ${publicKeyOrTweak.length}`);
|
|
49
56
|
}
|
|
50
|
-
|
|
51
|
-
|
|
57
|
+
// Store but don't process yet - defer EC operations
|
|
58
|
+
this.#pendingLegacyKey = new Uint8Array(publicKeyOrTweak.length);
|
|
59
|
+
this.#pendingLegacyKey.set(publicKeyOrTweak);
|
|
52
60
|
}
|
|
53
61
|
this.setMldsaKey(mldsaPublicKey);
|
|
54
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Prevent TypedArray methods (subarray, slice, etc.) from creating Address
|
|
65
|
+
* instances. Without this, @noble/hashes and other libraries that call
|
|
66
|
+
* subarray() on an Address would invoke the Address constructor that recomputes
|
|
67
|
+
* everything leading to bad performance.
|
|
68
|
+
*/
|
|
69
|
+
static get [Symbol.species]() {
|
|
70
|
+
return Uint8Array;
|
|
71
|
+
}
|
|
55
72
|
get mldsaLevel() {
|
|
56
|
-
return
|
|
73
|
+
return this.#mldsaLevel;
|
|
57
74
|
}
|
|
58
75
|
set mldsaLevel(level) {
|
|
59
|
-
|
|
76
|
+
this.#mldsaLevel = level;
|
|
60
77
|
}
|
|
61
78
|
get originalMDLSAPublicKey() {
|
|
62
|
-
return
|
|
79
|
+
return this.#originalMDLSAPublicKey;
|
|
63
80
|
}
|
|
64
81
|
set originalMDLSAPublicKey(key) {
|
|
65
|
-
|
|
82
|
+
this.#originalMDLSAPublicKey = key ? new Uint8Array(key) : undefined;
|
|
66
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* If available, this will return the original public key associated with the address.
|
|
86
|
+
* @returns {Uint8Array} The original public key used to create the address.
|
|
87
|
+
*/
|
|
67
88
|
get originalPublicKey() {
|
|
68
89
|
this.ensureLegacyProcessed();
|
|
69
|
-
return
|
|
90
|
+
return this.#originalPublicKey;
|
|
70
91
|
}
|
|
71
92
|
get mldsaPublicKey() {
|
|
72
|
-
return
|
|
93
|
+
return this.#mldsaPublicKey;
|
|
73
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Get the legacy public key (32-byte tweaked x-only after processing).
|
|
97
|
+
* Triggers lazy processing if not yet done.
|
|
98
|
+
*/
|
|
74
99
|
get legacyPublicKey() {
|
|
75
100
|
this.ensureLegacyProcessed();
|
|
76
|
-
return
|
|
101
|
+
return this.#tweakedPublicKey;
|
|
77
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Get the key pair for the address
|
|
105
|
+
* @description This is only for internal use. Please use address.tweakedBytes instead.
|
|
106
|
+
*/
|
|
78
107
|
get keyPair() {
|
|
79
108
|
this.ensureLegacyProcessed();
|
|
80
|
-
if (!
|
|
109
|
+
if (!this.#keyPair) {
|
|
81
110
|
throw new Error('Legacy public key not set for address');
|
|
82
111
|
}
|
|
83
|
-
return
|
|
112
|
+
return this.#keyPair;
|
|
84
113
|
}
|
|
85
114
|
static dead() {
|
|
86
|
-
return Address.fromString('0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
87
|
-
|
|
115
|
+
return Address.fromString('0x0000000000000000000000000000000000000000000000000000000000000000', // DEAD ADDRESS
|
|
116
|
+
'0x04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f');
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Create an address from a hex string
|
|
120
|
+
* @param {string} mldsaPublicKey The ml-dsa public key in hex format
|
|
121
|
+
* @param {string} legacyPublicKey The classical public key in hex format
|
|
122
|
+
* @returns {Address} The address
|
|
123
|
+
*/
|
|
88
124
|
static fromString(mldsaPublicKey, legacyPublicKey) {
|
|
89
125
|
if (!mldsaPublicKey) {
|
|
90
126
|
throw new Error('Invalid public key');
|
|
@@ -103,10 +139,15 @@ export class Address extends Uint8Array {
|
|
|
103
139
|
if (!BitcoinUtils.isValidHex(legacyPublicKey)) {
|
|
104
140
|
throw new Error('You must only pass classical public keys in hexadecimal format. If you have an address such as bc1q... you must convert it to a public key first. Please refer to await provider.getPublicKeyInfo("bc1q..."). If the public key associated with the address is not found, you must force the user to enter the destination public key. It looks like: 0x020373626d317ae8788ce3280b491068610d840c23ecb64c14075bbb9f670af52c.');
|
|
105
141
|
}
|
|
106
|
-
classicBuffer =
|
|
142
|
+
classicBuffer = fromHex(legacyPublicKey);
|
|
107
143
|
}
|
|
108
|
-
return new Address(
|
|
144
|
+
return new Address(fromHex(mldsaPublicKey), classicBuffer);
|
|
109
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Create an address from a public key
|
|
148
|
+
* @returns {Address} The address
|
|
149
|
+
* @param {ArrayLike<number>} bytes The public key
|
|
150
|
+
*/
|
|
110
151
|
static wrap(bytes) {
|
|
111
152
|
return new Address(bytes);
|
|
112
153
|
}
|
|
@@ -114,16 +155,85 @@ export class Address extends Uint8Array {
|
|
|
114
155
|
const buffer = Uint8Array.from(publicKey);
|
|
115
156
|
const x = buffer.slice(1, 33);
|
|
116
157
|
const y = buffer.slice(33);
|
|
117
|
-
const compressed =
|
|
158
|
+
const compressed = new Uint8Array(33);
|
|
118
159
|
compressed[0] = 0x02 + (y[y.length - 1] & 0x01);
|
|
119
160
|
compressed.set(x, 1);
|
|
120
161
|
return compressed;
|
|
121
162
|
}
|
|
163
|
+
[Symbol.dispose]() {
|
|
164
|
+
// Zero the base Uint8Array (hashed ML-DSA public key)
|
|
165
|
+
this.fill(0);
|
|
166
|
+
// Clear all cached / derived state
|
|
167
|
+
this.#p2tr = undefined;
|
|
168
|
+
this.#p2op = undefined;
|
|
169
|
+
this.#network = undefined;
|
|
170
|
+
this.#originalPublicKey = undefined;
|
|
171
|
+
this.#keyPair = undefined;
|
|
172
|
+
this.#uncompressed = undefined;
|
|
173
|
+
this.#tweakedUncompressed = undefined;
|
|
174
|
+
this.#p2wda = undefined;
|
|
175
|
+
this.#mldsaPublicKey?.fill(0);
|
|
176
|
+
this.#mldsaPublicKey = undefined;
|
|
177
|
+
this.#cachedBigInt = undefined;
|
|
178
|
+
this.#cachedBigIntTweaked = undefined;
|
|
179
|
+
this.#cachedUint64Array = undefined;
|
|
180
|
+
this.#originalMDLSAPublicKey?.fill(0);
|
|
181
|
+
this.#originalMDLSAPublicKey = undefined;
|
|
182
|
+
this.#mldsaLevel = undefined;
|
|
183
|
+
this.#legacyProcessed = false;
|
|
184
|
+
this.#tweakedPublicKey = undefined;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Creates an Address instance from a BigInt value.
|
|
188
|
+
*
|
|
189
|
+
* Converts a 256-bit unsigned integer into a 32-byte address by splitting it
|
|
190
|
+
* into four 64-bit chunks and writing them in big-endian format using DataView.
|
|
191
|
+
* This is the inverse operation of toBigInt().
|
|
192
|
+
*
|
|
193
|
+
* @param {bigint} value - The 256-bit unsigned integer to convert (0 to 2^256-1)
|
|
194
|
+
* @param {bigint} [tweakedValue] - Optional tweaked public key as a 256-bit unsigned integer
|
|
195
|
+
* @returns {Address} A new Address instance containing the converted value
|
|
196
|
+
*
|
|
197
|
+
* @throws {RangeError} If the value is negative or exceeds 2^256-1
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```typescript
|
|
201
|
+
* const bigIntValue = 12345678901234567890n;
|
|
202
|
+
* const address = Address.fromBigInt(bigIntValue);
|
|
203
|
+
* console.log(address.toHex()); // 0x0000000000000000000000000000000000000000000000000000abc123...
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
122
206
|
static fromBigInt(value, tweakedValue) {
|
|
123
207
|
const address = Address.bigintToUint8Array(value);
|
|
124
208
|
const legacyAddress = tweakedValue !== undefined ? Address.bigintToUint8Array(tweakedValue) : undefined;
|
|
125
209
|
return new Address(address, legacyAddress);
|
|
126
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* Creates an Address instance from four 64-bit unsigned integers.
|
|
213
|
+
*
|
|
214
|
+
* Constructs a 32-byte address by combining four 64-bit big-endian unsigned integers.
|
|
215
|
+
* This is the inverse operation of toUint64Array() and provides an efficient way
|
|
216
|
+
* to create addresses from word-aligned data.
|
|
217
|
+
*
|
|
218
|
+
* @param {bigint} w0 - Most significant 64 bits (bytes 0-7)
|
|
219
|
+
* @param {bigint} w1 - Second 64 bits (bytes 8-15)
|
|
220
|
+
* @param {bigint} w2 - Third 64 bits (bytes 16-23)
|
|
221
|
+
* @param {bigint} w3 - Least significant 64 bits (bytes 24-31)
|
|
222
|
+
* @returns {Address} A new Address instance containing the combined value
|
|
223
|
+
*
|
|
224
|
+
* @throws {RangeError} If any value exceeds 64 bits (2^64-1)
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```typescript
|
|
228
|
+
* const address = Address.fromUint64Array(
|
|
229
|
+
* 0x0123456789abcdefn,
|
|
230
|
+
* 0xfedcba9876543210n,
|
|
231
|
+
* 0x1111222233334444n,
|
|
232
|
+
* 0x5555666677778888n
|
|
233
|
+
* );
|
|
234
|
+
* console.log(address.toHex());
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
127
237
|
static fromUint64Array(w0, w1, w2, w3) {
|
|
128
238
|
const buffer = new Uint8Array(32);
|
|
129
239
|
const view = new DataView(buffer.buffer);
|
|
@@ -142,19 +252,41 @@ export class Address extends Uint8Array {
|
|
|
142
252
|
view.setBigUint64(24, value & 0xffffffffffffffffn, false);
|
|
143
253
|
return buffer;
|
|
144
254
|
}
|
|
255
|
+
/**
|
|
256
|
+
* Converts the address to four 64-bit unsigned integers.
|
|
257
|
+
*
|
|
258
|
+
* Splits the 32-byte (256-bit) address into four 64-bit big-endian unsigned integers.
|
|
259
|
+
* This representation is useful for efficient storage, comparison operations, or
|
|
260
|
+
* interfacing with systems that work with 64-bit word sizes.
|
|
261
|
+
*
|
|
262
|
+
* @returns {[bigint, bigint, bigint, bigint]} An array of four 64-bit unsigned integers
|
|
263
|
+
* representing the address from most significant to least significant bits
|
|
264
|
+
*
|
|
265
|
+
* @example
|
|
266
|
+
* ```typescript
|
|
267
|
+
* const address = Address.fromString('0x0123456789abcdef...');
|
|
268
|
+
* const [w0, w1, w2, w3] = address.toUint64Array();
|
|
269
|
+
* console.log(w0); // Most significant 64 bits
|
|
270
|
+
* console.log(w3); // Least significant 64 bits
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
145
273
|
toUint64Array() {
|
|
146
|
-
if (
|
|
147
|
-
return
|
|
274
|
+
if (this.#cachedUint64Array !== undefined) {
|
|
275
|
+
return this.#cachedUint64Array;
|
|
148
276
|
}
|
|
149
277
|
const view = new DataView(this.buffer, this.byteOffset, 32);
|
|
150
|
-
|
|
278
|
+
this.#cachedUint64Array = [
|
|
151
279
|
view.getBigUint64(0, false),
|
|
152
280
|
view.getBigUint64(8, false),
|
|
153
281
|
view.getBigUint64(16, false),
|
|
154
282
|
view.getBigUint64(24, false),
|
|
155
|
-
]
|
|
156
|
-
return
|
|
283
|
+
];
|
|
284
|
+
return this.#cachedUint64Array;
|
|
157
285
|
}
|
|
286
|
+
/**
|
|
287
|
+
* Check if the address is the dead address
|
|
288
|
+
* @returns {boolean}
|
|
289
|
+
*/
|
|
158
290
|
isDead() {
|
|
159
291
|
for (let i = 0; i < ADDRESS_BYTE_LENGTH; i++) {
|
|
160
292
|
if (this[i] !== 0) {
|
|
@@ -163,85 +295,135 @@ export class Address extends Uint8Array {
|
|
|
163
295
|
}
|
|
164
296
|
return true;
|
|
165
297
|
}
|
|
298
|
+
/**
|
|
299
|
+
* Converts the address to a hex string
|
|
300
|
+
* @returns {string} The hex string
|
|
301
|
+
*/
|
|
166
302
|
toHex() {
|
|
167
|
-
return '0x' +
|
|
303
|
+
return '0x' + toHex(this);
|
|
168
304
|
}
|
|
305
|
+
/**
|
|
306
|
+
* Converts the classical public key to a hex string
|
|
307
|
+
* @returns {string} The hex string
|
|
308
|
+
*/
|
|
169
309
|
tweakedToHex() {
|
|
170
310
|
const key = this.legacyPublicKey;
|
|
171
311
|
if (!key) {
|
|
172
312
|
throw new Error('Legacy public key not set');
|
|
173
313
|
}
|
|
174
|
-
return '0x' +
|
|
314
|
+
return '0x' + toHex(key);
|
|
175
315
|
}
|
|
316
|
+
/**
|
|
317
|
+
* Converts the address content (SHA256 hash of ML-DSA public key) to a Uint8Array
|
|
318
|
+
* @returns {Uint8Array} The Uint8Array containing the hashed ML-DSA public key
|
|
319
|
+
*/
|
|
176
320
|
toBuffer() {
|
|
177
|
-
return
|
|
321
|
+
return new Uint8Array(this);
|
|
178
322
|
}
|
|
323
|
+
/**
|
|
324
|
+
* Converts the classical public key to a Uint8Array
|
|
325
|
+
* @returns {Uint8Array} The Uint8Array
|
|
326
|
+
*/
|
|
179
327
|
tweakedPublicKeyToBuffer() {
|
|
180
328
|
const key = this.legacyPublicKey;
|
|
181
329
|
if (!key) {
|
|
182
330
|
throw new Error('Legacy public key not set');
|
|
183
331
|
}
|
|
184
|
-
return
|
|
332
|
+
return new Uint8Array(key);
|
|
185
333
|
}
|
|
186
334
|
toUncompressedHex() {
|
|
187
335
|
this.ensureLegacyProcessed();
|
|
188
|
-
if (!
|
|
336
|
+
if (!this.#uncompressed) {
|
|
189
337
|
throw new Error('Legacy public key not set');
|
|
190
338
|
}
|
|
191
|
-
return '0x' +
|
|
339
|
+
return '0x' + toHex(this.#uncompressed.uncompressed);
|
|
192
340
|
}
|
|
193
341
|
toUncompressedBuffer() {
|
|
194
342
|
this.ensureLegacyProcessed();
|
|
195
|
-
if (!
|
|
343
|
+
if (!this.#uncompressed) {
|
|
196
344
|
throw new Error('Legacy public key not set');
|
|
197
345
|
}
|
|
198
|
-
return
|
|
346
|
+
return this.#uncompressed.uncompressed;
|
|
199
347
|
}
|
|
200
348
|
toHybridPublicKeyHex() {
|
|
201
349
|
this.ensureLegacyProcessed();
|
|
202
|
-
if (!
|
|
350
|
+
if (!this.#uncompressed) {
|
|
203
351
|
throw new Error('Legacy public key not set');
|
|
204
352
|
}
|
|
205
|
-
return '0x' +
|
|
353
|
+
return '0x' + toHex(this.#uncompressed.hybrid);
|
|
206
354
|
}
|
|
207
355
|
toHybridPublicKeyBuffer() {
|
|
208
356
|
this.ensureLegacyProcessed();
|
|
209
|
-
if (!
|
|
357
|
+
if (!this.#uncompressed) {
|
|
210
358
|
throw new Error('Legacy public key not set');
|
|
211
359
|
}
|
|
212
|
-
return
|
|
360
|
+
return this.#uncompressed.hybrid;
|
|
213
361
|
}
|
|
214
362
|
originalPublicKeyBuffer() {
|
|
215
363
|
this.ensureLegacyProcessed();
|
|
216
|
-
if (!
|
|
364
|
+
if (!this.#originalPublicKey) {
|
|
217
365
|
throw new Error('Legacy public key not set');
|
|
218
366
|
}
|
|
219
|
-
return
|
|
220
|
-
}
|
|
367
|
+
return new Uint8Array(this.#originalPublicKey);
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Converts the address to a BigInt representation.
|
|
371
|
+
*
|
|
372
|
+
* This method uses an optimized DataView approach to read the 32-byte address
|
|
373
|
+
* as four 64-bit big-endian unsigned integers, then combines them using bitwise
|
|
374
|
+
* operations. This is approximately 10-20x faster than string-based conversion.
|
|
375
|
+
*
|
|
376
|
+
* @returns {bigint} The address as a 256-bit unsigned integer
|
|
377
|
+
*
|
|
378
|
+
* @example
|
|
379
|
+
* ```typescript
|
|
380
|
+
* const address = Address.fromString('0x0123456789abcdef...');
|
|
381
|
+
* const bigIntValue = address.toBigInt();
|
|
382
|
+
* console.log(bigIntValue); // 123456789...n
|
|
383
|
+
* ```
|
|
384
|
+
*/
|
|
221
385
|
toBigInt() {
|
|
222
|
-
if (
|
|
223
|
-
return
|
|
386
|
+
if (this.#cachedBigInt !== undefined) {
|
|
387
|
+
return this.#cachedBigInt;
|
|
224
388
|
}
|
|
225
389
|
const view = new DataView(this.buffer, this.byteOffset, 32);
|
|
226
|
-
|
|
227
|
-
(view.getBigUint64(
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
390
|
+
this.#cachedBigInt =
|
|
391
|
+
(view.getBigUint64(0, false) << 192n) |
|
|
392
|
+
(view.getBigUint64(8, false) << 128n) |
|
|
393
|
+
(view.getBigUint64(16, false) << 64n) |
|
|
394
|
+
view.getBigUint64(24, false);
|
|
395
|
+
return this.#cachedBigInt;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Converts the tweaked public key to a BigInt representation.
|
|
399
|
+
*
|
|
400
|
+
* This method uses an optimized DataView approach to read the 32-byte address
|
|
401
|
+
* as four 64-bit big-endian unsigned integers, then combines them using bitwise
|
|
402
|
+
* operations. This is approximately 10-20x faster than string-based conversion.
|
|
403
|
+
*
|
|
404
|
+
* @returns {bigint} The address as a 256-bit unsigned integer
|
|
405
|
+
*
|
|
406
|
+
* @example
|
|
407
|
+
* ```typescript
|
|
408
|
+
* const address = Address.fromString('0x0123456789abcdef...', '0xtweaked...');
|
|
409
|
+
* const bigIntValue = address.tweakedToBigInt();
|
|
410
|
+
* console.log(bigIntValue); // 123456789...n
|
|
411
|
+
* ```
|
|
412
|
+
*/
|
|
232
413
|
tweakedToBigInt() {
|
|
233
414
|
if (!this.legacyPublicKey) {
|
|
234
415
|
throw new Error('Legacy public key not set');
|
|
235
416
|
}
|
|
236
|
-
if (
|
|
237
|
-
return
|
|
417
|
+
if (this.#cachedBigIntTweaked !== undefined) {
|
|
418
|
+
return this.#cachedBigIntTweaked;
|
|
238
419
|
}
|
|
239
420
|
const view = new DataView(this.legacyPublicKey.buffer, this.byteOffset, 32);
|
|
240
|
-
|
|
241
|
-
(view.getBigUint64(
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
421
|
+
this.#cachedBigIntTweaked =
|
|
422
|
+
(view.getBigUint64(0, false) << 192n) |
|
|
423
|
+
(view.getBigUint64(8, false) << 128n) |
|
|
424
|
+
(view.getBigUint64(16, false) << 64n) |
|
|
425
|
+
view.getBigUint64(24, false);
|
|
426
|
+
return this.#cachedBigIntTweaked;
|
|
245
427
|
}
|
|
246
428
|
equals(a) {
|
|
247
429
|
const b = this;
|
|
@@ -255,65 +437,110 @@ export class Address extends Uint8Array {
|
|
|
255
437
|
}
|
|
256
438
|
return true;
|
|
257
439
|
}
|
|
440
|
+
/**
|
|
441
|
+
* Check if the address is bigger than another address
|
|
442
|
+
* @returns {boolean} If bigger
|
|
443
|
+
*/
|
|
258
444
|
lessThan(a) {
|
|
259
445
|
const b = this;
|
|
260
446
|
for (let i = 0; i < ADDRESS_BYTE_LENGTH; i++) {
|
|
261
447
|
const thisByte = b[i];
|
|
262
448
|
const aByte = a[i];
|
|
263
449
|
if (thisByte < aByte) {
|
|
264
|
-
return true;
|
|
450
|
+
return true; // this is less than a
|
|
265
451
|
}
|
|
266
452
|
else if (thisByte > aByte) {
|
|
267
|
-
return false;
|
|
453
|
+
return false; // this is greater than or equal to a
|
|
268
454
|
}
|
|
269
455
|
}
|
|
270
456
|
return false;
|
|
271
457
|
}
|
|
458
|
+
/**
|
|
459
|
+
* Check if the address is smaller than another address
|
|
460
|
+
* @returns {boolean} If smaller
|
|
461
|
+
*/
|
|
272
462
|
greaterThan(a) {
|
|
463
|
+
// Compare the two addresses byte-by-byte, treating them as big-endian uint256
|
|
273
464
|
const b = this;
|
|
274
465
|
for (let i = 0; i < ADDRESS_BYTE_LENGTH; i++) {
|
|
275
466
|
const thisByte = b[i];
|
|
276
467
|
const aByte = a[i];
|
|
277
468
|
if (thisByte > aByte) {
|
|
278
|
-
return true;
|
|
469
|
+
return true; // this is greater than a
|
|
279
470
|
}
|
|
280
471
|
else if (thisByte < aByte) {
|
|
281
|
-
return false;
|
|
472
|
+
return false; // this is less than or equal to a
|
|
282
473
|
}
|
|
283
474
|
}
|
|
284
475
|
return false;
|
|
285
476
|
}
|
|
477
|
+
/**
|
|
478
|
+
* Set the public key
|
|
479
|
+
* @param {ArrayLike<number>} mldsaPublicKey ML-DSA public key
|
|
480
|
+
* @returns {void}
|
|
481
|
+
*/
|
|
286
482
|
set(mldsaPublicKey) {
|
|
483
|
+
// Legacy key processing is now deferred via ensureLegacyProcessed()
|
|
287
484
|
this.setMldsaKey(mldsaPublicKey);
|
|
288
485
|
}
|
|
486
|
+
/**
|
|
487
|
+
* Check if the public key is valid
|
|
488
|
+
* @param {Network} network The network
|
|
489
|
+
* @returns {boolean} If the public key is valid
|
|
490
|
+
*/
|
|
289
491
|
isValidLegacyPublicKey(network) {
|
|
290
492
|
const key = this.legacyPublicKey;
|
|
291
493
|
if (!key) {
|
|
292
494
|
throw new Error(`Legacy key not set.`);
|
|
293
495
|
}
|
|
294
|
-
return AddressVerificator.isValidPublicKey(
|
|
496
|
+
return AddressVerificator.isValidPublicKey(toHex(key), network);
|
|
295
497
|
}
|
|
498
|
+
/**
|
|
499
|
+
* Get the public key as address
|
|
500
|
+
*/
|
|
296
501
|
p2pk() {
|
|
297
502
|
return this.toHex();
|
|
298
503
|
}
|
|
504
|
+
/**
|
|
505
|
+
* Get the address in p2wpkh format
|
|
506
|
+
* @param {Network} network The network
|
|
507
|
+
*/
|
|
299
508
|
p2wpkh(network) {
|
|
300
509
|
return EcKeyPair.getP2WPKHAddress(this.keyPair, network);
|
|
301
510
|
}
|
|
511
|
+
/**
|
|
512
|
+
* Get the address in p2pkh format
|
|
513
|
+
* @param {Network} network The network
|
|
514
|
+
*/
|
|
302
515
|
p2pkh(network) {
|
|
303
516
|
return EcKeyPair.getLegacyAddress(this.keyPair, network);
|
|
304
517
|
}
|
|
518
|
+
/**
|
|
519
|
+
* Get the address in p2sh-p2wpkh format
|
|
520
|
+
* @param {Network} network The network
|
|
521
|
+
*/
|
|
305
522
|
p2shp2wpkh(network) {
|
|
306
523
|
return EcKeyPair.getLegacySegwitAddress(this.keyPair, network);
|
|
307
524
|
}
|
|
525
|
+
/**
|
|
526
|
+
* Convert the address to a string
|
|
527
|
+
*/
|
|
308
528
|
toString() {
|
|
309
529
|
return this.toHex();
|
|
310
530
|
}
|
|
531
|
+
/**
|
|
532
|
+
* Convert the address to a JSON string
|
|
533
|
+
*/
|
|
311
534
|
toJSON() {
|
|
312
535
|
return this.toHex();
|
|
313
536
|
}
|
|
537
|
+
/**
|
|
538
|
+
* Get the address in p2tr format
|
|
539
|
+
* @param {Network} network The network
|
|
540
|
+
*/
|
|
314
541
|
p2tr(network) {
|
|
315
|
-
if (
|
|
316
|
-
return
|
|
542
|
+
if (this.#p2tr && this.#network === network) {
|
|
543
|
+
return this.#p2tr;
|
|
317
544
|
}
|
|
318
545
|
const key = this.legacyPublicKey;
|
|
319
546
|
if (!key) {
|
|
@@ -321,28 +548,50 @@ export class Address extends Uint8Array {
|
|
|
321
548
|
}
|
|
322
549
|
const p2trAddy = EcKeyPair.tweakedPubKeyBufferToAddress(key, network);
|
|
323
550
|
if (p2trAddy) {
|
|
324
|
-
|
|
325
|
-
|
|
551
|
+
this.#network = network;
|
|
552
|
+
this.#p2tr = p2trAddy;
|
|
326
553
|
return p2trAddy;
|
|
327
554
|
}
|
|
328
555
|
throw new Error('Legacy public key not set');
|
|
329
556
|
}
|
|
557
|
+
/**
|
|
558
|
+
* Generate a P2WDA (Pay-to-Witness-Data-Authentication) address
|
|
559
|
+
*
|
|
560
|
+
* P2WDA addresses are a special type of P2WSH address that allows embedding
|
|
561
|
+
* authenticated data directly in the witness field, achieving 75% cost reduction
|
|
562
|
+
* through Bitcoin's witness discount.
|
|
563
|
+
*
|
|
564
|
+
* The witness script pattern is: (OP_2DROP * 5) <pubkey> OP_CHECKSIG
|
|
565
|
+
* This allows up to 10 witness data fields (5 * 2 = 10), where each field
|
|
566
|
+
* can hold up to 80 bytes of data due to relay rules.
|
|
567
|
+
*
|
|
568
|
+
* @param {Network} network - The Bitcoin network to use
|
|
569
|
+
* @returns {IP2WSHAddress} The P2WDA address
|
|
570
|
+
* @throws {Error} If the public key is not set or address generation fails
|
|
571
|
+
*
|
|
572
|
+
* @example
|
|
573
|
+
* ```typescript
|
|
574
|
+
* const address = Address.fromString('0x02...');
|
|
575
|
+
* const p2wdaAddress = address.p2wda(networks.bitcoin);
|
|
576
|
+
* console.log(p2wdaAddress); // bc1q...
|
|
577
|
+
* ```
|
|
578
|
+
*/
|
|
330
579
|
p2wda(network) {
|
|
331
|
-
if (
|
|
332
|
-
return
|
|
580
|
+
if (this.#p2wda && this.#network === network) {
|
|
581
|
+
return this.#p2wda;
|
|
333
582
|
}
|
|
334
583
|
this.ensureLegacyProcessed();
|
|
335
|
-
if (!
|
|
584
|
+
if (!this.#originalPublicKey) {
|
|
336
585
|
throw new Error('Cannot create P2WDA address: public key not set');
|
|
337
586
|
}
|
|
338
|
-
const publicKeyBuffer =
|
|
587
|
+
const publicKeyBuffer = new Uint8Array(this.#originalPublicKey);
|
|
339
588
|
if (publicKeyBuffer.length !== 33) {
|
|
340
589
|
throw new Error('P2WDA requires a compressed public key (33 bytes)');
|
|
341
590
|
}
|
|
342
591
|
try {
|
|
343
592
|
const p2wdaInfo = P2WDADetector.generateP2WDAAddress(publicKeyBuffer, network);
|
|
344
|
-
|
|
345
|
-
|
|
593
|
+
this.#network = network;
|
|
594
|
+
this.#p2wda = p2wdaInfo;
|
|
346
595
|
return {
|
|
347
596
|
address: p2wdaInfo.address,
|
|
348
597
|
witnessScript: p2wdaInfo.witnessScript,
|
|
@@ -352,37 +601,82 @@ export class Address extends Uint8Array {
|
|
|
352
601
|
throw new Error(`Failed to generate P2WDA address: ${error.message}`);
|
|
353
602
|
}
|
|
354
603
|
}
|
|
604
|
+
/**
|
|
605
|
+
* Generate a P2WSH address with CSV (CheckSequenceVerify) time lock
|
|
606
|
+
* The resulting address can only be spent after the specified number of blocks
|
|
607
|
+
* have passed since the UTXO was created.
|
|
608
|
+
*
|
|
609
|
+
* @param {bigint | number | string} duration - The number of blocks that must pass before spending (1-65535)
|
|
610
|
+
* @param {Network} network - The Bitcoin network to use
|
|
611
|
+
* @returns {IP2WSHAddress} The timelocked address and its witness script
|
|
612
|
+
* @throws {Error} If the block number is out of range or public key is not available
|
|
613
|
+
*/
|
|
355
614
|
toCSV(duration, network) {
|
|
356
615
|
const n = Number(duration);
|
|
616
|
+
// First, let's validate the block number to ensure it's within the valid range
|
|
617
|
+
// CSV uses sequence numbers, which have special encoding for block-based locks
|
|
357
618
|
if (n < 1 || n > 65535) {
|
|
358
619
|
throw new Error('CSV block number must be between 1 and 65535');
|
|
359
620
|
}
|
|
621
|
+
// We need the original public key in compressed format for the script
|
|
622
|
+
// Your class stores this in #originalPublicKey when a key is set
|
|
360
623
|
this.ensureLegacyProcessed();
|
|
361
|
-
if (!
|
|
624
|
+
if (!this.#originalPublicKey) {
|
|
362
625
|
throw new Error('Cannot create CSV address: public key not set');
|
|
363
626
|
}
|
|
364
|
-
|
|
627
|
+
// Convert the public key to Uint8Array format that TimeLockGenerator expects
|
|
628
|
+
const publicKeyBuffer = new Uint8Array(this.#originalPublicKey);
|
|
629
|
+
// Now we can use your TimeLockGenerator to create the timelocked address
|
|
630
|
+
// Converting bigint to number is safe here because we've already validated the range
|
|
365
631
|
return TimeLockGenerator.generateTimeLockAddress(publicKeyBuffer, network, n);
|
|
366
632
|
}
|
|
633
|
+
/**
|
|
634
|
+
* Generate a P2TR address with CSV (CheckSequenceVerify) time lock
|
|
635
|
+
* The resulting address can only be spent after the specified number of blocks
|
|
636
|
+
* have passed since the UTXO was created.
|
|
637
|
+
*
|
|
638
|
+
* @param {bigint | number | string} duration - The number of blocks that must pass before spending (1-65535)
|
|
639
|
+
* @param {Network} network - The Bitcoin network to use
|
|
640
|
+
* @returns {IP2WSHAddress} The timelocked address and its witness script
|
|
641
|
+
* @throws {Error} If the block number is out of range or public key is not available
|
|
642
|
+
*/
|
|
367
643
|
toCSVTweaked(duration, network) {
|
|
368
644
|
const n = Number(duration);
|
|
645
|
+
// First, let's validate the block number to ensure it's within the valid range
|
|
646
|
+
// CSV uses sequence numbers, which have special encoding for block-based locks
|
|
369
647
|
if (n < 1 || n > 65535) {
|
|
370
648
|
throw new Error('CSV block number must be between 1 and 65535');
|
|
371
649
|
}
|
|
650
|
+
// We need the original public key in compressed format for the script
|
|
651
|
+
// Your class stores this in #originalPublicKey when a key is set
|
|
372
652
|
this.ensureLegacyProcessed();
|
|
373
|
-
if (!
|
|
653
|
+
if (!this.#originalPublicKey) {
|
|
374
654
|
throw new Error('Cannot create CSV address: public key not set');
|
|
375
655
|
}
|
|
656
|
+
// Now we can use your TimeLockGenerator to create the timelocked address
|
|
657
|
+
// Converting bigint to number is safe here because we've already validated the range
|
|
376
658
|
return TimeLockGenerator.generateTimeLockAddressP2TR(this.tweakedPublicKeyToBuffer(), network, n);
|
|
377
659
|
}
|
|
660
|
+
/**
|
|
661
|
+
* Returns the OPNet address encoded in bech32m format, derived from the SHA256 hash of the ML-DSA public key
|
|
662
|
+
* (which is what the Address internally stores).
|
|
663
|
+
*
|
|
664
|
+
* This method generates a P2OP (Pay-to-OPNet) address using witness version 16, suitable for
|
|
665
|
+
* quantum-resistant transactions on the OPNet protocol.
|
|
666
|
+
*
|
|
667
|
+
* @param network - The Bitcoin network to use (mainnet, testnet, regtest)
|
|
668
|
+
* @returns The P2OP address in bech32m format
|
|
669
|
+
*/
|
|
378
670
|
p2op(network) {
|
|
379
|
-
if (
|
|
380
|
-
return
|
|
671
|
+
if (this.#p2op && this.#network === network) {
|
|
672
|
+
return this.#p2op;
|
|
381
673
|
}
|
|
674
|
+
// p2op only uses the MLDSA hash (this Uint8Array), no legacy key processing needed.
|
|
675
|
+
// This is the HOT PATH for parsing - stays fast without triggering EC operations.
|
|
382
676
|
const p2opAddy = EcKeyPair.p2op(this, network);
|
|
383
677
|
if (p2opAddy) {
|
|
384
|
-
|
|
385
|
-
|
|
678
|
+
this.#network = network;
|
|
679
|
+
this.#p2op = p2opAddy;
|
|
386
680
|
return p2opAddy;
|
|
387
681
|
}
|
|
388
682
|
throw new Error('ML-DSA public key not set');
|
|
@@ -390,83 +684,107 @@ export class Address extends Uint8Array {
|
|
|
390
684
|
toTweakedHybridPublicKeyHex() {
|
|
391
685
|
this.ensureLegacyProcessed();
|
|
392
686
|
this.ensureTweakedUncompressed();
|
|
393
|
-
if (!
|
|
687
|
+
if (!this.#tweakedUncompressed) {
|
|
394
688
|
throw new Error('Legacy public key not set');
|
|
395
689
|
}
|
|
396
|
-
return '0x' +
|
|
690
|
+
return '0x' + toHex(this.#tweakedUncompressed);
|
|
397
691
|
}
|
|
398
692
|
toTweakedHybridPublicKeyBuffer() {
|
|
399
693
|
this.ensureLegacyProcessed();
|
|
400
694
|
this.ensureTweakedUncompressed();
|
|
401
|
-
if (!
|
|
695
|
+
if (!this.#tweakedUncompressed) {
|
|
402
696
|
throw new Error('Legacy public key not set');
|
|
403
697
|
}
|
|
404
|
-
return
|
|
698
|
+
return this.#tweakedUncompressed;
|
|
405
699
|
}
|
|
700
|
+
/**
|
|
701
|
+
* Lazily generates the tweaked uncompressed/hybrid key from the legacy public key.
|
|
702
|
+
* Only called when toTweakedHybridPublicKey* methods are accessed.
|
|
703
|
+
*/
|
|
406
704
|
ensureTweakedUncompressed() {
|
|
407
|
-
if (
|
|
705
|
+
if (this.#tweakedUncompressed)
|
|
408
706
|
return;
|
|
409
|
-
const key =
|
|
707
|
+
const key = this.#tweakedPublicKey;
|
|
410
708
|
if (!key)
|
|
411
709
|
return;
|
|
412
|
-
|
|
710
|
+
// Only attempt hybrid key generation for 32-byte keys that weren't processed through autoFormat
|
|
711
|
+
if (key.length === ADDRESS_BYTE_LENGTH && !this.#originalPublicKey) {
|
|
413
712
|
try {
|
|
414
|
-
|
|
415
|
-
buf.set(key);
|
|
416
|
-
__classPrivateFieldSet(this, _Address_tweakedUncompressed, ContractAddress.generateHybridKeyFromHash(buf), "f");
|
|
713
|
+
this.#tweakedUncompressed = ContractAddress.generateHybridKeyFromHash(key);
|
|
417
714
|
}
|
|
418
715
|
catch {
|
|
716
|
+
// Hybrid key generation may fail for keys that aren't valid EC points
|
|
717
|
+
// (e.g., zero addresses). Leave #tweakedUncompressed undefined.
|
|
419
718
|
}
|
|
420
719
|
}
|
|
421
720
|
}
|
|
721
|
+
/**
|
|
722
|
+
* Sets the MLDSA key portion of the address.
|
|
723
|
+
* @param {ArrayLike<number>} mldsaPublicKey - The MLDSA public key or its hash
|
|
724
|
+
*/
|
|
422
725
|
setMldsaKey(mldsaPublicKey) {
|
|
726
|
+
// THIS is the SHA256(ORIGINAL_ML_DSA_PUBLIC_KEY)
|
|
423
727
|
if (mldsaPublicKey.length === ADDRESS_BYTE_LENGTH) {
|
|
424
728
|
const buf = new Uint8Array(ADDRESS_BYTE_LENGTH);
|
|
425
729
|
buf.set(mldsaPublicKey);
|
|
426
730
|
super.set(buf);
|
|
427
731
|
}
|
|
428
732
|
else {
|
|
429
|
-
|
|
733
|
+
// Validate ML-DSA public key lengths according to BIP360 and FIPS 204
|
|
430
734
|
if (!validMLDSALengths.includes(mldsaPublicKey.length)) {
|
|
431
735
|
throw new Error(`Invalid ML-DSA public key length: ${mldsaPublicKey.length}. ` +
|
|
432
736
|
`Expected 1312 (ML-DSA-44/LEVEL2), 1952 (ML-DSA-65/LEVEL3), or 2592 (ML-DSA-87/LEVEL5) bytes.`);
|
|
433
737
|
}
|
|
434
|
-
|
|
435
|
-
|
|
738
|
+
// Store the original ML-DSA public key
|
|
739
|
+
this.#mldsaPublicKey = new Uint8Array(mldsaPublicKey.length);
|
|
740
|
+
this.#mldsaPublicKey.set(mldsaPublicKey);
|
|
741
|
+
// Hash the ML-DSA public key to get the 32-byte address
|
|
436
742
|
const hashedPublicKey = sha256(new Uint8Array(mldsaPublicKey));
|
|
437
743
|
const buf = new Uint8Array(ADDRESS_BYTE_LENGTH);
|
|
438
744
|
buf.set(hashedPublicKey);
|
|
439
745
|
super.set(buf);
|
|
440
746
|
}
|
|
441
747
|
}
|
|
748
|
+
/**
|
|
749
|
+
* Lazy processing of legacy key - defers expensive EC operations until actually needed.
|
|
750
|
+
* Does the EXACT same logic as the original set() method did for legacy keys.
|
|
751
|
+
*/
|
|
442
752
|
ensureLegacyProcessed() {
|
|
443
|
-
if (
|
|
753
|
+
if (this.#legacyProcessed)
|
|
444
754
|
return;
|
|
445
|
-
|
|
446
|
-
const pending =
|
|
755
|
+
this.#legacyProcessed = true;
|
|
756
|
+
const pending = this.#pendingLegacyKey;
|
|
447
757
|
if (!pending)
|
|
448
758
|
return;
|
|
759
|
+
// Length validation already done in constructor
|
|
449
760
|
if (pending.length === ADDRESS_BYTE_LENGTH) {
|
|
450
|
-
|
|
761
|
+
this.#tweakedPublicKey = pending;
|
|
451
762
|
}
|
|
452
763
|
else {
|
|
764
|
+
// 33 or 65 bytes: full autoFormat processing with EC operations
|
|
453
765
|
this.autoFormat(pending);
|
|
454
766
|
}
|
|
455
767
|
}
|
|
768
|
+
/**
|
|
769
|
+
* Processes a 33 or 65 byte public key, performing EC operations.
|
|
770
|
+
* Sets #tweakedPublicKey to 32-byte tweaked x-only (same as original behavior).
|
|
771
|
+
*/
|
|
456
772
|
autoFormat(publicKey) {
|
|
457
773
|
const firstByte = publicKey[0];
|
|
458
774
|
if (firstByte === 0x03 || firstByte === 0x02) {
|
|
775
|
+
// do nothing
|
|
459
776
|
}
|
|
460
777
|
else if (firstByte === 0x04 || firstByte === 0x06 || firstByte === 0x07) {
|
|
778
|
+
// uncompressed
|
|
461
779
|
publicKey = Address.uncompressedToCompressed(publicKey);
|
|
462
780
|
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
const tweakedBytes = toXOnly(EcKeyPair.tweakPublicKey(
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
781
|
+
this.#originalPublicKey = Uint8Array.from(publicKey);
|
|
782
|
+
this.#keyPair = EcKeyPair.fromPublicKey(this.#originalPublicKey);
|
|
783
|
+
this.#uncompressed = decompressPublicKey(this.#originalPublicKey);
|
|
784
|
+
const tweakedBytes = toXOnly(EcKeyPair.tweakPublicKey(this.#originalPublicKey));
|
|
785
|
+
this.#tweakedUncompressed = ContractAddress.generateHybridKeyFromHash(tweakedBytes);
|
|
786
|
+
this.#tweakedPublicKey = new Uint8Array(ADDRESS_BYTE_LENGTH);
|
|
787
|
+
this.#tweakedPublicKey.set(tweakedBytes);
|
|
470
788
|
}
|
|
471
789
|
}
|
|
472
|
-
|
|
790
|
+
//# sourceMappingURL=Address.js.map
|