@btc-vision/transaction 1.0.97 → 1.0.100
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/.babelrc +4 -7
- package/.prettierrc.json +11 -11
- package/CONTRIBUTING.md +71 -71
- package/LICENSE.md +62 -62
- package/README.md +76 -76
- package/browser/_version.d.ts +1 -1
- package/browser/bytecode/Compressor.d.ts +0 -1
- package/browser/crypto/crypto-browser.d.ts +1 -30
- package/browser/crypto/crypto.d.ts +0 -1
- package/browser/generators/AddressGenerator.d.ts +0 -1
- package/browser/generators/Generator.d.ts +2 -3
- package/browser/generators/builders/CalldataGenerator.d.ts +0 -1
- package/browser/generators/builders/CustomGenerator.d.ts +6 -0
- package/browser/generators/builders/DeploymentGenerator.d.ts +0 -1
- package/browser/generators/builders/MultiSignGenerator.d.ts +0 -1
- package/browser/index.js +1 -1
- package/browser/keypair/EcKeyPair.d.ts +0 -1
- package/browser/keypair/Wallet.d.ts +0 -1
- package/browser/opnet.d.ts +5 -3
- package/browser/signer/TweakedSigner.d.ts +0 -1
- package/browser/transaction/TransactionFactory.d.ts +2 -0
- package/browser/transaction/browser/BrowserSignerBase.d.ts +0 -1
- package/browser/transaction/browser/extensions/UnisatSigner.d.ts +0 -1
- package/{build/transaction/builders/DeploymentTransactionV2.d.ts → browser/transaction/builders/CustomScriptTransaction.d.ts} +16 -12
- package/browser/transaction/builders/DeploymentTransaction.d.ts +0 -1
- package/browser/transaction/builders/InteractionTransaction.d.ts +0 -1
- package/browser/transaction/builders/MultiSignTransaction.d.ts +0 -1
- package/browser/transaction/builders/SharedInteractionTransaction.d.ts +0 -1
- package/browser/transaction/builders/TransactionBuilder.d.ts +0 -1
- package/browser/transaction/builders/UnwrapSegwitTransaction.d.ts +0 -1
- package/browser/transaction/builders/UnwrapTransaction.d.ts +0 -1
- package/browser/transaction/builders/WrapTransaction.d.ts +0 -1
- package/browser/transaction/enums/TransactionType.d.ts +2 -1
- package/browser/transaction/interfaces/ITransactionParameters.d.ts +0 -1
- package/browser/transaction/interfaces/Tap.d.ts +0 -1
- package/browser/transaction/shared/P2TR_MS.d.ts +0 -1
- package/browser/transaction/shared/TweakedTransaction.d.ts +0 -1
- package/browser/utils/BitcoinUtils.d.ts +0 -1
- package/browser/verification/TapscriptVerificator.d.ts +0 -1
- package/browser/wbtc/WrappedGenerationParameters.d.ts +0 -1
- package/build/_version.d.ts +1 -1
- package/build/_version.js +1 -1
- package/build/bytecode/Compressor.d.ts +0 -1
- package/build/bytecode/Compressor.js +4 -4
- package/build/crypto/crypto.d.ts +0 -1
- package/build/generators/AddressGenerator.d.ts +0 -1
- package/build/generators/Generator.d.ts +2 -3
- package/build/generators/Generator.js +3 -5
- package/build/generators/builders/CalldataGenerator.d.ts +0 -1
- package/build/generators/builders/CalldataGenerator.js +2 -0
- package/build/generators/builders/CustomGenerator.d.ts +6 -0
- package/build/generators/builders/CustomGenerator.js +16 -0
- package/build/generators/builders/DeploymentGenerator.d.ts +0 -1
- package/build/generators/builders/DeploymentGenerator.js +2 -0
- package/build/generators/builders/{MultisignGenerator.d.ts → MultiSignGenerator.d.ts} +0 -1
- package/build/generators/builders/{MultisignGenerator.js → MultiSignGenerator.js} +1 -1
- package/build/keypair/EcKeyPair.d.ts +0 -1
- package/build/keypair/EcKeyPair.js +2 -2
- package/build/keypair/Wallet.d.ts +0 -1
- package/build/keypair/Wallet.js +0 -5
- package/build/metadata/ContractBaseMetadata.js +0 -1
- package/build/metadata/contracts/wBTC.js +3 -5
- package/build/metadata/tokens.js +32 -30
- package/build/opnet.d.ts +5 -3
- package/build/opnet.js +5 -3
- package/build/signer/TweakedSigner.d.ts +0 -1
- package/build/transaction/TransactionFactory.d.ts +2 -0
- package/build/transaction/TransactionFactory.js +42 -3
- package/build/transaction/browser/BrowserSignerBase.d.ts +0 -1
- package/build/transaction/browser/extensions/UnisatSigner.d.ts +0 -1
- package/build/transaction/browser/extensions/UnisatSigner.js +1 -6
- package/build/transaction/builders/CustomScriptTransaction.d.ts +40 -0
- package/build/transaction/builders/{DeploymentTransactionV2.js → CustomScriptTransaction.js} +40 -67
- package/build/transaction/builders/DeploymentTransaction.d.ts +0 -1
- package/build/transaction/builders/DeploymentTransaction.js +25 -33
- package/build/transaction/builders/FundingTransaction.js +1 -3
- package/build/transaction/builders/InteractionTransaction.d.ts +0 -1
- package/build/transaction/builders/InteractionTransaction.js +2 -5
- package/build/transaction/builders/MultiSignTransaction.d.ts +0 -1
- package/build/transaction/builders/MultiSignTransaction.js +66 -73
- package/build/transaction/builders/SharedInteractionTransaction.d.ts +0 -1
- package/build/transaction/builders/SharedInteractionTransaction.js +20 -25
- package/build/transaction/builders/TransactionBuilder.d.ts +0 -1
- package/build/transaction/builders/TransactionBuilder.js +12 -21
- package/build/transaction/builders/UnwrapSegwitTransaction.d.ts +0 -1
- package/build/transaction/builders/UnwrapSegwitTransaction.js +4 -10
- package/build/transaction/builders/UnwrapTransaction.d.ts +0 -1
- package/build/transaction/builders/UnwrapTransaction.js +5 -11
- package/build/transaction/builders/WrapTransaction.d.ts +0 -1
- package/build/transaction/builders/WrapTransaction.js +5 -12
- package/build/transaction/enums/TransactionType.d.ts +2 -1
- package/build/transaction/enums/TransactionType.js +1 -0
- package/build/transaction/interfaces/ITransactionParameters.d.ts +0 -1
- package/build/transaction/interfaces/Tap.d.ts +0 -1
- package/build/transaction/processor/PsbtTransaction.js +3 -4
- package/build/transaction/shared/P2TR_MS.d.ts +0 -1
- package/build/transaction/shared/TweakedTransaction.d.ts +0 -1
- package/build/transaction/shared/TweakedTransaction.js +11 -16
- package/build/utils/BitcoinUtils.d.ts +0 -1
- package/build/utxo/OPNetLimitedProvider.js +2 -3
- package/build/verification/TapscriptVerificator.d.ts +0 -1
- package/build/verification/TapscriptVerificator.js +1 -1
- package/build/wbtc/UnwrapGeneration.js +0 -2
- package/build/wbtc/WrappedGenerationParameters.d.ts +0 -1
- package/build/wbtc/WrappedGenerationParameters.js +0 -6
- package/cjs/package.json +3 -0
- package/gulpfile.js +49 -133
- package/package.json +112 -113
- package/src/_version.ts +1 -1
- package/src/bytecode/Compressor.ts +27 -27
- package/src/consensus/metadata/RoswellConsensus.ts +26 -26
- package/src/crypto/crypto.ts +1 -1
- package/src/generators/Generator.ts +75 -75
- package/src/generators/builders/CalldataGenerator.ts +2 -0
- package/src/generators/builders/CustomGenerator.ts +30 -0
- package/src/generators/builders/DeploymentGenerator.ts +2 -0
- package/src/generators/builders/MultiSignGenerator.ts +73 -73
- package/src/metadata/contracts/wBTC.ts +60 -60
- package/src/metadata/tokens.ts +135 -135
- package/src/network/ChainId.ts +6 -6
- package/src/opnet.ts +82 -82
- package/src/signer/TweakedSigner.ts +56 -56
- package/src/transaction/TransactionFactory.ts +72 -14
- package/src/transaction/builders/CustomScriptTransaction.ts +337 -0
- package/src/transaction/builders/DeploymentTransaction.ts +356 -356
- package/src/transaction/builders/MultiSignTransaction.ts +659 -659
- package/src/transaction/builders/UnwrapSegwitTransaction.ts +365 -365
- package/src/transaction/builders/UnwrapTransaction.ts +507 -507
- package/src/transaction/enums/TransactionType.ts +10 -9
- package/src/transaction/processor/PsbtTransaction.ts +173 -173
- package/src/transaction/shared/P2TR_MS.ts +42 -42
- package/src/transaction/shared/TweakedTransaction.ts +539 -539
- package/src/utils/BitcoinUtils.ts +96 -96
- package/tsconfig.base.json +27 -43
- package/tsconfig.json +15 -8
- package/tsconfig.webpack.json +22 -22
- package/EPOCH.md +0 -250
- package/VAULT_TARGET_CONSOLIDATION.md +0 -111
- package/browser/network/NetworkInformation.d.ts +0 -6
- package/browser/transaction/browser/BrowserSigner.d.ts +0 -9
- package/browser/transaction/builders/TapUnwarpTransaction.d.ts +0 -40
- package/browser/transaction/builders/UnwarpTransaction.d.ts +0 -34
- package/browser/utxo/UTXOManager.d.ts +0 -7
- package/build/Utils.d.ts +0 -0
- package/build/Utils.js +0 -1
- package/build/consensus/metadata/RoswsellConsensus.d.ts +0 -2
- package/build/consensus/metadata/RoswsellConsensus.js +0 -4
- package/build/contracts/ContractMetadataManager.d.ts +0 -0
- package/build/contracts/ContractMetadataManager.js +0 -1
- package/build/generators/OPNetAddressGenerator.d.ts +0 -0
- package/build/generators/OPNetAddressGenerator.js +0 -1
- package/build/generators/builders/DeploymentGeneratorV2.d.ts +0 -13
- package/build/generators/builders/DeploymentGeneratorV2.js +0 -57
- package/build/generators/builders/UnwrapGenerator.d.ts +0 -8
- package/build/generators/builders/UnwrapGenerator.js +0 -79
- package/build/keypair/interfaces/GeneratedWallet.d.ts +0 -5
- package/build/keypair/interfaces/GeneratedWallet.js +0 -1
- package/build/metadata/CommonContracts.d.ts +0 -6
- package/build/metadata/CommonContracts.js +0 -5
- package/build/metadata/ContractMetadataManager.d.ts +0 -1
- package/build/metadata/ContractMetadataManager.js +0 -9
- package/build/metadata/contracts/ContractBase.d.ts +0 -9
- package/build/metadata/contracts/ContractBase.js +0 -13
- package/build/metadata/contracts/ContractBaseMetadata.d.ts +0 -9
- package/build/metadata/contracts/ContractBaseMetadata.js +0 -13
- package/build/metadata/contracts/ContractMetadataManager.d.ts +0 -0
- package/build/metadata/contracts/ContractMetadataManager.js +0 -1
- package/build/network/NetworkConverter.d.ts +0 -0
- package/build/network/NetworkConverter.js +0 -14
- package/build/network/NetworkInformation.d.ts +0 -6
- package/build/network/NetworkInformation.js +0 -1
- package/build/scripts/Regtest.d.ts +0 -2
- package/build/scripts/Regtest.js +0 -15
- package/build/scripts/test.d.ts +0 -1
- package/build/scripts/test.js +0 -74
- package/build/signer/Regtest.d.ts +0 -2
- package/build/signer/Regtest.js +0 -15
- package/build/tests/Regtest.d.ts +0 -3
- package/build/tests/Regtest.js +0 -29
- package/build/tests/adaptPSBT.d.ts +0 -1
- package/build/tests/adaptPSBT.js +0 -44
- package/build/tests/btc/send.d.ts +0 -1
- package/build/tests/btc/send.js +0 -35
- package/build/tests/btc/transfer.d.ts +0 -1
- package/build/tests/btc/transfer.js +0 -35
- package/build/tests/createPairReg.d.ts +0 -1
- package/build/tests/createPairReg.js +0 -73
- package/build/tests/deploy/deployMoto.d.ts +0 -4
- package/build/tests/deploy/deployMoto.js +0 -89
- package/build/tests/deploy/deployPool.d.ts +0 -1
- package/build/tests/deploy/deployPool.js +0 -5
- package/build/tests/deploy/deployStep1.d.ts +0 -1
- package/build/tests/deploy/deployStep1.js +0 -5
- package/build/tests/deploy/deployStep2.d.ts +0 -1
- package/build/tests/deploy/deployStep2.js +0 -5
- package/build/tests/deploy/deployStep3.d.ts +0 -1
- package/build/tests/deploy/deployStep3.js +0 -5
- package/build/tests/deploy.d.ts +0 -1
- package/build/tests/deploy.js +0 -41
- package/build/tests/deployMotoRegStep1.d.ts +0 -1
- package/build/tests/deployMotoRegStep1.js +0 -85
- package/build/tests/deployReg.d.ts +0 -1
- package/build/tests/deployReg.js +0 -85
- package/build/tests/factory/createPairReg.d.ts +0 -1
- package/build/tests/factory/createPairReg.js +0 -13
- package/build/tests/gen.d.ts +0 -1
- package/build/tests/gen.js +0 -19
- package/build/tests/interaction.d.ts +0 -5
- package/build/tests/interaction.js +0 -62
- package/build/tests/massWrapReg.d.ts +0 -1
- package/build/tests/massWrapReg.js +0 -105
- package/build/tests/mineReg.d.ts +0 -1
- package/build/tests/mineReg.js +0 -19
- package/build/tests/moto/airdropToken.d.ts +0 -1
- package/build/tests/moto/airdropToken.js +0 -21
- package/build/tests/moto/airdropTokens.d.ts +0 -1
- package/build/tests/moto/airdropTokens.js +0 -60
- package/build/tests/moto/allowance.d.ts +0 -1
- package/build/tests/moto/allowance.js +0 -6
- package/build/tests/moto/approve.d.ts +0 -1
- package/build/tests/moto/approve.js +0 -10
- package/build/tests/moto/approveWBTC.d.ts +0 -1
- package/build/tests/moto/approveWBTC.js +0 -12
- package/build/tests/moto/balanceOf.d.ts +0 -1
- package/build/tests/moto/balanceOf.js +0 -12
- package/build/tests/moto/transfer.d.ts +0 -1
- package/build/tests/moto/transfer.js +0 -16
- package/build/tests/motoswap/airdropToken.d.ts +0 -11
- package/build/tests/motoswap/airdropToken.js +0 -36
- package/build/tests/motoswap/deployMoto.d.ts +0 -4
- package/build/tests/motoswap/deployMoto.js +0 -89
- package/build/tests/motoswap/deployMotoRegStep1.d.ts +0 -1
- package/build/tests/motoswap/deployMotoRegStep1.js +0 -91
- package/build/tests/motoswap/deployMotoRegStep2.d.ts +0 -1
- package/build/tests/motoswap/deployMotoRegStep2.js +0 -91
- package/build/tests/motoswap/deployPool.d.ts +0 -1
- package/build/tests/motoswap/deployPool.js +0 -5
- package/build/tests/motoswap/deployStep1.d.ts +0 -1
- package/build/tests/motoswap/deployStep1.js +0 -5
- package/build/tests/motoswap/deployStep2.d.ts +0 -1
- package/build/tests/motoswap/deployStep2.js +0 -5
- package/build/tests/motoswap/deployStep3.d.ts +0 -1
- package/build/tests/motoswap/deployStep3.js +0 -5
- package/build/tests/motoswap/interaction.d.ts +0 -3
- package/build/tests/motoswap/interaction.js +0 -63
- package/build/tests/motoswap/routerAddLiquidity.d.ts +0 -11
- package/build/tests/motoswap/routerAddLiquidity.js +0 -35
- package/build/tests/motoswap-router/addLiquidity.d.ts +0 -11
- package/build/tests/motoswap-router/addLiquidity.js +0 -36
- package/build/tests/motoswap-router/deployMoto.d.ts +0 -4
- package/build/tests/motoswap-router/deployMoto.js +0 -89
- package/build/tests/motoswap-router/deployPool.d.ts +0 -1
- package/build/tests/motoswap-router/deployPool.js +0 -5
- package/build/tests/motoswap-router/deployStep1.d.ts +0 -1
- package/build/tests/motoswap-router/deployStep1.js +0 -5
- package/build/tests/motoswap-router/deployStep2.d.ts +0 -1
- package/build/tests/motoswap-router/deployStep2.js +0 -5
- package/build/tests/motoswap-router/deployStep3.d.ts +0 -1
- package/build/tests/motoswap-router/deployStep3.js +0 -5
- package/build/tests/motoswap-router/getAmountsOut.d.ts +0 -5
- package/build/tests/motoswap-router/getAmountsOut.js +0 -34
- package/build/tests/motoswap-router/routerAddLiquidity.d.ts +0 -11
- package/build/tests/motoswap-router/routerAddLiquidity.js +0 -35
- package/build/tests/motoswap-router/swap.d.ts +0 -8
- package/build/tests/motoswap-router/swap.js +0 -24
- package/build/tests/multisign.d.ts +0 -1
- package/build/tests/multisign.js +0 -47
- package/build/tests/multisign2.d.ts +0 -1
- package/build/tests/multisign2.js +0 -27
- package/build/tests/pool/DecodePoolAddress.d.ts +0 -6
- package/build/tests/pool/DecodePoolAddress.js +0 -12
- package/build/tests/pool/decodeReserves.d.ts +0 -5
- package/build/tests/pool/decodeReserves.js +0 -13
- package/build/tests/pool/reserves.d.ts +0 -1
- package/build/tests/pool/reserves.js +0 -18
- package/build/tests/shared/Utils.d.ts +0 -2
- package/build/tests/shared/Utils.js +0 -14
- package/build/tests/shared/interaction.d.ts +0 -7
- package/build/tests/shared/interaction.js +0 -85
- package/build/tests/shared/tokens.d.ts +0 -6
- package/build/tests/shared/tokens.js +0 -5
- package/build/tests/stakeReg.d.ts +0 -1
- package/build/tests/stakeReg.js +0 -73
- package/build/tests/stakedReg.d.ts +0 -1
- package/build/tests/stakedReg.js +0 -28
- package/build/tests/test.d.ts +0 -1
- package/build/tests/test.js +0 -51
- package/build/tests/test2.d.ts +0 -1
- package/build/tests/test2.js +0 -73
- package/build/tests/testReg.d.ts +0 -1
- package/build/tests/testReg.js +0 -91
- package/build/tests/tokens.d.ts +0 -6
- package/build/tests/tokens.js +0 -5
- package/build/tests/totalRewardReg.d.ts +0 -1
- package/build/tests/totalRewardReg.js +0 -28
- package/build/tests/transfer.d.ts +0 -1
- package/build/tests/transfer.js +0 -74
- package/build/tests/transferReg.d.ts +0 -1
- package/build/tests/transferReg.js +0 -74
- package/build/tests/unStakeReg.d.ts +0 -1
- package/build/tests/unStakeReg.js +0 -72
- package/build/tests/unwrapReg.d.ts +0 -1
- package/build/tests/unwrapReg.js +0 -61
- package/build/tests/unwrapReg2.d.ts +0 -1
- package/build/tests/unwrapReg2.js +0 -56
- package/build/tests/unwrapRegSegwit.d.ts +0 -1
- package/build/tests/unwrapRegSegwit.js +0 -83
- package/build/tests/wbtc/approve.d.ts +0 -1
- package/build/tests/wbtc/approve.js +0 -6
- package/build/tests/wbtc/approveWBTC.d.ts +0 -1
- package/build/tests/wbtc/approveWBTC.js +0 -12
- package/build/tests/wbtc/massWrapReg.d.ts +0 -1
- package/build/tests/wbtc/massWrapReg.js +0 -105
- package/build/tests/wbtc/transfer.d.ts +0 -1
- package/build/tests/wbtc/transfer.js +0 -16
- package/build/tests/wbtc/transferReg.d.ts +0 -1
- package/build/tests/wbtc/transferReg.js +0 -16
- package/build/tests/wbtc/unStakeReg.d.ts +0 -1
- package/build/tests/wbtc/unStakeReg.js +0 -72
- package/build/tests/wbtc/unwrapReg.d.ts +0 -1
- package/build/tests/wbtc/unwrapReg.js +0 -60
- package/build/tests/wbtc/unwrapRegSegwit.d.ts +0 -1
- package/build/tests/wbtc/unwrapRegSegwit.js +0 -83
- package/build/tests/wbtc/withdrawalRequestReg.d.ts +0 -1
- package/build/tests/wbtc/withdrawalRequestReg.js +0 -71
- package/build/tests/wbtc/wrapReg.d.ts +0 -1
- package/build/tests/wbtc/wrapReg.js +0 -65
- package/build/tests/wbtc/wrapTest.d.ts +0 -1
- package/build/tests/wbtc/wrapTest.js +0 -66
- package/build/tests/withdrawalRequestReg.d.ts +0 -1
- package/build/tests/withdrawalRequestReg.js +0 -71
- package/build/tests/wrap.d.ts +0 -1
- package/build/tests/wrap.js +0 -65
- package/build/tests/wrapReg.d.ts +0 -1
- package/build/tests/wrapReg.js +0 -68
- package/build/tests/wrapTest.d.ts +0 -1
- package/build/tests/wrapTest.js +0 -66
- package/build/tests/wrapTestg.d.ts +0 -1
- package/build/tests/wrapTestg.js +0 -66
- package/build/tests/writers/allowance.d.ts +0 -3
- package/build/tests/writers/allowance.js +0 -10
- package/build/tests/writers/approve.d.ts +0 -4
- package/build/tests/writers/approve.js +0 -11
- package/build/transaction/TransactionBuilder.d.ts +0 -60
- package/build/transaction/TransactionBuilder.js +0 -244
- package/build/transaction/browser/BrowserSigner.d.ts +0 -11
- package/build/transaction/browser/BrowserSigner.js +0 -10
- package/build/transaction/browser/extensions/Unisat.d.ts +0 -54
- package/build/transaction/browser/extensions/Unisat.js +0 -11
- package/build/transaction/builders/GenericTransaction.d.ts +0 -11
- package/build/transaction/builders/GenericTransaction.js +0 -23
- package/build/transaction/builders/TapUnwarpTransaction.d.ts +0 -37
- package/build/transaction/builders/TapUnwarpTransaction.js +0 -201
- package/build/transaction/builders/UnwarpSegwitTransaction.d.ts +0 -34
- package/build/transaction/builders/UnwarpSegwitTransaction.js +0 -184
- package/build/transaction/builders/UnwarpTransaction.d.ts +0 -35
- package/build/transaction/builders/UnwarpTransaction.js +0 -199
- package/build/transaction/interfaces/ITransactions.d.ts +0 -32
- package/build/transaction/interfaces/ITransactions.js +0 -1
- package/build/utxo/IUTXO.d.ts +0 -0
- package/build/utxo/IUTXO.js +0 -1
- package/build/utxo/OPNetUtils.d.ts +0 -7
- package/build/utxo/OPNetUtils.js +0 -47
- package/build/utxo/UTXOManager.d.ts +0 -7
- package/build/utxo/UTXOManager.js +0 -47
- package/build/wbtc/BroadcastResponse.d.ts +0 -0
- package/build/wbtc/BroadcastResponse.js +0 -1
- package/examples/Deploy.md +0 -188
- package/examples/Unwrap.md +0 -165
- package/examples/Wrap.md +0 -194
- package/tsconfig.cjs.json +0 -13
- /package/build/generators/{features.d.ts → Features.d.ts} +0 -0
- /package/build/generators/{features.js → Features.js} +0 -0
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export enum TransactionType {
|
|
2
|
-
GENERIC = 0,
|
|
3
|
-
FUNDING = 1,
|
|
4
|
-
DEPLOYMENT = 2,
|
|
5
|
-
INTERACTION = 3,
|
|
6
|
-
WBTC_WRAP = 4,
|
|
7
|
-
WBTC_UNWRAP = 5,
|
|
8
|
-
MULTI_SIG = 6,
|
|
9
|
-
|
|
1
|
+
export enum TransactionType {
|
|
2
|
+
GENERIC = 0,
|
|
3
|
+
FUNDING = 1,
|
|
4
|
+
DEPLOYMENT = 2,
|
|
5
|
+
INTERACTION = 3,
|
|
6
|
+
WBTC_WRAP = 4,
|
|
7
|
+
WBTC_UNWRAP = 5,
|
|
8
|
+
MULTI_SIG = 6,
|
|
9
|
+
CUSTOM_CODE = 7,
|
|
10
|
+
}
|
|
@@ -1,173 +1,173 @@
|
|
|
1
|
-
import { Network, Psbt, Signer, Transaction } from 'bitcoinjs-lib';
|
|
2
|
-
import { ITweakedTransactionData, TweakedTransaction } from '../shared/TweakedTransaction.js';
|
|
3
|
-
import { PsbtInputExtended, PsbtOutputExtended } from '../interfaces/Tap.js';
|
|
4
|
-
import { Address } from '@btc-vision/bsi-binary';
|
|
5
|
-
|
|
6
|
-
export interface PsbtTransactionData extends ITweakedTransactionData {
|
|
7
|
-
readonly psbt: Psbt;
|
|
8
|
-
readonly signer: Signer;
|
|
9
|
-
readonly network: Network;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface IWBTCUTXODocument {
|
|
13
|
-
readonly vault: Address;
|
|
14
|
-
readonly blockId: bigint;
|
|
15
|
-
|
|
16
|
-
readonly hash: string;
|
|
17
|
-
readonly value: bigint;
|
|
18
|
-
readonly outputIndex: number;
|
|
19
|
-
|
|
20
|
-
readonly output: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface VaultUTXOs {
|
|
24
|
-
readonly vault: Address;
|
|
25
|
-
readonly publicKeys: Address[];
|
|
26
|
-
readonly minimum: number;
|
|
27
|
-
readonly utxos: IWBTCUTXODocument[];
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export type FromBase64Params = Omit<PsbtTransactionData, 'psbt'>;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* @description PSBT Transaction processor.
|
|
34
|
-
* */
|
|
35
|
-
export class PsbtTransaction extends TweakedTransaction {
|
|
36
|
-
public readonly logColor: string = '#00ffe1';
|
|
37
|
-
|
|
38
|
-
public feesAddition: bigint = 10000n; // add 80000 satoshis to the fees
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* @description The transaction
|
|
42
|
-
* @protected
|
|
43
|
-
*/
|
|
44
|
-
protected readonly transaction: Psbt;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* @description Sign hash types
|
|
48
|
-
* @protected
|
|
49
|
-
*/
|
|
50
|
-
protected readonly sighashTypes: number[] | undefined = [];
|
|
51
|
-
|
|
52
|
-
constructor(data: PsbtTransactionData) {
|
|
53
|
-
super(data);
|
|
54
|
-
|
|
55
|
-
this.signer = data.signer;
|
|
56
|
-
this.network = data.network;
|
|
57
|
-
|
|
58
|
-
this.transaction = data.psbt;
|
|
59
|
-
|
|
60
|
-
this.ignoreSignatureError();
|
|
61
|
-
|
|
62
|
-
this.tweakSigner();
|
|
63
|
-
this.internalInit();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
public static fromBase64(data: string, params: FromBase64Params): PsbtTransaction {
|
|
67
|
-
const psbt = Psbt.fromBase64(data, {
|
|
68
|
-
network: params.network,
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
return new PsbtTransaction({
|
|
72
|
-
...params,
|
|
73
|
-
psbt,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
public static fromHex(data: string, params: FromBase64Params): PsbtTransaction {
|
|
78
|
-
const psbt = Psbt.fromHex(data, {
|
|
79
|
-
network: params.network,
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
return new PsbtTransaction({
|
|
83
|
-
...params,
|
|
84
|
-
psbt,
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
public static from(params: FromBase64Params): PsbtTransaction {
|
|
89
|
-
const psbt = new Psbt({ network: params.network });
|
|
90
|
-
|
|
91
|
-
return new PsbtTransaction({
|
|
92
|
-
...params,
|
|
93
|
-
psbt,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* @description Extract the transaction
|
|
99
|
-
*/
|
|
100
|
-
public extractTransaction(): Transaction {
|
|
101
|
-
return this.transaction.extractTransaction();
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Final tx hex string.
|
|
106
|
-
*/
|
|
107
|
-
public final(): string {
|
|
108
|
-
return this.extractTransaction().toHex();
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Get the psbt as a hex string
|
|
113
|
-
*/
|
|
114
|
-
public toHex(): string {
|
|
115
|
-
return this.transaction.toHex();
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* @description Add an input to the transaction
|
|
120
|
-
* @param input
|
|
121
|
-
*/
|
|
122
|
-
public addInput(input: PsbtInputExtended): void {
|
|
123
|
-
this.transaction.addInput(input);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* @description Add an output to the transaction
|
|
128
|
-
* @param output
|
|
129
|
-
*/
|
|
130
|
-
public addOutput(output: PsbtOutputExtended): void {
|
|
131
|
-
if (!output.value) return;
|
|
132
|
-
|
|
133
|
-
this.transaction.addOutput(output);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Attempt to finalize all inputs
|
|
138
|
-
* @returns {boolean} True if all inputs were finalized
|
|
139
|
-
*/
|
|
140
|
-
public attemptFinalizeInputs(n: number = 1): boolean {
|
|
141
|
-
try {
|
|
142
|
-
const inputs = this.transaction.data.inputs;
|
|
143
|
-
for (let i = n; i < inputs.length; i++) {
|
|
144
|
-
let input = inputs[i];
|
|
145
|
-
if (input.finalScriptWitness) {
|
|
146
|
-
this.transaction.finalizeTaprootInput(i, input.finalScriptWitness);
|
|
147
|
-
} else {
|
|
148
|
-
this.transaction.finalizeInput(i);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
return true;
|
|
153
|
-
} catch (e) {
|
|
154
|
-
this.warn((e as Error).stack);
|
|
155
|
-
return false;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
public getPSBT(): Psbt {
|
|
160
|
-
return this.transaction;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
private getTotalOutputAmount(vaults: VaultUTXOs[]): bigint {
|
|
164
|
-
let total = BigInt(0);
|
|
165
|
-
for (const vault of vaults) {
|
|
166
|
-
for (const utxo of vault.utxos) {
|
|
167
|
-
total += BigInt(utxo.value);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return total;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
1
|
+
import { Network, Psbt, Signer, Transaction } from 'bitcoinjs-lib';
|
|
2
|
+
import { ITweakedTransactionData, TweakedTransaction } from '../shared/TweakedTransaction.js';
|
|
3
|
+
import { PsbtInputExtended, PsbtOutputExtended } from '../interfaces/Tap.js';
|
|
4
|
+
import { Address } from '@btc-vision/bsi-binary';
|
|
5
|
+
|
|
6
|
+
export interface PsbtTransactionData extends ITweakedTransactionData {
|
|
7
|
+
readonly psbt: Psbt;
|
|
8
|
+
readonly signer: Signer;
|
|
9
|
+
readonly network: Network;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface IWBTCUTXODocument {
|
|
13
|
+
readonly vault: Address;
|
|
14
|
+
readonly blockId: bigint;
|
|
15
|
+
|
|
16
|
+
readonly hash: string;
|
|
17
|
+
readonly value: bigint;
|
|
18
|
+
readonly outputIndex: number;
|
|
19
|
+
|
|
20
|
+
readonly output: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface VaultUTXOs {
|
|
24
|
+
readonly vault: Address;
|
|
25
|
+
readonly publicKeys: Address[];
|
|
26
|
+
readonly minimum: number;
|
|
27
|
+
readonly utxos: IWBTCUTXODocument[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type FromBase64Params = Omit<PsbtTransactionData, 'psbt'>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @description PSBT Transaction processor.
|
|
34
|
+
* */
|
|
35
|
+
export class PsbtTransaction extends TweakedTransaction {
|
|
36
|
+
public readonly logColor: string = '#00ffe1';
|
|
37
|
+
|
|
38
|
+
public feesAddition: bigint = 10000n; // add 80000 satoshis to the fees
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @description The transaction
|
|
42
|
+
* @protected
|
|
43
|
+
*/
|
|
44
|
+
protected readonly transaction: Psbt;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @description Sign hash types
|
|
48
|
+
* @protected
|
|
49
|
+
*/
|
|
50
|
+
protected readonly sighashTypes: number[] | undefined = [];
|
|
51
|
+
|
|
52
|
+
constructor(data: PsbtTransactionData) {
|
|
53
|
+
super(data);
|
|
54
|
+
|
|
55
|
+
this.signer = data.signer;
|
|
56
|
+
this.network = data.network;
|
|
57
|
+
|
|
58
|
+
this.transaction = data.psbt;
|
|
59
|
+
|
|
60
|
+
this.ignoreSignatureError();
|
|
61
|
+
|
|
62
|
+
this.tweakSigner();
|
|
63
|
+
this.internalInit();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public static fromBase64(data: string, params: FromBase64Params): PsbtTransaction {
|
|
67
|
+
const psbt = Psbt.fromBase64(data, {
|
|
68
|
+
network: params.network,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
return new PsbtTransaction({
|
|
72
|
+
...params,
|
|
73
|
+
psbt,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public static fromHex(data: string, params: FromBase64Params): PsbtTransaction {
|
|
78
|
+
const psbt = Psbt.fromHex(data, {
|
|
79
|
+
network: params.network,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
return new PsbtTransaction({
|
|
83
|
+
...params,
|
|
84
|
+
psbt,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public static from(params: FromBase64Params): PsbtTransaction {
|
|
89
|
+
const psbt = new Psbt({ network: params.network });
|
|
90
|
+
|
|
91
|
+
return new PsbtTransaction({
|
|
92
|
+
...params,
|
|
93
|
+
psbt,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* @description Extract the transaction
|
|
99
|
+
*/
|
|
100
|
+
public extractTransaction(): Transaction {
|
|
101
|
+
return this.transaction.extractTransaction();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Final tx hex string.
|
|
106
|
+
*/
|
|
107
|
+
public final(): string {
|
|
108
|
+
return this.extractTransaction().toHex();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Get the psbt as a hex string
|
|
113
|
+
*/
|
|
114
|
+
public toHex(): string {
|
|
115
|
+
return this.transaction.toHex();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @description Add an input to the transaction
|
|
120
|
+
* @param input
|
|
121
|
+
*/
|
|
122
|
+
public addInput(input: PsbtInputExtended): void {
|
|
123
|
+
this.transaction.addInput(input);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @description Add an output to the transaction
|
|
128
|
+
* @param output
|
|
129
|
+
*/
|
|
130
|
+
public addOutput(output: PsbtOutputExtended): void {
|
|
131
|
+
if (!output.value) return;
|
|
132
|
+
|
|
133
|
+
this.transaction.addOutput(output);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Attempt to finalize all inputs
|
|
138
|
+
* @returns {boolean} True if all inputs were finalized
|
|
139
|
+
*/
|
|
140
|
+
public attemptFinalizeInputs(n: number = 1): boolean {
|
|
141
|
+
try {
|
|
142
|
+
const inputs = this.transaction.data.inputs;
|
|
143
|
+
for (let i = n; i < inputs.length; i++) {
|
|
144
|
+
let input = inputs[i];
|
|
145
|
+
if (input.finalScriptWitness) {
|
|
146
|
+
this.transaction.finalizeTaprootInput(i, input.finalScriptWitness);
|
|
147
|
+
} else {
|
|
148
|
+
this.transaction.finalizeInput(i);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return true;
|
|
153
|
+
} catch (e) {
|
|
154
|
+
this.warn((e as Error).stack);
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
public getPSBT(): Psbt {
|
|
160
|
+
return this.transaction;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
private getTotalOutputAmount(vaults: VaultUTXOs[]): bigint {
|
|
164
|
+
let total = BigInt(0);
|
|
165
|
+
for (const vault of vaults) {
|
|
166
|
+
for (const utxo of vault.utxos) {
|
|
167
|
+
total += BigInt(utxo.value);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return total;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { Network, networks } from 'bitcoinjs-lib';
|
|
2
|
-
import { Address } from '@btc-vision/bsi-binary';
|
|
3
|
-
import { EcKeyPair } from '../../keypair/EcKeyPair.js';
|
|
4
|
-
import { MultiSignParameters, MultiSignTransaction } from '../builders/MultiSignTransaction.js';
|
|
5
|
-
|
|
6
|
-
export class P2TR_MS {
|
|
7
|
-
/**
|
|
8
|
-
* Generate a multi-sig address
|
|
9
|
-
* @param {Buffer[]} pubKeys - The public keys to use
|
|
10
|
-
* @param {number} minimumSignatureRequired - The minimum number of signatures required
|
|
11
|
-
* @param {Network} network - The network to use
|
|
12
|
-
* @returns {Address} - The generated address
|
|
13
|
-
* @throws {Error} - If the address cannot be generated
|
|
14
|
-
*/
|
|
15
|
-
public static generateMultiSigAddress(
|
|
16
|
-
pubKeys: Buffer[],
|
|
17
|
-
minimumSignatureRequired: number,
|
|
18
|
-
network: Network = networks.bitcoin,
|
|
19
|
-
): Address {
|
|
20
|
-
const publicKeys: Buffer[] = EcKeyPair.verifyPubKeys(pubKeys, network);
|
|
21
|
-
if (publicKeys.length !== pubKeys.length) throw new Error(`Contains invalid public keys`);
|
|
22
|
-
|
|
23
|
-
// fake params
|
|
24
|
-
const multiSignParams: MultiSignParameters = {
|
|
25
|
-
network: network,
|
|
26
|
-
utxos: [],
|
|
27
|
-
pubkeys: pubKeys,
|
|
28
|
-
minimumSignatures: minimumSignatureRequired,
|
|
29
|
-
feeRate: 100,
|
|
30
|
-
receiver: 'a',
|
|
31
|
-
requestedAmount: 1n,
|
|
32
|
-
refundVault: 'a',
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const address = new MultiSignTransaction(multiSignParams).getScriptAddress();
|
|
36
|
-
if (!address) {
|
|
37
|
-
throw new Error('Failed to generate address');
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return address;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
1
|
+
import { Network, networks } from 'bitcoinjs-lib';
|
|
2
|
+
import { Address } from '@btc-vision/bsi-binary';
|
|
3
|
+
import { EcKeyPair } from '../../keypair/EcKeyPair.js';
|
|
4
|
+
import { MultiSignParameters, MultiSignTransaction } from '../builders/MultiSignTransaction.js';
|
|
5
|
+
|
|
6
|
+
export class P2TR_MS {
|
|
7
|
+
/**
|
|
8
|
+
* Generate a multi-sig address
|
|
9
|
+
* @param {Buffer[]} pubKeys - The public keys to use
|
|
10
|
+
* @param {number} minimumSignatureRequired - The minimum number of signatures required
|
|
11
|
+
* @param {Network} network - The network to use
|
|
12
|
+
* @returns {Address} - The generated address
|
|
13
|
+
* @throws {Error} - If the address cannot be generated
|
|
14
|
+
*/
|
|
15
|
+
public static generateMultiSigAddress(
|
|
16
|
+
pubKeys: Buffer[],
|
|
17
|
+
minimumSignatureRequired: number,
|
|
18
|
+
network: Network = networks.bitcoin,
|
|
19
|
+
): Address {
|
|
20
|
+
const publicKeys: Buffer[] = EcKeyPair.verifyPubKeys(pubKeys, network);
|
|
21
|
+
if (publicKeys.length !== pubKeys.length) throw new Error(`Contains invalid public keys`);
|
|
22
|
+
|
|
23
|
+
// fake params
|
|
24
|
+
const multiSignParams: MultiSignParameters = {
|
|
25
|
+
network: network,
|
|
26
|
+
utxos: [],
|
|
27
|
+
pubkeys: pubKeys,
|
|
28
|
+
minimumSignatures: minimumSignatureRequired,
|
|
29
|
+
feeRate: 100,
|
|
30
|
+
receiver: 'a',
|
|
31
|
+
requestedAmount: 1n,
|
|
32
|
+
refundVault: 'a',
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const address = new MultiSignTransaction(multiSignParams).getScriptAddress();
|
|
36
|
+
if (!address) {
|
|
37
|
+
throw new Error('Failed to generate address');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return address;
|
|
41
|
+
}
|
|
42
|
+
}
|