@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,33 +1,124 @@
|
|
|
1
|
-
import bitcoin, {
|
|
1
|
+
import bitcoin, { equals, fromHex, getFinalScripts, opcodes, Psbt, script, toSatoshi, toXOnly, Transaction, } from '@btc-vision/bitcoin';
|
|
2
2
|
import { witnessStackToScriptWitness } from '../utils/WitnessUtils.js';
|
|
3
|
-
import
|
|
3
|
+
import { TransactionType } from '../enums/TransactionType.js';
|
|
4
4
|
import { EcKeyPair } from '../../keypair/EcKeyPair.js';
|
|
5
|
+
import {} from '@btc-vision/ecpair';
|
|
5
6
|
import { AddressVerificator } from '../../keypair/AddressVerificator.js';
|
|
6
7
|
import { TweakedTransaction } from '../shared/TweakedTransaction.js';
|
|
8
|
+
import { UnisatSigner } from '../browser/extensions/UnisatSigner.js';
|
|
7
9
|
import { P2WDADetector } from '../../p2wda/P2WDADetector.js';
|
|
8
|
-
import { FeaturePriority, Features } from '../../generators/Features.js';
|
|
10
|
+
import { FeaturePriority, Features, } from '../../generators/Features.js';
|
|
9
11
|
import { BITCOIN_PROTOCOL_ID, getChainId } from '../../chain/ChainData.js';
|
|
10
12
|
import { BinaryWriter } from '../../buffer/BinaryWriter.js';
|
|
11
13
|
import { MLDSASecurityLevel } from '@btc-vision/bip32';
|
|
12
14
|
import { MessageSigner } from '../../keypair/MessageSigner.js';
|
|
13
15
|
import { getLevelFromPublicKeyLength } from '../../generators/MLDSAData.js';
|
|
14
|
-
|
|
15
|
-
export const MINIMUM_AMOUNT_REWARD = 330n;
|
|
16
|
+
export const MINIMUM_AMOUNT_REWARD = 330n; //540n;
|
|
16
17
|
export const MINIMUM_AMOUNT_CA = 297n;
|
|
17
|
-
export const ANCHOR_SCRIPT =
|
|
18
|
+
export const ANCHOR_SCRIPT = fromHex('51024e73');
|
|
19
|
+
/**
|
|
20
|
+
* Allows to build a transaction like you would on Ethereum.
|
|
21
|
+
* @description The transaction builder class
|
|
22
|
+
* @abstract
|
|
23
|
+
* @class TransactionBuilder
|
|
24
|
+
*/
|
|
18
25
|
export class TransactionBuilder extends TweakedTransaction {
|
|
26
|
+
static MINIMUM_DUST = 330n;
|
|
27
|
+
logColor = '#785def';
|
|
28
|
+
debugFees = false;
|
|
29
|
+
// Cancel script
|
|
30
|
+
LOCK_LEAF_SCRIPT;
|
|
31
|
+
/**
|
|
32
|
+
* @description The overflow fees of the transaction
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
overflowFees = 0n;
|
|
36
|
+
/**
|
|
37
|
+
* @description Cost in satoshis of the transaction fee
|
|
38
|
+
*/
|
|
39
|
+
transactionFee = 0n;
|
|
40
|
+
/**
|
|
41
|
+
* @description The estimated fees of the transaction
|
|
42
|
+
*/
|
|
43
|
+
estimatedFees = 0n;
|
|
44
|
+
/**
|
|
45
|
+
* @param {ITransactionParameters} parameters - The transaction parameters
|
|
46
|
+
*/
|
|
47
|
+
optionalOutputs;
|
|
48
|
+
/**
|
|
49
|
+
* @description The transaction itself.
|
|
50
|
+
*/
|
|
51
|
+
transaction;
|
|
52
|
+
/**
|
|
53
|
+
* @description Inputs to update later on.
|
|
54
|
+
*/
|
|
55
|
+
updateInputs = [];
|
|
56
|
+
/**
|
|
57
|
+
* @description The outputs of the transaction
|
|
58
|
+
*/
|
|
59
|
+
outputs = [];
|
|
60
|
+
/**
|
|
61
|
+
* @description Output that will be used to pay the fees
|
|
62
|
+
*/
|
|
63
|
+
feeOutput = null;
|
|
64
|
+
/**
|
|
65
|
+
* @description The total amount of satoshis in the inputs
|
|
66
|
+
*/
|
|
67
|
+
totalInputAmount;
|
|
68
|
+
/**
|
|
69
|
+
* @description The signer of the transaction
|
|
70
|
+
*/
|
|
71
|
+
signer;
|
|
72
|
+
/**
|
|
73
|
+
* @description The network where the transaction will be broadcasted
|
|
74
|
+
*/
|
|
75
|
+
network;
|
|
76
|
+
/**
|
|
77
|
+
* @description The fee rate of the transaction
|
|
78
|
+
*/
|
|
79
|
+
feeRate;
|
|
80
|
+
/**
|
|
81
|
+
* @description The opnet priority fee of the transaction
|
|
82
|
+
*/
|
|
83
|
+
priorityFee;
|
|
84
|
+
gasSatFee;
|
|
85
|
+
/**
|
|
86
|
+
* @description The utxos used in the transaction
|
|
87
|
+
*/
|
|
88
|
+
utxos;
|
|
89
|
+
/**
|
|
90
|
+
* @description The inputs of the transaction
|
|
91
|
+
* @protected
|
|
92
|
+
*/
|
|
93
|
+
optionalInputs;
|
|
94
|
+
/**
|
|
95
|
+
* @description The address where the transaction is sent to
|
|
96
|
+
* @protected
|
|
97
|
+
*/
|
|
98
|
+
to;
|
|
99
|
+
/**
|
|
100
|
+
* @description The address where the transaction is sent from
|
|
101
|
+
* @protected
|
|
102
|
+
*/
|
|
103
|
+
from;
|
|
104
|
+
/**
|
|
105
|
+
* @description The maximum fee rate of the transaction
|
|
106
|
+
*/
|
|
107
|
+
_maximumFeeRate = 100000000;
|
|
108
|
+
/**
|
|
109
|
+
* @description Is the destionation P2PK
|
|
110
|
+
* @protected
|
|
111
|
+
*/
|
|
112
|
+
isPubKeyDestination;
|
|
113
|
+
/**
|
|
114
|
+
* @description If the transaction need an anchor output
|
|
115
|
+
* @protected
|
|
116
|
+
*/
|
|
117
|
+
anchor;
|
|
118
|
+
note;
|
|
119
|
+
optionalOutputsAdded = false;
|
|
19
120
|
constructor(parameters) {
|
|
20
121
|
super(parameters);
|
|
21
|
-
this.logColor = '#785def';
|
|
22
|
-
this.debugFees = false;
|
|
23
|
-
this.overflowFees = 0n;
|
|
24
|
-
this.transactionFee = 0n;
|
|
25
|
-
this.estimatedFees = 0n;
|
|
26
|
-
this.updateInputs = [];
|
|
27
|
-
this.outputs = [];
|
|
28
|
-
this.feeOutput = null;
|
|
29
|
-
this._maximumFeeRate = 100000000;
|
|
30
|
-
this.optionalOutputsAdded = false;
|
|
31
122
|
if (parameters.estimatedFees) {
|
|
32
123
|
this.estimatedFees = parameters.estimatedFees;
|
|
33
124
|
}
|
|
@@ -43,7 +134,7 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
43
134
|
this.LOCK_LEAF_SCRIPT = this.defineLockScript();
|
|
44
135
|
if (parameters.note) {
|
|
45
136
|
if (typeof parameters.note === 'string') {
|
|
46
|
-
this.note =
|
|
137
|
+
this.note = new TextEncoder().encode(parameters.note);
|
|
47
138
|
}
|
|
48
139
|
else {
|
|
49
140
|
this.note = parameters.note;
|
|
@@ -68,19 +159,34 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
68
159
|
static getFrom(from, keypair, network) {
|
|
69
160
|
return from || EcKeyPair.getTaprootAddress(keypair, network);
|
|
70
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* @description Converts the witness stack to a script witness
|
|
164
|
+
* @param {Buffer[]} witness - The witness stack
|
|
165
|
+
* @protected
|
|
166
|
+
* @returns {Buffer}
|
|
167
|
+
*/
|
|
71
168
|
static witnessStackToScriptWitness(witness) {
|
|
72
169
|
return witnessStackToScriptWitness(witness);
|
|
73
170
|
}
|
|
171
|
+
[Symbol.dispose]() {
|
|
172
|
+
super[Symbol.dispose]();
|
|
173
|
+
this.updateInputs.length = 0;
|
|
174
|
+
this.outputs.length = 0;
|
|
175
|
+
this.feeOutput = null;
|
|
176
|
+
this.optionalOutputs = undefined;
|
|
177
|
+
this.utxos = [];
|
|
178
|
+
this.optionalInputs = [];
|
|
179
|
+
}
|
|
74
180
|
addOPReturn(buffer) {
|
|
75
181
|
const compileScript = script.compile([opcodes.OP_RETURN, buffer]);
|
|
76
182
|
this.addOutput({
|
|
77
|
-
value:
|
|
183
|
+
value: toSatoshi(0n),
|
|
78
184
|
script: compileScript,
|
|
79
185
|
});
|
|
80
186
|
}
|
|
81
187
|
addAnchor() {
|
|
82
188
|
this.addOutput({
|
|
83
|
-
value:
|
|
189
|
+
value: toSatoshi(0n),
|
|
84
190
|
script: ANCHOR_SCRIPT,
|
|
85
191
|
});
|
|
86
192
|
}
|
|
@@ -98,17 +204,34 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
98
204
|
gasSatFee: this.gasSatFee ?? 0n,
|
|
99
205
|
from: this.from,
|
|
100
206
|
amount: this.estimatedFees,
|
|
101
|
-
optionalOutputs: this.optionalOutputs,
|
|
102
207
|
optionalInputs: this.optionalInputs,
|
|
103
208
|
mldsaSigner: null,
|
|
209
|
+
...(this.optionalOutputs !== undefined
|
|
210
|
+
? { optionalOutputs: this.optionalOutputs }
|
|
211
|
+
: {}),
|
|
104
212
|
};
|
|
105
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* Set the destination address of the transaction
|
|
216
|
+
* @param {string} address - The address to set
|
|
217
|
+
*/
|
|
106
218
|
setDestinationAddress(address) {
|
|
107
|
-
this.to = address;
|
|
219
|
+
this.to = address; // this.getScriptAddress()
|
|
108
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* Set the maximum fee rate of the transaction in satoshis per byte
|
|
223
|
+
* @param {number} feeRate - The fee rate to set
|
|
224
|
+
* @public
|
|
225
|
+
*/
|
|
109
226
|
setMaximumFeeRate(feeRate) {
|
|
110
227
|
this._maximumFeeRate = feeRate;
|
|
111
228
|
}
|
|
229
|
+
/**
|
|
230
|
+
* @description Signs the transaction
|
|
231
|
+
* @public
|
|
232
|
+
* @returns {Promise<Transaction>} - The signed transaction in hex format
|
|
233
|
+
* @throws {Error} - If something went wrong
|
|
234
|
+
*/
|
|
112
235
|
async signTransaction() {
|
|
113
236
|
if (!this.utxos.length) {
|
|
114
237
|
throw new Error('No UTXOs specified');
|
|
@@ -131,6 +254,10 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
131
254
|
}
|
|
132
255
|
throw new Error('Could not sign transaction');
|
|
133
256
|
}
|
|
257
|
+
/**
|
|
258
|
+
* @description Generates the transaction minimal signatures
|
|
259
|
+
* @public
|
|
260
|
+
*/
|
|
134
261
|
async generateTransactionMinimalSignatures(checkPartialSigs = false) {
|
|
135
262
|
if (this.to &&
|
|
136
263
|
!this.isPubKeyDestination &&
|
|
@@ -149,42 +276,81 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
149
276
|
this.transaction.addOutputs(outputs);
|
|
150
277
|
}
|
|
151
278
|
}
|
|
279
|
+
/**
|
|
280
|
+
* @description Signs the transaction
|
|
281
|
+
* @public
|
|
282
|
+
* @returns {Promise<Psbt>} - The signed transaction in hex format
|
|
283
|
+
* @throws {Error} - If something went wrong
|
|
284
|
+
*/
|
|
152
285
|
async signPSBT() {
|
|
153
286
|
if (await this.signTransaction()) {
|
|
154
287
|
return this.transaction;
|
|
155
288
|
}
|
|
156
289
|
throw new Error('Could not sign transaction');
|
|
157
290
|
}
|
|
291
|
+
/**
|
|
292
|
+
* Add an input to the transaction.
|
|
293
|
+
* @param {PsbtInputExtended} input - The input to add
|
|
294
|
+
* @public
|
|
295
|
+
* @returns {void}
|
|
296
|
+
*/
|
|
158
297
|
addInput(input) {
|
|
159
298
|
this.inputs.push(input);
|
|
160
299
|
}
|
|
300
|
+
/**
|
|
301
|
+
* Add an output to the transaction.
|
|
302
|
+
* @param {PsbtOutputExtended} output - The output to add
|
|
303
|
+
* @param bypassMinCheck
|
|
304
|
+
* @public
|
|
305
|
+
* @returns {void}
|
|
306
|
+
*/
|
|
161
307
|
addOutput(output, bypassMinCheck = false) {
|
|
162
|
-
if (output.value ===
|
|
163
|
-
const
|
|
164
|
-
if (!
|
|
308
|
+
if (output.value === toSatoshi(0n)) {
|
|
309
|
+
const scriptOutput = output;
|
|
310
|
+
if (!scriptOutput.script || scriptOutput.script.length === 0) {
|
|
165
311
|
throw new Error('Output value is 0 and no script provided');
|
|
166
312
|
}
|
|
167
|
-
if (
|
|
313
|
+
if (scriptOutput.script.length < 2) {
|
|
168
314
|
throw new Error('Output script is too short');
|
|
169
315
|
}
|
|
170
|
-
if (
|
|
316
|
+
if (scriptOutput.script[0] !== opcodes.OP_RETURN &&
|
|
317
|
+
!equals(scriptOutput.script, ANCHOR_SCRIPT)) {
|
|
171
318
|
throw new Error('Output script must start with OP_RETURN or be an ANCHOR when value is 0');
|
|
172
319
|
}
|
|
173
320
|
}
|
|
174
|
-
else if (!bypassMinCheck && output.value < TransactionBuilder.MINIMUM_DUST) {
|
|
321
|
+
else if (!bypassMinCheck && BigInt(output.value) < TransactionBuilder.MINIMUM_DUST) {
|
|
175
322
|
throw new Error(`Output value is less than the minimum dust ${output.value} < ${TransactionBuilder.MINIMUM_DUST}`);
|
|
176
323
|
}
|
|
177
324
|
this.outputs.push(output);
|
|
178
325
|
}
|
|
326
|
+
/**
|
|
327
|
+
* Returns the total value of all outputs added so far (excluding the fee/change output).
|
|
328
|
+
* @public
|
|
329
|
+
* @returns {bigint}
|
|
330
|
+
*/
|
|
179
331
|
getTotalOutputValue() {
|
|
180
332
|
return this.outputs.reduce((total, output) => total + BigInt(output.value), 0n);
|
|
181
333
|
}
|
|
334
|
+
/**
|
|
335
|
+
* Receiver address.
|
|
336
|
+
* @public
|
|
337
|
+
* @returns {string} - The receiver address
|
|
338
|
+
*/
|
|
182
339
|
toAddress() {
|
|
183
340
|
return this.to;
|
|
184
341
|
}
|
|
342
|
+
/**
|
|
343
|
+
* @description Returns the script address
|
|
344
|
+
* @returns {string} - The script address
|
|
345
|
+
*/
|
|
185
346
|
address() {
|
|
186
347
|
return this.tapData?.address;
|
|
187
348
|
}
|
|
349
|
+
/**
|
|
350
|
+
* Estimates the transaction fees with accurate size calculation.
|
|
351
|
+
* @public
|
|
352
|
+
* @returns {Promise<bigint>}
|
|
353
|
+
*/
|
|
188
354
|
async estimateTransactionFees() {
|
|
189
355
|
await Promise.resolve();
|
|
190
356
|
const fakeTx = new Psbt({ network: this.network });
|
|
@@ -192,22 +358,23 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
192
358
|
const outputs = this.getOutputs();
|
|
193
359
|
fakeTx.addInputs(inputs);
|
|
194
360
|
fakeTx.addOutputs(outputs);
|
|
195
|
-
const dummySchnorrSig =
|
|
196
|
-
const dummyEcdsaSig =
|
|
197
|
-
const dummyCompressedPubkey =
|
|
361
|
+
const dummySchnorrSig = new Uint8Array(64);
|
|
362
|
+
const dummyEcdsaSig = new Uint8Array(72);
|
|
363
|
+
const dummyCompressedPubkey = new Uint8Array(33).fill(2);
|
|
198
364
|
const finalizer = (inputIndex, input) => {
|
|
199
365
|
if (input.isPayToAnchor || this.anchorInputIndices.has(inputIndex)) {
|
|
200
366
|
return {
|
|
201
367
|
finalScriptSig: undefined,
|
|
202
|
-
finalScriptWitness:
|
|
368
|
+
finalScriptWitness: Uint8Array.from([0]),
|
|
203
369
|
};
|
|
204
370
|
}
|
|
205
371
|
if (input.witnessScript && P2WDADetector.isP2WDAWitnessScript(input.witnessScript)) {
|
|
372
|
+
// Create dummy witness stack for P2WDA
|
|
206
373
|
const dummyDataSlots = [];
|
|
207
374
|
for (let i = 0; i < 10; i++) {
|
|
208
|
-
dummyDataSlots.push(
|
|
375
|
+
dummyDataSlots.push(new Uint8Array(0));
|
|
209
376
|
}
|
|
210
|
-
const dummyEcdsaSig =
|
|
377
|
+
const dummyEcdsaSig = new Uint8Array(72);
|
|
211
378
|
return {
|
|
212
379
|
finalScriptWitness: TransactionBuilder.witnessStackToScriptWitness([
|
|
213
380
|
...dummyDataSlots,
|
|
@@ -217,14 +384,15 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
217
384
|
};
|
|
218
385
|
}
|
|
219
386
|
if (inputIndex === 0 && this.tapLeafScript) {
|
|
220
|
-
const dummySecret =
|
|
387
|
+
const dummySecret = new Uint8Array(32);
|
|
221
388
|
const dummyScript = this.tapLeafScript.script;
|
|
222
|
-
|
|
389
|
+
// A control block for a 2-leaf tree contains one 32-byte hash.
|
|
390
|
+
const dummyControlBlock = new Uint8Array(1 + 32 + 32);
|
|
223
391
|
return {
|
|
224
392
|
finalScriptWitness: TransactionBuilder.witnessStackToScriptWitness([
|
|
225
393
|
dummySecret,
|
|
226
|
-
dummySchnorrSig,
|
|
227
|
-
dummySchnorrSig,
|
|
394
|
+
dummySchnorrSig, // It's a tapScriptSig, which is Schnorr
|
|
395
|
+
dummySchnorrSig, // Second Schnorr signature
|
|
228
396
|
dummyScript,
|
|
229
397
|
dummyControlBlock,
|
|
230
398
|
]),
|
|
@@ -250,6 +418,7 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
250
418
|
}
|
|
251
419
|
if (input.witnessScript) {
|
|
252
420
|
if (this.csvInputIndices.has(inputIndex)) {
|
|
421
|
+
// CSV P2WSH needs: [signature, witnessScript]
|
|
253
422
|
return {
|
|
254
423
|
finalScriptWitness: TransactionBuilder.witnessStackToScriptWitness([
|
|
255
424
|
dummyEcdsaSig,
|
|
@@ -258,6 +427,7 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
258
427
|
};
|
|
259
428
|
}
|
|
260
429
|
if (input.redeemScript) {
|
|
430
|
+
// P2SH-P2WSH needs redeemScript in scriptSig and witness data
|
|
261
431
|
const dummyWitness = [dummyEcdsaSig, input.witnessScript];
|
|
262
432
|
return {
|
|
263
433
|
finalScriptSig: input.redeemScript,
|
|
@@ -268,6 +438,7 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
268
438
|
if (decompiled && decompiled.length >= 4) {
|
|
269
439
|
const firstOp = decompiled[0];
|
|
270
440
|
const lastOp = decompiled[decompiled.length - 1];
|
|
441
|
+
// Check if it's M-of-N multisig
|
|
271
442
|
if (typeof firstOp === 'number' &&
|
|
272
443
|
firstOp >= opcodes.OP_1 &&
|
|
273
444
|
lastOp === opcodes.OP_CHECKMULTISIG) {
|
|
@@ -278,7 +449,7 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
278
449
|
}
|
|
279
450
|
return {
|
|
280
451
|
finalScriptWitness: TransactionBuilder.witnessStackToScriptWitness([
|
|
281
|
-
|
|
452
|
+
new Uint8Array(0), // OP_0 due to multisig bug
|
|
282
453
|
...signatures,
|
|
283
454
|
input.witnessScript,
|
|
284
455
|
]),
|
|
@@ -297,8 +468,9 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
297
468
|
if (decompiled &&
|
|
298
469
|
decompiled.length === 2 &&
|
|
299
470
|
decompiled[0] === opcodes.OP_0 &&
|
|
300
|
-
|
|
471
|
+
decompiled[1] instanceof Uint8Array &&
|
|
301
472
|
decompiled[1].length === 20) {
|
|
473
|
+
// P2SH-P2WPKH
|
|
302
474
|
return {
|
|
303
475
|
finalScriptSig: input.redeemScript,
|
|
304
476
|
finalScriptWitness: TransactionBuilder.witnessStackToScriptWitness([
|
|
@@ -309,13 +481,14 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
309
481
|
}
|
|
310
482
|
}
|
|
311
483
|
if (input.redeemScript && !input.witnessScript && !input.witnessUtxo) {
|
|
484
|
+
// Pure P2SH needs signatures + redeemScript in scriptSig
|
|
312
485
|
return {
|
|
313
486
|
finalScriptSig: bitcoin.script.compile([dummyEcdsaSig, input.redeemScript]),
|
|
314
487
|
finalScriptWitness: undefined,
|
|
315
488
|
};
|
|
316
489
|
}
|
|
317
|
-
const
|
|
318
|
-
if (!
|
|
490
|
+
const inputScript = input.witnessUtxo?.script;
|
|
491
|
+
if (!inputScript)
|
|
319
492
|
return { finalScriptSig: undefined, finalScriptWitness: undefined };
|
|
320
493
|
if (input.tapInternalKey) {
|
|
321
494
|
return {
|
|
@@ -324,7 +497,7 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
324
497
|
]),
|
|
325
498
|
};
|
|
326
499
|
}
|
|
327
|
-
if (
|
|
500
|
+
if (inputScript.length === 22 && inputScript[0] === opcodes.OP_0) {
|
|
328
501
|
return {
|
|
329
502
|
finalScriptWitness: TransactionBuilder.witnessStackToScriptWitness([
|
|
330
503
|
dummyEcdsaSig,
|
|
@@ -340,7 +513,7 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
340
513
|
]),
|
|
341
514
|
};
|
|
342
515
|
}
|
|
343
|
-
return getFinalScripts(inputIndex, input,
|
|
516
|
+
return getFinalScripts(inputIndex, input, inputScript, true, !!input.redeemScript, !!input.witnessScript);
|
|
344
517
|
};
|
|
345
518
|
try {
|
|
346
519
|
for (let i = 0; i < fakeTx.data.inputs.length; i++) {
|
|
@@ -374,9 +547,19 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
374
547
|
setPSBT(psbt) {
|
|
375
548
|
this.transaction = psbt;
|
|
376
549
|
}
|
|
550
|
+
/**
|
|
551
|
+
* Returns the inputs of the transaction.
|
|
552
|
+
* @protected
|
|
553
|
+
* @returns {PsbtInputExtended[]}
|
|
554
|
+
*/
|
|
377
555
|
getInputs() {
|
|
378
556
|
return this.inputs;
|
|
379
557
|
}
|
|
558
|
+
/**
|
|
559
|
+
* Returns the outputs of the transaction.
|
|
560
|
+
* @protected
|
|
561
|
+
* @returns {PsbtOutputExtended[]}
|
|
562
|
+
*/
|
|
380
563
|
getOutputs() {
|
|
381
564
|
const outputs = [...this.outputs];
|
|
382
565
|
if (this.feeOutput)
|
|
@@ -399,78 +582,59 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
399
582
|
if (this.anchor) {
|
|
400
583
|
this.addAnchor();
|
|
401
584
|
}
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
const
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
585
|
+
// Add a dummy change output to estimate fee with the change-output shape
|
|
586
|
+
this.feeOutput = this.createChangeOutput(TransactionBuilder.MINIMUM_DUST);
|
|
587
|
+
const feeWithChange = await this.estimateTransactionFees();
|
|
588
|
+
const sendBackAmount = this.totalInputAmount - amountSpent - feeWithChange;
|
|
589
|
+
if (this.debugFees) {
|
|
590
|
+
this.log(`Fee with change: ${feeWithChange} sats, inputAmount=${this.totalInputAmount}, amountSpent=${amountSpent}, sendBackAmount=${sendBackAmount}`);
|
|
591
|
+
}
|
|
592
|
+
if (sendBackAmount >= TransactionBuilder.MINIMUM_DUST) {
|
|
593
|
+
// Change output is viable, set it to the real value
|
|
594
|
+
this.feeOutput = this.createChangeOutput(sendBackAmount);
|
|
595
|
+
this.overflowFees = sendBackAmount;
|
|
596
|
+
this.transactionFee = feeWithChange;
|
|
597
|
+
}
|
|
598
|
+
else {
|
|
599
|
+
// Change output not viable, remove it and re-estimate without it
|
|
600
|
+
this.feeOutput = null;
|
|
601
|
+
this.overflowFees = 0n;
|
|
602
|
+
const feeWithoutChange = await this.estimateTransactionFees();
|
|
603
|
+
this.transactionFee = feeWithoutChange;
|
|
412
604
|
if (this.debugFees) {
|
|
413
|
-
this.
|
|
414
|
-
}
|
|
415
|
-
if (sendBackAmount >= TransactionBuilder.MINIMUM_DUST) {
|
|
416
|
-
if (AddressVerificator.isValidP2TRAddress(this.from, this.network)) {
|
|
417
|
-
this.feeOutput = {
|
|
418
|
-
value: Number(sendBackAmount),
|
|
419
|
-
address: this.from,
|
|
420
|
-
tapInternalKey: this.internalPubKeyToXOnly(),
|
|
421
|
-
};
|
|
422
|
-
}
|
|
423
|
-
else if (AddressVerificator.isValidPublicKey(this.from, this.network)) {
|
|
424
|
-
const pubKeyScript = script.compile([
|
|
425
|
-
Buffer.from(this.from.replace('0x', ''), 'hex'),
|
|
426
|
-
opcodes.OP_CHECKSIG,
|
|
427
|
-
]);
|
|
428
|
-
this.feeOutput = {
|
|
429
|
-
value: Number(sendBackAmount),
|
|
430
|
-
script: pubKeyScript,
|
|
431
|
-
};
|
|
432
|
-
}
|
|
433
|
-
else {
|
|
434
|
-
this.feeOutput = {
|
|
435
|
-
value: Number(sendBackAmount),
|
|
436
|
-
address: this.from,
|
|
437
|
-
};
|
|
438
|
-
}
|
|
439
|
-
this.overflowFees = sendBackAmount;
|
|
605
|
+
this.warn(`Amount to send back (${sendBackAmount} sat) is less than minimum dust. Fee without change: ${feeWithoutChange} sats`);
|
|
440
606
|
}
|
|
441
|
-
|
|
442
|
-
this.
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
}
|
|
447
|
-
if (this.debugFees) {
|
|
448
|
-
this.warn(`Amount to send back (${sendBackAmount} sat) is less than minimum dust...`);
|
|
449
|
-
}
|
|
607
|
+
if (this.totalInputAmount <= amountSpent) {
|
|
608
|
+
throw new Error(`Insufficient funds: need ${amountSpent + feeWithoutChange} sats but only have ${this.totalInputAmount} sats`);
|
|
609
|
+
}
|
|
610
|
+
if (expectRefund && sendBackAmount < 0n) {
|
|
611
|
+
throw new Error(`Insufficient funds: need at least ${-sendBackAmount} more sats to cover fees.`);
|
|
450
612
|
}
|
|
451
|
-
iterations++;
|
|
452
|
-
}
|
|
453
|
-
if (expectRefund && sendBackAmount < 0n) {
|
|
454
|
-
throw new Error(`Insufficient funds: need at least ${-sendBackAmount} more sats to cover fees.`);
|
|
455
|
-
}
|
|
456
|
-
if (iterations >= maxIterations) {
|
|
457
|
-
this.warn(`Fee calculation did not stabilize after ${maxIterations} iterations`);
|
|
458
613
|
}
|
|
459
|
-
this.transactionFee = estimatedFee;
|
|
460
614
|
if (this.debugFees) {
|
|
461
|
-
this.log(`Final fee: ${
|
|
615
|
+
this.log(`Final fee: ${this.transactionFee} sats, Change output: ${this.feeOutput ? `${this.feeOutput.value} sats` : 'none'}`);
|
|
462
616
|
}
|
|
463
617
|
}
|
|
464
618
|
defineLockScript() {
|
|
465
|
-
return script.compile([toXOnly(
|
|
466
|
-
}
|
|
619
|
+
return script.compile([toXOnly(this.signer.publicKey), opcodes.OP_CHECKSIG]);
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* @description Adds the value to the output
|
|
623
|
+
* @param {number | bigint} value - The value to add
|
|
624
|
+
* @protected
|
|
625
|
+
* @returns {void}
|
|
626
|
+
*/
|
|
467
627
|
addValueToToOutput(value) {
|
|
468
|
-
if (value < TransactionBuilder.MINIMUM_DUST) {
|
|
628
|
+
if (BigInt(value) < TransactionBuilder.MINIMUM_DUST) {
|
|
469
629
|
throw new Error(`Value to send is less than the minimum dust ${value} < ${TransactionBuilder.MINIMUM_DUST}`);
|
|
470
630
|
}
|
|
471
|
-
for (
|
|
631
|
+
for (let i = 0; i < this.outputs.length; i++) {
|
|
632
|
+
const output = this.outputs[i];
|
|
472
633
|
if ('address' in output && output.address === this.to) {
|
|
473
|
-
|
|
634
|
+
this.outputs[i] = {
|
|
635
|
+
...output,
|
|
636
|
+
value: toSatoshi(BigInt(output.value) + BigInt(value)),
|
|
637
|
+
};
|
|
474
638
|
return;
|
|
475
639
|
}
|
|
476
640
|
}
|
|
@@ -488,6 +652,7 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
488
652
|
}
|
|
489
653
|
const chainId = getChainId(this.network);
|
|
490
654
|
const writer = new BinaryWriter();
|
|
655
|
+
// ONLY SUPPORT MLDSA-44 FOR NOW.
|
|
491
656
|
writer.writeU8(MLDSASecurityLevel.LEVEL2);
|
|
492
657
|
writer.writeBytes(this.hashedPublicKey);
|
|
493
658
|
writer.writeBytes(tweakedKey);
|
|
@@ -500,7 +665,7 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
500
665
|
if (!isValid) {
|
|
501
666
|
throw new Error('Could not verify generated legacy signature for MLDSA link request');
|
|
502
667
|
}
|
|
503
|
-
return
|
|
668
|
+
return new Uint8Array(signature.signature);
|
|
504
669
|
}
|
|
505
670
|
generateMLDSASignature() {
|
|
506
671
|
if (!this.mldsaSigner) {
|
|
@@ -534,7 +699,7 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
534
699
|
if (!isValid) {
|
|
535
700
|
throw new Error('Could not verify generated MLDSA signature for link request');
|
|
536
701
|
}
|
|
537
|
-
return
|
|
702
|
+
return new Uint8Array(signature.signature);
|
|
538
703
|
}
|
|
539
704
|
generateMLDSALinkRequest(parameters, features) {
|
|
540
705
|
const mldsaSigner = this.mldsaSigner;
|
|
@@ -557,6 +722,11 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
557
722
|
};
|
|
558
723
|
features.push(mldsaRequest);
|
|
559
724
|
}
|
|
725
|
+
/**
|
|
726
|
+
* @description Returns the transaction opnet fee
|
|
727
|
+
* @protected
|
|
728
|
+
* @returns {bigint}
|
|
729
|
+
*/
|
|
560
730
|
getTransactionOPNetFee() {
|
|
561
731
|
const totalFee = this.priorityFee + this.gasSatFee;
|
|
562
732
|
if (totalFee > TransactionBuilder.MINIMUM_DUST) {
|
|
@@ -564,6 +734,11 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
564
734
|
}
|
|
565
735
|
return TransactionBuilder.MINIMUM_DUST;
|
|
566
736
|
}
|
|
737
|
+
/**
|
|
738
|
+
* @description Returns the total amount of satoshis in the inputs
|
|
739
|
+
* @protected
|
|
740
|
+
* @returns {bigint}
|
|
741
|
+
*/
|
|
567
742
|
calculateTotalUTXOAmount() {
|
|
568
743
|
let total = 0n;
|
|
569
744
|
for (const utxo of this.utxos) {
|
|
@@ -574,6 +749,11 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
574
749
|
}
|
|
575
750
|
return total;
|
|
576
751
|
}
|
|
752
|
+
/**
|
|
753
|
+
* @description Returns the total amount of satoshis in the outputs
|
|
754
|
+
* @protected
|
|
755
|
+
* @returns {bigint}
|
|
756
|
+
*/
|
|
577
757
|
calculateTotalVOutAmount() {
|
|
578
758
|
let total = 0n;
|
|
579
759
|
for (const utxo of this.utxos) {
|
|
@@ -584,6 +764,11 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
584
764
|
}
|
|
585
765
|
return total;
|
|
586
766
|
}
|
|
767
|
+
/**
|
|
768
|
+
* @description Adds optional outputs to transaction and returns their total value in satoshi to calculate refund transaction
|
|
769
|
+
* @protected
|
|
770
|
+
* @returns {bigint}
|
|
771
|
+
*/
|
|
587
772
|
addOptionalOutputsAndGetAmount() {
|
|
588
773
|
if (!this.optionalOutputs || this.optionalOutputsAdded)
|
|
589
774
|
return 0n;
|
|
@@ -595,13 +780,20 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
595
780
|
this.optionalOutputsAdded = true;
|
|
596
781
|
return refundedFromOptionalOutputs;
|
|
597
782
|
}
|
|
783
|
+
/**
|
|
784
|
+
* @description Adds the inputs from the utxos
|
|
785
|
+
* @protected
|
|
786
|
+
* @returns {void}
|
|
787
|
+
*/
|
|
598
788
|
addInputsFromUTXO() {
|
|
599
789
|
if (this.utxos.length) {
|
|
790
|
+
//throw new Error('No UTXOs specified');
|
|
600
791
|
if (this.totalInputAmount < TransactionBuilder.MINIMUM_DUST) {
|
|
601
792
|
throw new Error(`Total input amount is ${this.totalInputAmount} sat which is less than the minimum dust ${TransactionBuilder.MINIMUM_DUST} sat.`);
|
|
602
793
|
}
|
|
603
794
|
for (let i = 0; i < this.utxos.length; i++) {
|
|
604
795
|
const utxo = this.utxos[i];
|
|
796
|
+
// Register signer BEFORE generating input (needed for tapInternalKey)
|
|
605
797
|
this.registerInputSigner(i, utxo);
|
|
606
798
|
const input = this.generatePsbtInputExtended(utxo, i);
|
|
607
799
|
this.addInput(input);
|
|
@@ -610,19 +802,38 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
610
802
|
if (this.optionalInputs) {
|
|
611
803
|
for (let i = this.utxos.length; i < this.optionalInputs.length + this.utxos.length; i++) {
|
|
612
804
|
const utxo = this.optionalInputs[i - this.utxos.length];
|
|
805
|
+
// Register signer BEFORE generating input (needed for tapInternalKey)
|
|
613
806
|
this.registerInputSigner(i, utxo);
|
|
614
807
|
const input = this.generatePsbtInputExtended(utxo, i, true);
|
|
615
808
|
this.addInput(input);
|
|
616
809
|
}
|
|
617
810
|
}
|
|
618
811
|
}
|
|
812
|
+
/**
|
|
813
|
+
* Internal init.
|
|
814
|
+
* @protected
|
|
815
|
+
*/
|
|
619
816
|
internalInit() {
|
|
620
817
|
this.verifyUTXOValidity();
|
|
621
818
|
super.internalInit();
|
|
622
819
|
}
|
|
820
|
+
/**
|
|
821
|
+
* Add an input update
|
|
822
|
+
* @param {UpdateInput} input - The input to update
|
|
823
|
+
* @protected
|
|
824
|
+
* @returns {void}
|
|
825
|
+
*/
|
|
623
826
|
updateInput(input) {
|
|
624
827
|
this.updateInputs.push(input);
|
|
625
828
|
}
|
|
829
|
+
/**
|
|
830
|
+
* Adds the fee to the output.
|
|
831
|
+
* @param amountSpent
|
|
832
|
+
* @param contractAddress
|
|
833
|
+
* @param epochChallenge
|
|
834
|
+
* @param addContractOutput
|
|
835
|
+
* @protected
|
|
836
|
+
*/
|
|
626
837
|
addFeeToOutput(amountSpent, contractAddress, epochChallenge, addContractOutput) {
|
|
627
838
|
if (addContractOutput) {
|
|
628
839
|
let amountToCA;
|
|
@@ -632,26 +843,35 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
632
843
|
else {
|
|
633
844
|
amountToCA = amountSpent;
|
|
634
845
|
}
|
|
846
|
+
// ALWAYS THE FIRST INPUT.
|
|
635
847
|
this.addOutput({
|
|
636
|
-
value:
|
|
848
|
+
value: toSatoshi(amountToCA),
|
|
637
849
|
address: contractAddress,
|
|
638
850
|
}, true);
|
|
851
|
+
// ALWAYS SECOND.
|
|
639
852
|
if (amountToCA === MINIMUM_AMOUNT_CA &&
|
|
640
853
|
amountSpent - MINIMUM_AMOUNT_CA > MINIMUM_AMOUNT_REWARD) {
|
|
641
854
|
this.addOutput({
|
|
642
|
-
value:
|
|
855
|
+
value: toSatoshi(amountSpent - amountToCA),
|
|
643
856
|
address: epochChallenge.address,
|
|
644
857
|
}, true);
|
|
645
858
|
}
|
|
646
859
|
}
|
|
647
860
|
else {
|
|
861
|
+
// When SEND_AMOUNT_TO_CA is false, always send to epochChallenge
|
|
862
|
+
// Use the maximum of amountSpent or MINIMUM_AMOUNT_REWARD
|
|
648
863
|
const amountToEpoch = amountSpent < MINIMUM_AMOUNT_REWARD ? MINIMUM_AMOUNT_REWARD : amountSpent;
|
|
649
864
|
this.addOutput({
|
|
650
|
-
value:
|
|
865
|
+
value: toSatoshi(amountToEpoch),
|
|
651
866
|
address: epochChallenge.address,
|
|
652
867
|
}, true);
|
|
653
868
|
}
|
|
654
869
|
}
|
|
870
|
+
/**
|
|
871
|
+
* Returns the witness of the tap transaction.
|
|
872
|
+
* @protected
|
|
873
|
+
* @returns {Buffer}
|
|
874
|
+
*/
|
|
655
875
|
getWitness() {
|
|
656
876
|
if (!this.tapData || !this.tapData.witness) {
|
|
657
877
|
throw new Error('Witness is required');
|
|
@@ -661,12 +881,21 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
661
881
|
}
|
|
662
882
|
return this.tapData.witness[this.tapData.witness.length - 1];
|
|
663
883
|
}
|
|
884
|
+
/**
|
|
885
|
+
* Returns the tap output.
|
|
886
|
+
* @protected
|
|
887
|
+
* @returns {Buffer}
|
|
888
|
+
*/
|
|
664
889
|
getTapOutput() {
|
|
665
890
|
if (!this.tapData || !this.tapData.output) {
|
|
666
891
|
throw new Error('Tap data is required');
|
|
667
892
|
}
|
|
668
893
|
return this.tapData.output;
|
|
669
894
|
}
|
|
895
|
+
/**
|
|
896
|
+
* Verifies that the utxos are valid.
|
|
897
|
+
* @protected
|
|
898
|
+
*/
|
|
670
899
|
verifyUTXOValidity() {
|
|
671
900
|
for (const utxo of this.utxos) {
|
|
672
901
|
if (!utxo.scriptPubKey) {
|
|
@@ -679,49 +908,14 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
679
908
|
}
|
|
680
909
|
}
|
|
681
910
|
}
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
estimatedFee = await this.estimateTransactionFees();
|
|
691
|
-
const valueLeft = BigInt(initialValue) - estimatedFee;
|
|
692
|
-
if (this.debugFees) {
|
|
693
|
-
this.log(` -> Iteration ${i + 1}: Estimated fee is ${estimatedFee} sats. Value left for change: ${valueLeft} sats.`);
|
|
694
|
-
}
|
|
695
|
-
if (valueLeft >= TransactionBuilder.MINIMUM_DUST) {
|
|
696
|
-
this.feeOutput = { ...output, value: Number(valueLeft) };
|
|
697
|
-
this.overflowFees = valueLeft;
|
|
698
|
-
}
|
|
699
|
-
else {
|
|
700
|
-
this.feeOutput = null;
|
|
701
|
-
this.overflowFees = 0n;
|
|
702
|
-
estimatedFee = await this.estimateTransactionFees();
|
|
703
|
-
if (this.debugFees) {
|
|
704
|
-
this.log(` -> Change is less than dust. Final fee without change output: ${estimatedFee} sats.`);
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
const finalValueLeft = BigInt(initialValue) - estimatedFee;
|
|
709
|
-
if (finalValueLeft < 0) {
|
|
710
|
-
throw new Error(`setFeeOutput: Insufficient funds to pay the fees. Required fee: ${estimatedFee}, Available: ${initialValue}. Total input: ${this.totalInputAmount} sat`);
|
|
711
|
-
}
|
|
712
|
-
if (finalValueLeft >= TransactionBuilder.MINIMUM_DUST) {
|
|
713
|
-
this.feeOutput = { ...output, value: Number(finalValueLeft) };
|
|
714
|
-
this.overflowFees = finalValueLeft;
|
|
715
|
-
if (this.debugFees) {
|
|
716
|
-
this.log(`setFeeOutput: Final change output set to ${finalValueLeft} sats. Final fee: ${estimatedFee} sats.`);
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
else {
|
|
720
|
-
this.warn(`Amount to send back (${finalValueLeft} sat) is less than the minimum dust (${TransactionBuilder.MINIMUM_DUST} sat), it will be consumed in fees instead.`);
|
|
721
|
-
this.feeOutput = null;
|
|
722
|
-
this.overflowFees = 0n;
|
|
723
|
-
}
|
|
724
|
-
}
|
|
911
|
+
/**
|
|
912
|
+
* Builds the transaction.
|
|
913
|
+
* @param {Psbt} transaction - The transaction to build
|
|
914
|
+
* @param checkPartialSigs
|
|
915
|
+
* @protected
|
|
916
|
+
* @returns {Promise<boolean>}
|
|
917
|
+
* @throws {Error} - If something went wrong while building the transaction
|
|
918
|
+
*/
|
|
725
919
|
async internalBuildTransaction(transaction, checkPartialSigs = false) {
|
|
726
920
|
if (transaction.data.inputs.length === 0) {
|
|
727
921
|
const inputs = this.getInputs();
|
|
@@ -746,5 +940,30 @@ export class TransactionBuilder extends TweakedTransaction {
|
|
|
746
940
|
}
|
|
747
941
|
return false;
|
|
748
942
|
}
|
|
943
|
+
createChangeOutput(amount) {
|
|
944
|
+
if (AddressVerificator.isValidP2TRAddress(this.from, this.network)) {
|
|
945
|
+
return {
|
|
946
|
+
value: toSatoshi(amount),
|
|
947
|
+
address: this.from,
|
|
948
|
+
tapInternalKey: this.internalPubKeyToXOnly(),
|
|
949
|
+
};
|
|
950
|
+
}
|
|
951
|
+
else if (AddressVerificator.isValidPublicKey(this.from, this.network)) {
|
|
952
|
+
const pubKeyScript = script.compile([
|
|
953
|
+
fromHex(this.from.replace('0x', '')),
|
|
954
|
+
opcodes.OP_CHECKSIG,
|
|
955
|
+
]);
|
|
956
|
+
return {
|
|
957
|
+
value: toSatoshi(amount),
|
|
958
|
+
script: pubKeyScript,
|
|
959
|
+
};
|
|
960
|
+
}
|
|
961
|
+
else {
|
|
962
|
+
return {
|
|
963
|
+
value: toSatoshi(amount),
|
|
964
|
+
address: this.from,
|
|
965
|
+
};
|
|
966
|
+
}
|
|
967
|
+
}
|
|
749
968
|
}
|
|
750
|
-
TransactionBuilder.
|
|
969
|
+
//# sourceMappingURL=TransactionBuilder.js.map
|