@subwallet/extension-base 1.3.41-0 → 1.3.43-0

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.
Files changed (219) hide show
  1. package/background/KoniTypes.d.ts +134 -5
  2. package/background/KoniTypes.js +18 -0
  3. package/background/errors/BitcoinProviderError.d.ts +6 -0
  4. package/background/errors/BitcoinProviderError.js +47 -0
  5. package/background/types.d.ts +1 -1
  6. package/cjs/background/KoniTypes.js +20 -1
  7. package/cjs/background/errors/BitcoinProviderError.js +54 -0
  8. package/cjs/constants/bitcoin.js +22 -0
  9. package/cjs/constants/index.js +16 -1
  10. package/cjs/core/logic-validation/recipientAddress.js +9 -0
  11. package/cjs/core/logic-validation/request.js +316 -3
  12. package/cjs/core/logic-validation/transfer.js +25 -5
  13. package/cjs/core/types.js +1 -0
  14. package/cjs/core/utils.js +15 -1
  15. package/cjs/koni/background/handlers/Extension.js +477 -93
  16. package/cjs/koni/background/handlers/State.js +249 -16
  17. package/cjs/koni/background/handlers/Tabs.js +119 -6
  18. package/cjs/packageInfo.js +1 -1
  19. package/cjs/page/bitcoin/index.js +67 -0
  20. package/cjs/page/index.js +5 -0
  21. package/cjs/services/balance-service/helpers/subscribe/bitcoin.js +94 -0
  22. package/cjs/services/balance-service/helpers/subscribe/index.js +19 -7
  23. package/cjs/services/balance-service/index.js +32 -4
  24. package/cjs/services/balance-service/transfer/bitcoin-transfer.js +119 -0
  25. package/cjs/services/balance-service/transfer/token.js +2 -0
  26. package/cjs/services/base/types.js +2 -0
  27. package/cjs/services/buy-service/index.js +17 -2
  28. package/cjs/services/chain-service/constants.js +14 -3
  29. package/cjs/services/chain-service/handler/bitcoin/BitcoinApi.js +105 -0
  30. package/cjs/services/chain-service/handler/bitcoin/BitcoinChainHandler.js +78 -0
  31. package/cjs/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/blockstream-testnet-strategy.js +371 -0
  32. package/cjs/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/index.js +19 -0
  33. package/cjs/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/mempool-testnet-strategy.js +368 -0
  34. package/cjs/services/chain-service/handler/bitcoin/strategy/SubWalletMainnet/index.js +302 -0
  35. package/cjs/services/chain-service/handler/bitcoin/strategy/types.js +1 -0
  36. package/cjs/services/chain-service/index.js +27 -3
  37. package/cjs/services/chain-service/utils/index.js +57 -4
  38. package/cjs/services/chain-service/utils/patch.js +1 -1
  39. package/cjs/services/earning-service/handlers/native-staking/para-chain.js +27 -5
  40. package/cjs/services/event-service/index.js +4 -0
  41. package/cjs/services/fee-service/service.js +8 -3
  42. package/cjs/services/hiro-service/index.js +96 -0
  43. package/cjs/services/hiro-service/utils/index.js +85 -0
  44. package/cjs/services/history-service/bitcoin-history.js +58 -0
  45. package/cjs/services/history-service/helpers/recoverHistoryStatus.js +96 -4
  46. package/cjs/services/history-service/index.js +41 -3
  47. package/cjs/services/keyring-service/context/handlers/Derive.js +1 -1
  48. package/cjs/services/keyring-service/context/handlers/Migration.js +2 -2
  49. package/cjs/services/keyring-service/context/handlers/Mnemonic.js +4 -3
  50. package/cjs/services/migration-service/scripts/MigrateNewUnifiedAccount.js +29 -0
  51. package/cjs/services/migration-service/scripts/index.js +3 -1
  52. package/cjs/services/request-service/handler/AuthRequestHandler.js +18 -0
  53. package/cjs/services/request-service/handler/BitcoinRequestHandler.js +427 -0
  54. package/cjs/services/request-service/index.js +29 -3
  55. package/cjs/services/rune-service/index.js +105 -0
  56. package/cjs/services/transaction-service/helpers/index.js +7 -1
  57. package/cjs/services/transaction-service/index.js +206 -16
  58. package/cjs/services/transaction-service/utils.js +6 -3
  59. package/cjs/strategy/api-request-strategy/context/base.js +31 -0
  60. package/cjs/strategy/api-request-strategy/index.js +90 -0
  61. package/cjs/strategy/api-request-strategy/types.js +1 -0
  62. package/cjs/strategy/api-request-strategy/utils/index.js +33 -0
  63. package/cjs/types/account/info/keyring.js +1 -1
  64. package/cjs/types/bitcoin.js +24 -0
  65. package/cjs/types/fee/bitcoin.js +1 -0
  66. package/cjs/types/fee/index.js +11 -0
  67. package/cjs/types/index.js +11 -0
  68. package/cjs/utils/account/analyze.js +3 -3
  69. package/cjs/utils/account/common.js +16 -6
  70. package/cjs/utils/account/derive/info/solo.js +68 -19
  71. package/cjs/utils/account/derive/info/unified.js +2 -0
  72. package/cjs/utils/account/derive/validate.js +70 -2
  73. package/cjs/utils/account/transform.js +11 -5
  74. package/cjs/utils/auth.js +2 -1
  75. package/cjs/utils/bitcoin/common.js +98 -0
  76. package/cjs/utils/bitcoin/fee.js +21 -0
  77. package/cjs/utils/bitcoin/index.js +38 -0
  78. package/cjs/utils/bitcoin/utxo-management.js +281 -0
  79. package/cjs/utils/fee/transfer.js +48 -0
  80. package/cjs/utils/index.js +15 -1
  81. package/constants/bitcoin.d.ts +3 -0
  82. package/constants/bitcoin.js +13 -0
  83. package/constants/index.d.ts +2 -0
  84. package/constants/index.js +3 -1
  85. package/core/logic-validation/recipientAddress.js +10 -1
  86. package/core/logic-validation/request.d.ts +6 -2
  87. package/core/logic-validation/request.js +309 -3
  88. package/core/logic-validation/transfer.d.ts +2 -2
  89. package/core/logic-validation/transfer.js +27 -7
  90. package/core/types.d.ts +1 -0
  91. package/core/types.js +1 -0
  92. package/core/utils.d.ts +1 -0
  93. package/core/utils.js +15 -2
  94. package/koni/background/handlers/Extension.d.ts +5 -0
  95. package/koni/background/handlers/Extension.js +387 -9
  96. package/koni/background/handlers/State.d.ts +10 -3
  97. package/koni/background/handlers/State.js +240 -15
  98. package/koni/background/handlers/Tabs.d.ts +7 -2
  99. package/koni/background/handlers/Tabs.js +119 -9
  100. package/package.json +149 -8
  101. package/packageInfo.js +1 -1
  102. package/page/bitcoin/index.d.ts +17 -0
  103. package/page/bitcoin/index.js +60 -0
  104. package/page/index.d.ts +2 -1
  105. package/page/index.js +4 -0
  106. package/services/balance-service/helpers/subscribe/bitcoin.d.ts +2 -0
  107. package/services/balance-service/helpers/subscribe/bitcoin.js +87 -0
  108. package/services/balance-service/helpers/subscribe/index.d.ts +2 -2
  109. package/services/balance-service/helpers/subscribe/index.js +20 -8
  110. package/services/balance-service/index.d.ts +2 -0
  111. package/services/balance-service/index.js +32 -4
  112. package/services/balance-service/transfer/bitcoin-transfer.d.ts +14 -0
  113. package/services/balance-service/transfer/bitcoin-transfer.js +112 -0
  114. package/services/balance-service/transfer/cardano-transfer.d.ts +2 -0
  115. package/services/balance-service/transfer/token.js +2 -0
  116. package/services/base/types.d.ts +2 -0
  117. package/services/base/types.js +2 -0
  118. package/services/buy-service/index.js +17 -2
  119. package/services/chain-service/constants.d.ts +6 -0
  120. package/services/chain-service/constants.js +8 -2
  121. package/services/chain-service/handler/bitcoin/BitcoinApi.d.ts +31 -0
  122. package/services/chain-service/handler/bitcoin/BitcoinApi.js +98 -0
  123. package/services/chain-service/handler/bitcoin/BitcoinChainHandler.d.ts +16 -0
  124. package/services/chain-service/handler/bitcoin/BitcoinChainHandler.js +70 -0
  125. package/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/blockstream-testnet-strategy.d.ts +28 -0
  126. package/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/blockstream-testnet-strategy.js +362 -0
  127. package/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/index.d.ts +2 -0
  128. package/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/index.js +5 -0
  129. package/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/mempool-testnet-strategy.d.ts +28 -0
  130. package/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/mempool-testnet-strategy.js +359 -0
  131. package/services/chain-service/handler/bitcoin/strategy/SubWalletMainnet/index.d.ts +28 -0
  132. package/services/chain-service/handler/bitcoin/strategy/SubWalletMainnet/index.js +293 -0
  133. package/services/chain-service/handler/bitcoin/strategy/types.d.ts +291 -0
  134. package/services/chain-service/handler/bitcoin/strategy/types.js +1 -0
  135. package/services/chain-service/index.d.ts +3 -0
  136. package/services/chain-service/index.js +31 -5
  137. package/services/chain-service/types.d.ts +20 -0
  138. package/services/chain-service/utils/index.d.ts +4 -0
  139. package/services/chain-service/utils/index.js +50 -4
  140. package/services/chain-service/utils/patch.js +1 -1
  141. package/services/earning-service/handlers/native-staking/para-chain.js +27 -5
  142. package/services/event-service/index.d.ts +3 -0
  143. package/services/event-service/index.js +4 -0
  144. package/services/event-service/types.d.ts +3 -0
  145. package/services/fee-service/service.js +8 -3
  146. package/services/hiro-service/index.d.ts +17 -0
  147. package/services/hiro-service/index.js +88 -0
  148. package/services/hiro-service/utils/index.d.ts +6 -0
  149. package/services/hiro-service/utils/index.js +72 -0
  150. package/services/history-service/bitcoin-history.d.ts +4 -0
  151. package/services/history-service/bitcoin-history.js +52 -0
  152. package/services/history-service/helpers/recoverHistoryStatus.d.ts +3 -1
  153. package/services/history-service/helpers/recoverHistoryStatus.js +96 -4
  154. package/services/history-service/index.d.ts +1 -0
  155. package/services/history-service/index.js +42 -4
  156. package/services/keyring-service/context/handlers/Derive.js +2 -2
  157. package/services/keyring-service/context/handlers/Migration.js +2 -2
  158. package/services/keyring-service/context/handlers/Mnemonic.js +4 -3
  159. package/services/migration-service/scripts/MigrateNewUnifiedAccount.d.ts +4 -0
  160. package/services/migration-service/scripts/MigrateNewUnifiedAccount.js +21 -0
  161. package/services/migration-service/scripts/index.js +3 -1
  162. package/services/request-service/handler/AuthRequestHandler.js +19 -1
  163. package/services/request-service/handler/BitcoinRequestHandler.d.ts +22 -0
  164. package/services/request-service/handler/BitcoinRequestHandler.js +414 -0
  165. package/services/request-service/index.d.ts +8 -2
  166. package/services/request-service/index.js +25 -3
  167. package/services/rune-service/index.d.ts +17 -0
  168. package/services/rune-service/index.js +97 -0
  169. package/services/transaction-service/helpers/index.d.ts +3 -1
  170. package/services/transaction-service/helpers/index.js +5 -0
  171. package/services/transaction-service/index.d.ts +4 -5
  172. package/services/transaction-service/index.js +205 -17
  173. package/services/transaction-service/types.d.ts +13 -2
  174. package/services/transaction-service/utils.js +7 -4
  175. package/strategy/api-request-strategy/context/base.d.ts +15 -0
  176. package/strategy/api-request-strategy/context/base.js +24 -0
  177. package/strategy/api-request-strategy/index.d.ts +15 -0
  178. package/strategy/api-request-strategy/index.js +83 -0
  179. package/strategy/api-request-strategy/types.d.ts +22 -0
  180. package/strategy/api-request-strategy/types.js +1 -0
  181. package/strategy/api-request-strategy/utils/index.d.ts +2 -0
  182. package/strategy/api-request-strategy/utils/index.js +23 -0
  183. package/types/account/info/keyring.d.ts +1 -1
  184. package/types/account/info/keyring.js +1 -1
  185. package/types/balance/index.d.ts +4 -1
  186. package/types/balance/transfer.d.ts +19 -0
  187. package/types/bitcoin.d.ts +93 -0
  188. package/types/bitcoin.js +17 -0
  189. package/types/buy.d.ts +1 -1
  190. package/types/fee/base.d.ts +4 -1
  191. package/types/fee/bitcoin.d.ts +18 -0
  192. package/types/fee/bitcoin.js +1 -0
  193. package/types/fee/index.d.ts +1 -0
  194. package/types/fee/index.js +2 -1
  195. package/types/fee/subscription.d.ts +4 -3
  196. package/types/index.d.ts +1 -0
  197. package/types/index.js +1 -0
  198. package/utils/account/analyze.js +4 -4
  199. package/utils/account/common.d.ts +7 -8
  200. package/utils/account/common.js +16 -6
  201. package/utils/account/derive/info/solo.js +70 -21
  202. package/utils/account/derive/info/unified.js +2 -0
  203. package/utils/account/derive/validate.d.ts +1 -0
  204. package/utils/account/derive/validate.js +68 -1
  205. package/utils/account/transform.d.ts +1 -1
  206. package/utils/account/transform.js +11 -5
  207. package/utils/auth.js +3 -2
  208. package/utils/bitcoin/common.d.ts +22 -0
  209. package/utils/bitcoin/common.js +88 -0
  210. package/utils/bitcoin/fee.d.ts +2 -0
  211. package/utils/bitcoin/fee.js +14 -0
  212. package/utils/bitcoin/index.d.ts +3 -0
  213. package/utils/bitcoin/index.js +6 -0
  214. package/utils/bitcoin/utxo-management.d.ts +33 -0
  215. package/utils/bitcoin/utxo-management.js +266 -0
  216. package/utils/fee/transfer.d.ts +3 -1
  217. package/utils/fee/transfer.js +47 -1
  218. package/utils/index.d.ts +1 -0
  219. package/utils/index.js +6 -3
@@ -8,7 +8,7 @@ import { TransactionError } from '@subwallet/extension-base/background/errors/Tr
8
8
  import { withErrorLog } from '@subwallet/extension-base/background/handlers/helpers';
9
9
  import { createSubscription } from '@subwallet/extension-base/background/handlers/subscriptions';
10
10
  import { CampaignDataType, ChainType, ExternalRequestPromiseStatus, ExtrinsicType, MantaPayEnableMessage, StakingType } from '@subwallet/extension-base/background/KoniTypes';
11
- import { _SUPPORT_TOKEN_PAY_FEE_GROUP, ALL_ACCOUNT_KEY, LATEST_SESSION } from '@subwallet/extension-base/constants';
11
+ import { _SUPPORT_TOKEN_PAY_FEE_GROUP, ALL_ACCOUNT_KEY, BTC_DUST_AMOUNT, LATEST_SESSION } from '@subwallet/extension-base/constants';
12
12
  import { additionalValidateTransferForRecipient, validateTransferRequest, validateXcmMinAmountToMythos, validateXcmTransferRequest } from '@subwallet/extension-base/core/logic-validation/transfer';
13
13
  import { _isSnowBridgeXcm } from '@subwallet/extension-base/core/substrate/xcm-parser';
14
14
  import { _isSufficientToken } from '@subwallet/extension-base/core/utils';
@@ -25,6 +25,7 @@ import { getPoolingBondingExtrinsic, getPoolingUnbondingExtrinsic, validatePoolB
25
25
  import { YIELD_EXTRINSIC_TYPES } from '@subwallet/extension-base/koni/api/yield/helper/utils';
26
26
  import { DEFAULT_CARDANO_TTL_OFFSET } from '@subwallet/extension-base/services/balance-service/helpers/subscribe/cardano/consts';
27
27
  import { isBounceableAddress } from '@subwallet/extension-base/services/balance-service/helpers/subscribe/ton/utils';
28
+ import { createBitcoinTransaction } from '@subwallet/extension-base/services/balance-service/transfer/bitcoin-transfer';
28
29
  import { createCardanoTransaction } from '@subwallet/extension-base/services/balance-service/transfer/cardano-transfer';
29
30
  import { getERC20TransactionObject, getERC721Transaction, getEVMTransactionObject, getPSP34TransferExtrinsic } from '@subwallet/extension-base/services/balance-service/transfer/smart-contract';
30
31
  import { createSubstrateExtrinsic } from '@subwallet/extension-base/services/balance-service/transfer/token';
@@ -37,7 +38,7 @@ import { _isPosChainBridge, getClaimPosBridge } from '@subwallet/extension-base/
37
38
  import { estimateXcmFee } from '@subwallet/extension-base/services/balance-service/transfer/xcm/utils';
38
39
  import { _DEFAULT_MANTA_ZK_CHAIN, _MANTA_ZK_CHAIN_GROUP, _ZK_ASSET_PREFIX } from '@subwallet/extension-base/services/chain-service/constants';
39
40
  import { _ChainConnectionStatus } from '@subwallet/extension-base/services/chain-service/types';
40
- import { _getAssetDecimals, _getAssetSymbol, _getChainNativeTokenBasicInfo, _getContractAddressOfToken, _getEvmChainId, _isAssetSmartContractNft, _isChainEnabled, _isChainEvmCompatible, _isChainSubstrateCompatible, _isCustomAsset, _isLocalToken, _isMantaZkAsset, _isNativeToken, _isNativeTokenBySlug, _isPureEvmChain, _isTokenEvmSmartContract, _isTokenTransferredByCardano, _isTokenTransferredByEvm, _isTokenTransferredByTon } from '@subwallet/extension-base/services/chain-service/utils';
41
+ import { _getAssetDecimals, _getAssetSymbol, _getChainNativeTokenBasicInfo, _getContractAddressOfToken, _getEvmChainId, _isAssetSmartContractNft, _isChainBitcoinCompatible, _isChainEnabled, _isChainEvmCompatible, _isChainSubstrateCompatible, _isCustomAsset, _isLocalToken, _isMantaZkAsset, _isNativeToken, _isNativeTokenBySlug, _isPureEvmChain, _isTokenEvmSmartContract, _isTokenTransferredByBitcoin, _isTokenTransferredByCardano, _isTokenTransferredByEvm, _isTokenTransferredByTon } from '@subwallet/extension-base/services/chain-service/utils';
41
42
  import { calculateToAmountByReservePool } from '@subwallet/extension-base/services/fee-service/utils';
42
43
  import { batchExtrinsicSetFeeHydration, getAssetHubTokensCanPayFee, getHydrationTokensCanPayFee } from '@subwallet/extension-base/services/fee-service/utils/tokenPayFee';
43
44
  import { EXTENSION_REQUEST_URL } from '@subwallet/extension-base/services/request-service/constants';
@@ -46,14 +47,17 @@ import { isProposalExpired, isSupportWalletConnectChain, isSupportWalletConnectN
46
47
  import { SWStorage } from '@subwallet/extension-base/storage';
47
48
  import { AccountsStore } from '@subwallet/extension-base/stores';
48
49
  import { AccountSignMode, BasicTxErrorType, BasicTxWarningCode, CommonStepType, EarningProcessType, ProcessType, StakingTxErrorType, StepStatus, SwapFeeType, YieldPoolType, YieldStepType } from '@subwallet/extension-base/types';
49
- import { _analyzeAddress, calculateMaxTransferable, combineAllAccountProxy, createPromiseHandler, createTransactionFromRLP, detectTransferTxType, getAccountSignMode, isSameAddress, MODULE_SUPPORT, reformatAddress, signatureToHex, transformAccounts, transformAddresses, uniqueStringArray } from '@subwallet/extension-base/utils';
50
+ import { _analyzeAddress, calculateMaxTransferable, combineAllAccountProxy, combineBitcoinFee, createPromiseHandler, createTransactionFromRLP, detectTransferTxType, filterUneconomicalUtxos, getAccountSignMode, getSizeInfo, getTransferableBitcoinUtxos, isSameAddress, MODULE_SUPPORT, reformatAddress, signatureToHex, transformAccounts, transformAddresses, uniqueStringArray } from '@subwallet/extension-base/utils';
50
51
  import { parseContractInput, parseEvmRlp } from '@subwallet/extension-base/utils/eth/parseTransaction';
51
52
  import { getId } from '@subwallet/extension-base/utils/getId';
52
53
  import { getKeypairTypeByAddress, isAddress, isCardanoAddress, isSubstrateAddress, isTonAddress } from '@subwallet/keyring';
53
- import { CardanoKeypairTypes, EthereumKeypairTypes, SubstrateKeypairTypes, TonKeypairTypes } from '@subwallet/keyring/types';
54
+ import { BitcoinKeypairTypes, CardanoKeypairTypes, EthereumKeypairTypes, SubstrateKeypairTypes, TonKeypairTypes } from '@subwallet/keyring/types';
55
+ import { getBitcoinAddressInfo } from '@subwallet/keyring/utils';
56
+ import { isBitcoinAddress } from '@subwallet/keyring/utils/address/validate';
54
57
  import { keyring } from '@subwallet/ui-keyring';
55
58
  import { getSdkError } from '@walletconnect/utils';
56
59
  import BigN from 'bignumber.js';
60
+ import * as bitcoin from 'bitcoinjs-lib';
57
61
  import { t } from 'i18next';
58
62
  import { combineLatest, Subject } from 'rxjs';
59
63
  import { TypeRegistry } from '@polkadot/types';
@@ -563,7 +567,8 @@ export default class KoniExtension {
563
567
  evm: EthereumKeypairTypes,
564
568
  substrate: SubstrateKeypairTypes,
565
569
  ton: TonKeypairTypes,
566
- cardano: CardanoKeypairTypes
570
+ cardano: CardanoKeypairTypes,
571
+ bitcoin: BitcoinKeypairTypes
567
572
  };
568
573
  return !!accountAuthTypes && accountAuthTypes.some(authType => {
569
574
  var _validTypes$authType;
@@ -665,7 +670,8 @@ export default class KoniExtension {
665
670
  substrate: 'substrateInfo',
666
671
  evm: 'evmInfo',
667
672
  cardano: 'cardanoInfo',
668
- ton: 'tonInfo'
673
+ ton: 'tonInfo',
674
+ bitcoin: 'bitcoinInfo'
669
675
  };
670
676
  const typeInfoKey = typeInfoMap[authSwitchNetworkType];
671
677
  if (!typeInfoKey || !chainInfo[typeInfoKey]) {
@@ -1244,6 +1250,7 @@ export default class KoniExtension {
1244
1250
  decimals: _getAssetDecimals(transferTokenInfo)
1245
1251
  };
1246
1252
  let transaction;
1253
+ let overrideFeeCustom;
1247
1254
  const transferTokenAvailable = await this.getAddressTransferableBalance({
1248
1255
  address: from,
1249
1256
  networkKey: chain,
@@ -1315,6 +1322,39 @@ export default class KoniExtension {
1315
1322
  cardanoApi,
1316
1323
  nativeTokenInfo
1317
1324
  });
1325
+ } else if (isBitcoinAddress(from) && isBitcoinAddress(to) && _isTokenTransferredByBitcoin(transferTokenInfo)) {
1326
+ // Note: Currently supports transferring only the native token, Bitcoin.
1327
+ chainType = ChainType.BITCOIN;
1328
+ const chainInfo = this.#koniState.getChainInfo(chain);
1329
+ const network = chainInfo.isTestnet ? bitcoin.networks.testnet : bitcoin.networks.bitcoin;
1330
+ const txVal = transferAll ? transferTokenAvailable.value : value || '0';
1331
+ const bitcoinApi = this.#koniState.getBitcoinApi(chain);
1332
+ const feeInfo = await this.#koniState.feeService.subscribeChainFee(getId(), chain, 'bitcoin');
1333
+ let calculatedBitcoinFeeRate;
1334
+ [transaction, transferAmount.value, calculatedBitcoinFeeRate] = await createBitcoinTransaction({
1335
+ bitcoinApi,
1336
+ chain,
1337
+ from,
1338
+ feeInfo,
1339
+ to,
1340
+ transferAll: !!transferAll,
1341
+ value: txVal,
1342
+ network: network
1343
+ });
1344
+ if (calculatedBitcoinFeeRate) {
1345
+ const feeRate = parseFloat(calculatedBitcoinFeeRate);
1346
+ if (!isNaN(feeRate)) {
1347
+ overrideFeeCustom = {
1348
+ feeRate
1349
+ };
1350
+ }
1351
+ }
1352
+
1353
+ // TODO: This is a hotfix until transferMax for Bitcoin is supported.
1354
+ if (transferAll) {
1355
+ inputData.value = transferAmount.value;
1356
+ }
1357
+ console.log('PSPT transaction', transaction.toHex());
1318
1358
  } else {
1319
1359
  const substrateApi = this.#koniState.getSubstrateApi(chain);
1320
1360
  [transaction, transferAmount.value] = await createSubstrateExtrinsic({
@@ -1405,8 +1445,8 @@ export default class KoniExtension {
1405
1445
  warnings,
1406
1446
  address: from,
1407
1447
  chain,
1408
- feeCustom,
1409
- feeOption,
1448
+ feeCustom: overrideFeeCustom || feeCustom,
1449
+ feeOption: overrideFeeCustom ? 'custom' : feeOption,
1410
1450
  tokenPayFeeSlug,
1411
1451
  chainType,
1412
1452
  transferNativeAmount,
@@ -1626,6 +1666,190 @@ export default class KoniExtension {
1626
1666
  eventsHandler: eventsHandler
1627
1667
  });
1628
1668
  }
1669
+ async makeBitcoinDappTransferConfirmation(inputData) {
1670
+ const {
1671
+ chain,
1672
+ feeCustom,
1673
+ feeOption,
1674
+ from,
1675
+ id,
1676
+ to,
1677
+ tokenSlug,
1678
+ transferAll,
1679
+ value
1680
+ } = inputData;
1681
+ const transferTokenInfo = this.#koniState.chainService.getAssetBySlug(tokenSlug);
1682
+ const errors = validateTransferRequest(transferTokenInfo, from, to, value, transferAll);
1683
+ const warnings = [];
1684
+ const chainInfo = this.#koniState.getChainInfo(chain);
1685
+ const nativeTokenInfo = this.#koniState.getNativeTokenInfo(chain);
1686
+ const nativeTokenSlug = nativeTokenInfo.slug;
1687
+ const isTransferNativeToken = nativeTokenSlug === tokenSlug;
1688
+ let chainType = ChainType.BITCOIN;
1689
+ const tokenBaseAmount = {
1690
+ value: '0',
1691
+ symbol: transferTokenInfo.symbol,
1692
+ decimals: transferTokenInfo.decimals || 0
1693
+ };
1694
+ const transferAmount = {
1695
+ ...tokenBaseAmount
1696
+ };
1697
+ let transaction;
1698
+ let overrideFeeCustom;
1699
+ let calculatedBitcoinFeeRate;
1700
+
1701
+ // Get native token amount
1702
+ const freeBalance = await this.getAddressTransferableBalance({
1703
+ address: from,
1704
+ networkKey: chain,
1705
+ token: tokenSlug
1706
+ });
1707
+ const txVal = transferAll ? freeBalance.value : value || '0';
1708
+ try {
1709
+ if (_isChainBitcoinCompatible(chainInfo)) {
1710
+ chainType = ChainType.BITCOIN;
1711
+ const bitcoinApi = this.#koniState.getBitcoinApi(chain); // Get Bitcoin API map
1712
+ const network = chainInfo.isTestnet ? bitcoin.networks.testnet : bitcoin.networks.bitcoin;
1713
+ const feeInfo = await this.#koniState.feeService.subscribeChainFee(getId(), chain, 'bitcoin');
1714
+ [transaction, transferAmount.value, calculatedBitcoinFeeRate] = await createBitcoinTransaction({
1715
+ bitcoinApi,
1716
+ chain,
1717
+ from,
1718
+ feeInfo,
1719
+ to,
1720
+ transferAll: transferAll,
1721
+ value: txVal,
1722
+ network: network
1723
+ });
1724
+ if (calculatedBitcoinFeeRate) {
1725
+ const feeRate = parseFloat(calculatedBitcoinFeeRate);
1726
+ if (!isNaN(feeRate)) {
1727
+ overrideFeeCustom = {
1728
+ feeRate
1729
+ };
1730
+ }
1731
+ }
1732
+ }
1733
+ } catch (e) {
1734
+ const error = e;
1735
+ if (error.message.includes('transfer amount exceeds balance')) {
1736
+ error.message = t('Insufficient balance');
1737
+ }
1738
+ throw error;
1739
+ }
1740
+ const transferNativeAmount = isTransferNativeToken ? transferAmount.value : '0';
1741
+ return this.#koniState.transactionService.handleTransactionAfterConfirmation({
1742
+ id,
1743
+ errors,
1744
+ warnings,
1745
+ address: from,
1746
+ chain: chain,
1747
+ feeCustom: overrideFeeCustom || feeCustom,
1748
+ feeOption: overrideFeeCustom ? 'custom' : feeOption,
1749
+ chainType,
1750
+ transferNativeAmount,
1751
+ transaction,
1752
+ data: inputData,
1753
+ extrinsicType: isTransferNativeToken ? ExtrinsicType.TRANSFER_BALANCE : ExtrinsicType.TRANSFER_TOKEN,
1754
+ ignoreWarnings: [],
1755
+ isTransferAll: isTransferNativeToken ? transferAll : false,
1756
+ edAsWarning: isTransferNativeToken
1757
+ });
1758
+ }
1759
+ async makePsbtTransferAfterConfirmation(inputData_) {
1760
+ var _txOutput$;
1761
+ const {
1762
+ chain,
1763
+ from,
1764
+ id,
1765
+ psbt,
1766
+ tokenSlug,
1767
+ txInput,
1768
+ txOutput,
1769
+ value
1770
+ } = inputData_;
1771
+ let inputAmount = new BigN(0);
1772
+ const transferTokenInfo = this.#koniState.chainService.getAssetBySlug(tokenSlug);
1773
+ const totalUtxoInput = txInput.reduce((total, {
1774
+ address,
1775
+ amount
1776
+ }) => {
1777
+ if (!address || !amount) {
1778
+ return total;
1779
+ }
1780
+ if (isSameAddress(address, from)) {
1781
+ inputAmount = new BigN(amount);
1782
+ }
1783
+ return total.plus(new BigN(amount || 0));
1784
+ }, new BigN(0));
1785
+ const totalUtxoOutput = txOutput.reduce((total, {
1786
+ address,
1787
+ amount
1788
+ }) => {
1789
+ if (!address || !amount) {
1790
+ return total;
1791
+ }
1792
+ return total.plus(new BigN(amount));
1793
+ }, new BigN(0));
1794
+ const estimateFeeValue = totalUtxoInput.minus(totalUtxoOutput).toString();
1795
+ const errors = validateTransferRequest(transferTokenInfo, from, ((_txOutput$ = txOutput[0]) === null || _txOutput$ === void 0 ? void 0 : _txOutput$.address) || '', value, false);
1796
+ const warnings = [];
1797
+ const chainInfo = this.#koniState.getChainInfo(chain);
1798
+ const {
1799
+ decimals,
1800
+ symbol
1801
+ } = _getChainNativeTokenBasicInfo(chainInfo);
1802
+ const estimateFee = {
1803
+ symbol,
1804
+ decimals,
1805
+ value: estimateFeeValue,
1806
+ tooHigh: false
1807
+ };
1808
+ const nativeTokenInfo = this.#koniState.getNativeTokenInfo(chain);
1809
+ const nativeTokenSlug = nativeTokenInfo.slug;
1810
+ const isTransferNativeToken = nativeTokenSlug === tokenSlug;
1811
+ const chainType = ChainType.BITCOIN;
1812
+ const bitcoinNetwork = chainInfo.isTestnet ? bitcoin.networks.testnet : bitcoin.networks.bitcoin;
1813
+ const psbtGenerate = bitcoin.Psbt.fromHex(psbt, {
1814
+ network: bitcoinNetwork
1815
+ });
1816
+ const tokenBaseAmount = {
1817
+ value: inputData_.value,
1818
+ symbol: transferTokenInfo.symbol,
1819
+ decimals: transferTokenInfo.decimals || 0
1820
+ };
1821
+ const transferAmount = {
1822
+ ...tokenBaseAmount
1823
+ };
1824
+
1825
+ // Get native token amount
1826
+ const freeBalance = await this.getAddressTransferableBalance({
1827
+ address: from,
1828
+ networkKey: chain,
1829
+ token: tokenSlug
1830
+ });
1831
+ if (new BigN(freeBalance.value).lt(inputAmount)) {
1832
+ throw new Error(t('Insufficient balance'));
1833
+ }
1834
+ const transferNativeAmount = isTransferNativeToken ? transferAmount.value : '0';
1835
+ return this.#koniState.transactionService.handleTransactionAfterConfirmation({
1836
+ id,
1837
+ errors,
1838
+ warnings,
1839
+ address: from,
1840
+ chain: chain,
1841
+ estimateFee,
1842
+ chainType,
1843
+ transferNativeAmount,
1844
+ transaction: psbtGenerate,
1845
+ data: inputData_,
1846
+ extrinsicType: isTransferNativeToken ? ExtrinsicType.TRANSFER_BALANCE : ExtrinsicType.TRANSFER_TOKEN,
1847
+ ignoreWarnings: [],
1848
+ isTransferAll: false,
1849
+ edAsWarning: isTransferNativeToken,
1850
+ skipFeeRecalculation: true
1851
+ });
1852
+ }
1629
1853
  async getTokensCanPayFee(request) {
1630
1854
  var _tokensHasBalanceInfo;
1631
1855
  const {
@@ -1864,6 +2088,7 @@ export default class KoniExtension {
1864
2088
  destChain: _destChain,
1865
2089
  feeCustom,
1866
2090
  feeOption,
2091
+ to,
1867
2092
  token,
1868
2093
  tokenPayFeeSlug,
1869
2094
  value
@@ -1886,6 +2111,7 @@ export default class KoniExtension {
1886
2111
  }
1887
2112
  const _request = {
1888
2113
  address: address,
2114
+ to: to,
1889
2115
  value,
1890
2116
  // todo: lazy subscribe to improve performance
1891
2117
  cardanoApi: this.#koniState.chainService.getCardanoApi(chain),
@@ -1898,6 +2124,7 @@ export default class KoniExtension {
1898
2124
  srcToken,
1899
2125
  substrateApi: this.#koniState.chainService.getSubstrateApi(chain),
1900
2126
  tonApi: this.#koniState.chainService.getTonApi(chain),
2127
+ bitcoinApi: this.#koniState.chainService.getBitcoinApi(chain),
1901
2128
  isTransferLocalTokenAndPayThatTokenAsFee,
1902
2129
  isTransferNativeTokenAndPayLocalTokenAsFee,
1903
2130
  nativeToken
@@ -1943,6 +2170,135 @@ export default class KoniExtension {
1943
2170
  });
1944
2171
  return calculateMaxTransferable(id, _request, freeBalance, fee);
1945
2172
  }
2173
+ async subscribeTransferableWhenConfirmation({
2174
+ address,
2175
+ chain,
2176
+ feeCustom,
2177
+ feeOption: _feeOptions,
2178
+ to,
2179
+ token,
2180
+ value
2181
+ }, id, port) {
2182
+ const cb = createSubscription(id, port);
2183
+ const freeBalanceSubject = new Subject();
2184
+ const feeSubject = new Subject();
2185
+ const feeType = 'bitcoin';
2186
+ let error;
2187
+ const convertData = async (freeBalance, fee, feeOption, feeCustom) => {
2188
+ let estimatedFee = '0';
2189
+ let feeOptions = null;
2190
+ const amount = parseInt(value || '0');
2191
+ const neededUtxos = [];
2192
+ let sum = new BigN(0);
2193
+ let sizeInfo = null;
2194
+ try {
2195
+ const _fee = fee;
2196
+ const _feeCustom = feeCustom;
2197
+ const combineFee = combineBitcoinFee(_fee, _feeOptions, _feeCustom);
2198
+ const bitcoinApi = this.#koniState.chainService.getBitcoinApi(chain);
2199
+ let utxos = await getTransferableBitcoinUtxos(bitcoinApi, address);
2200
+ const recipients = [address, to || address];
2201
+ utxos = utxos.sort((a, b) => b.value - a.value);
2202
+ const filteredUtxos = filterUneconomicalUtxos({
2203
+ utxos,
2204
+ feeRate: combineFee.feeRate,
2205
+ recipients,
2206
+ sender: address
2207
+ });
2208
+ for (const utxo of filteredUtxos) {
2209
+ sizeInfo = getSizeInfo({
2210
+ inputLength: neededUtxos.length,
2211
+ sender: address,
2212
+ recipients
2213
+ });
2214
+ const currentValue = new BigN(amount).plus(Math.ceil(sizeInfo.txVBytes * combineFee.feeRate));
2215
+ if (sum.gte(currentValue)) {
2216
+ break;
2217
+ }
2218
+ sum = sum.plus(utxo.value);
2219
+ neededUtxos.push(utxo);
2220
+ }
2221
+
2222
+ // re calculate
2223
+ sizeInfo = getSizeInfo({
2224
+ inputLength: neededUtxos.length,
2225
+ sender: address,
2226
+ recipients
2227
+ });
2228
+ if (!sizeInfo) {
2229
+ sizeInfo = getSizeInfo({
2230
+ inputLength: utxos.length || 1,
2231
+ sender: address,
2232
+ recipients
2233
+ });
2234
+ }
2235
+ estimatedFee = Math.ceil(sizeInfo.txVBytes * combineFee.feeRate).toString();
2236
+ const amountLeft = sum.minus(amount).minus(new BigN(estimatedFee));
2237
+ if (amountLeft.lte(0)) {
2238
+ error = 'Insufficient balance';
2239
+ } else {
2240
+ const senderAddressInfo = getBitcoinAddressInfo(address);
2241
+ const dustLimit = BTC_DUST_AMOUNT[senderAddressInfo.type] || 546;
2242
+ if (amountLeft.lte(dustLimit)) {
2243
+ sizeInfo = getSizeInfo({
2244
+ inputLength: neededUtxos.length,
2245
+ sender: address,
2246
+ recipients: [to || address]
2247
+ });
2248
+ estimatedFee = sum.minus(amount).toString();
2249
+ }
2250
+ }
2251
+ feeOptions = {
2252
+ ...fee,
2253
+ vSize: sizeInfo.txVBytes,
2254
+ estimatedFee
2255
+ };
2256
+ } catch (e) {
2257
+ feeOptions = {
2258
+ ...fee,
2259
+ estimatedFee,
2260
+ vSize: 0
2261
+ };
2262
+ error = e.message || e;
2263
+ console.warn('Unable to estimate fee', e);
2264
+ }
2265
+ return {
2266
+ feeOptions: feeOptions,
2267
+ feeType,
2268
+ error,
2269
+ id
2270
+ };
2271
+ };
2272
+ const subscription = combineLatest({
2273
+ freeBalance: freeBalanceSubject,
2274
+ fee: feeSubject
2275
+ }).subscribe({
2276
+ next: ({
2277
+ fee,
2278
+ freeBalance
2279
+ }) => {
2280
+ convertData(freeBalance, fee, _feeOptions, feeCustom).then(cb).catch(console.error);
2281
+ }
2282
+ });
2283
+ const [unsubBalance, freeBalance] = await this.#koniState.balanceService.subscribeBalance(address, chain, token, 'transferable', ExtrinsicType.TRANSFER_BALANCE, data => {
2284
+ freeBalanceSubject.next(data); // Must be called after subscription
2285
+ });
2286
+
2287
+ const fee = await this.#koniState.feeService.subscribeChainFee(id, chain, feeType, data => {
2288
+ feeSubject.next(data); // Must be called after subscription
2289
+ });
2290
+
2291
+ const unsub = () => {
2292
+ subscription.unsubscribe();
2293
+ unsubBalance();
2294
+ this.#koniState.feeService.unsubscribeChainFee(id, chain, feeType);
2295
+ };
2296
+ this.createUnsubscriptionHandle(id, unsub);
2297
+ port.onDisconnect.addListener(() => {
2298
+ this.cancelSubscription(id);
2299
+ });
2300
+ return convertData(freeBalance, fee, _feeOptions, feeCustom);
2301
+ }
1946
2302
  async subscribeAddressTransferableBalance({
1947
2303
  address,
1948
2304
  extrinsicType,
@@ -2095,6 +2451,15 @@ export default class KoniExtension {
2095
2451
  });
2096
2452
  return this.#koniState.getConfirmationsQueueSubjectCardano().getValue();
2097
2453
  }
2454
+ subscribeConfirmationsBitcoin(id, port) {
2455
+ const cb = createSubscription(id, port);
2456
+ const subscription = this.#koniState.getConfirmationsQueueSubjectBitcoin().subscribe(cb);
2457
+ this.createUnsubscriptionHandle(id, subscription.unsubscribe);
2458
+ port.onDisconnect.addListener(() => {
2459
+ this.cancelSubscription(id);
2460
+ });
2461
+ return this.#koniState.getConfirmationsQueueSubjectBitcoin().getValue();
2462
+ }
2098
2463
  async completeConfirmation(request) {
2099
2464
  return await this.#koniState.completeConfirmation(request);
2100
2465
  }
@@ -2104,7 +2469,9 @@ export default class KoniExtension {
2104
2469
  async completeConfirmationCardano(request) {
2105
2470
  return await this.#koniState.completeConfirmationCardano(request);
2106
2471
  }
2107
-
2472
+ async completeConfirmationBitcoin(request) {
2473
+ return await this.#koniState.completeConfirmationBitcoin(request);
2474
+ }
2108
2475
  /// Sign Qr
2109
2476
 
2110
2477
  getNetworkJsonByChainId(chainId) {
@@ -2800,6 +3167,7 @@ export default class KoniExtension {
2800
3167
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
2801
3168
  const {
2802
3169
  additionalValidator,
3170
+ emitterTransaction,
2803
3171
  eventsHandler,
2804
3172
  step,
2805
3173
  transaction,
@@ -4590,6 +4958,8 @@ export default class KoniExtension {
4590
4958
  return await this.updateAssetSetting(request);
4591
4959
  case 'pri(transfer.subscribe)':
4592
4960
  return this.subscribeMaxTransferable(request, id, port);
4961
+ case 'pri(transfer.confirmation.subscribe)':
4962
+ return this.subscribeTransferableWhenConfirmation(request, id, port);
4593
4963
  case 'pri(freeBalance.get)':
4594
4964
  return this.getAddressTransferableBalance(request);
4595
4965
  case 'pri(freeBalance.subscribe)':
@@ -4608,6 +4978,10 @@ export default class KoniExtension {
4608
4978
  /// Transfer
4609
4979
  case 'pri(accounts.transfer)':
4610
4980
  return await this.makeTransfer(request);
4981
+ case 'pri(accounts.bitcoin.dapp.transfer.confirmation)':
4982
+ return await this.makeBitcoinDappTransferConfirmation(request);
4983
+ case 'pri(accounts.psbt.transfer.confirmation)':
4984
+ return await this.makePsbtTransferAfterConfirmation(request);
4611
4985
  case 'pri(accounts.crossChainTransfer)':
4612
4986
  return await this.makeCrossChainTransfer(request);
4613
4987
  case 'pri(accounts.getOptimalTransferProcess)':
@@ -4640,12 +5014,16 @@ export default class KoniExtension {
4640
5014
  return this.subscribeConfirmationsTon(id, port);
4641
5015
  case 'pri(confirmationsCardano.subscribe)':
4642
5016
  return this.subscribeConfirmationsCardano(id, port);
5017
+ case 'pri(confirmationsBitcoin.subscribe)':
5018
+ return this.subscribeConfirmationsBitcoin(id, port);
4643
5019
  case 'pri(confirmations.complete)':
4644
5020
  return await this.completeConfirmation(request);
4645
5021
  case 'pri(confirmationsTon.complete)':
4646
5022
  return await this.completeConfirmationTon(request);
4647
5023
  case 'pri(confirmationsCardano.complete)':
4648
5024
  return await this.completeConfirmationCardano(request);
5025
+ case 'pri(confirmationsBitcoin.complete)':
5026
+ return await this.completeConfirmationBitcoin(request);
4649
5027
 
4650
5028
  /// Stake
4651
5029
  case 'pri(bonding.getBondingOptions)':
@@ -1,7 +1,7 @@
1
1
  /// <reference types="chrome" />
2
2
  import * as CardanoWasm from '@emurgo/cardano-serialization-lib-nodejs';
3
3
  import { _AssetRef, _AssetType, _ChainAsset, _ChainInfo, _MultiChainAsset } from '@subwallet/chain-list/types';
4
- import { AddTokenRequestExternal, AmountData, ApiMap, AuthRequestV2, ChainStakingMetadata, ConfirmationsQueue, ConfirmationsQueueCardano, ConfirmationsQueueTon, CrowdloanItem, CrowdloanJson, EvmSendTransactionParams, ExternalRequestPromise, MantaPayConfig, MantaPaySyncState, NftCollection, NftItem, NftJson, NominatorMetadata, RequestAccountExportPrivateKey, RequestCardanoSignData, RequestCardanoSignTransaction, RequestConfirmationComplete, RequestConfirmationCompleteCardano, RequestConfirmationCompleteTon, RequestCrowdloanContributions, RequestSettingsType, ResponseAccountExportPrivateKey, ResponseCardanoSignData, ResponseCardanoSignTransaction, ServiceInfo, SingleModeJson, StakingItem, StakingJson, StakingRewardItem, StakingRewardJson, StakingType, UiSettings } from '@subwallet/extension-base/background/KoniTypes';
4
+ import { AddTokenRequestExternal, AmountData, ApiMap, AuthRequestV2, BitcoinSendTransactionParams, BitcoinSignMessageParams, BitcoinSignMessageResult, BitcoinSignPsbtParams, BitcoinSignPsbtResult, ChainStakingMetadata, ConfirmationsQueue, ConfirmationsQueueBitcoin, ConfirmationsQueueCardano, ConfirmationsQueueTon, CrowdloanItem, CrowdloanJson, EvmSendTransactionParams, ExternalRequestPromise, MantaPayConfig, MantaPaySyncState, NftCollection, NftItem, NftJson, NominatorMetadata, RequestAccountExportPrivateKey, RequestCardanoSignData, RequestCardanoSignTransaction, RequestConfirmationComplete, RequestConfirmationCompleteBitcoin, RequestConfirmationCompleteCardano, RequestConfirmationCompleteTon, RequestCrowdloanContributions, RequestSettingsType, ResponseAccountExportPrivateKey, ResponseCardanoSignData, ResponseCardanoSignTransaction, ServiceInfo, SingleModeJson, StakingItem, StakingJson, StakingRewardItem, StakingRewardJson, StakingType, UiSettings } from '@subwallet/extension-base/background/KoniTypes';
5
5
  import { RequestAuthorizeTab, RequestRpcSend, RequestRpcSubscribe, RequestRpcUnsubscribe, RequestSign, ResponseRpcListProviders, ResponseSigning } from '@subwallet/extension-base/background/types';
6
6
  import { EnvConfig } from '@subwallet/extension-base/constants';
7
7
  import { BalanceService } from '@subwallet/extension-base/services/balance-service';
@@ -82,6 +82,7 @@ export default class KoniState {
82
82
  private generalStatus;
83
83
  private waitSleeping;
84
84
  private waitStarting;
85
+ private waitStartingFull;
85
86
  constructor(providers?: Providers);
86
87
  get knownMetadata(): MetadataDef[];
87
88
  injectMetadata(request: MetadataDef): boolean;
@@ -100,7 +101,6 @@ export default class KoniState {
100
101
  init(): Promise<void>;
101
102
  initMantaPay(password: string): Promise<void>;
102
103
  private startSubscription;
103
- onReady(): void;
104
104
  updateKeyringState(isReady?: boolean, callback?: () => void): void;
105
105
  private lazyNext;
106
106
  getAuthRequestV2(id: string): AuthRequestV2;
@@ -196,6 +196,7 @@ export default class KoniState {
196
196
  getTonApi(networkKey: string): import("../../../services/chain-service/handler/TonApi").TonApi;
197
197
  getCardanoApiMap(): Record<string, import("../../../services/chain-service/handler/CardanoApi").CardanoApi>;
198
198
  getCardanoApi(networkKey: string): import("../../../services/chain-service/handler/CardanoApi").CardanoApi;
199
+ getBitcoinApi(networkKey: string): import("../../../services/chain-service/handler/bitcoin/BitcoinApi").BitcoinApi;
199
200
  getApiMap(): ApiMap;
200
201
  refreshSubstrateApi(key: string): boolean;
201
202
  refreshWeb3Api(key: string): void;
@@ -221,12 +222,17 @@ export default class KoniState {
221
222
  cardanoSignData(id: string, url: string, params: RequestCardanoSignData, currentAddress: string): Promise<ResponseCardanoSignData>;
222
223
  cardanoSignTx(id: string, url: string, param: RequestCardanoSignTransaction, currentAddress: string): Promise<ResponseCardanoSignTransaction>;
223
224
  cardanoSubmitTx(id: string, url: string, txHex: string): Promise<string>;
225
+ bitcoinSign(id: string, url: string, method: string, params: BitcoinSignMessageParams): Promise<BitcoinSignMessageResult>;
226
+ bitcoinSignPspt(id: string, url: string, params: BitcoinSignPsbtParams): Promise<BitcoinSignPsbtResult>;
227
+ bitcoinSendTransaction(id: string, url: string, transactionParams: BitcoinSendTransactionParams): Promise<string | undefined>;
224
228
  getConfirmationsQueueSubject(): BehaviorSubject<ConfirmationsQueue>;
225
229
  getConfirmationsQueueSubjectTon(): BehaviorSubject<ConfirmationsQueueTon>;
226
230
  getConfirmationsQueueSubjectCardano(): BehaviorSubject<ConfirmationsQueueCardano>;
231
+ getConfirmationsQueueSubjectBitcoin(): BehaviorSubject<ConfirmationsQueueBitcoin>;
227
232
  completeConfirmation(request: RequestConfirmationComplete): Promise<boolean>;
228
233
  completeConfirmationTon(request: RequestConfirmationCompleteTon): Promise<boolean>;
229
234
  completeConfirmationCardano(request: RequestConfirmationCompleteCardano): Promise<boolean>;
235
+ completeConfirmationBitcoin(request: RequestConfirmationCompleteBitcoin): Promise<boolean>;
230
236
  private onMV3Update;
231
237
  private storePreviousVersionData;
232
238
  migrateMV3LocalStorage(data: string): Promise<boolean>;
@@ -241,7 +247,8 @@ export default class KoniState {
241
247
  get activeChainSlugs(): string[];
242
248
  sleep(): Promise<void>;
243
249
  private _start;
244
- wakeup(): Promise<void>;
250
+ private _startFull;
251
+ wakeup(fullWakeup?: boolean): Promise<void>;
245
252
  cancelSubscription(id: string): boolean;
246
253
  createUnsubscriptionHandle(id: string, unsubscribe: () => void): void;
247
254
  get detectBalanceChainSlugMap(): Record<string, string>;