@airgap/coinlib-core 0.13.7-beta.0 → 0.13.7-beta.2
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/actions/GetKtAccountsAction.js +1 -1
- package/actions/GetKtAccountsAction.js.map +1 -1
- package/airgap-coinlib-core.min.js +2914 -2332
- package/index.d.ts +1 -3
- package/index.js +1 -6
- package/index.js.map +1 -1
- package/interfaces/IAirGapAddress.d.ts +19 -0
- package/interfaces/IAirGapAddress.js +3 -0
- package/interfaces/IAirGapAddress.js.map +1 -0
- package/package.json +1 -1
- package/protocols/CryptoClient.d.ts +4 -5
- package/protocols/Ed25519CryptoClient.d.ts +1 -2
- package/protocols/Ed25519CryptoClient.js +1 -1
- package/protocols/Ed25519CryptoClient.js.map +1 -1
- package/protocols/ICoinBaseProtocol.d.ts +47 -0
- package/protocols/ICoinBaseProtocol.js +3 -0
- package/protocols/ICoinBaseProtocol.js.map +1 -0
- package/protocols/ICoinOfflineProtocol.d.ts +22 -0
- package/protocols/ICoinOfflineProtocol.js +3 -0
- package/protocols/ICoinOfflineProtocol.js.map +1 -0
- package/protocols/ICoinOnlineProtocol.d.ts +46 -0
- package/protocols/ICoinOnlineProtocol.js +3 -0
- package/protocols/ICoinOnlineProtocol.js.map +1 -0
- package/protocols/ICoinProtocol.d.ts +4 -110
- package/protocols/ICoinSubProtocol.d.ts +3 -3
- package/protocols/NonExtendedProtocol.d.ts +4 -3
- package/protocols/NonExtendedProtocol.js +4 -1
- package/protocols/NonExtendedProtocol.js.map +1 -1
- package/protocols/Secp256k1CryptoClient.d.ts +1 -2
- package/protocols/Secp256k1CryptoClient.js +1 -1
- package/protocols/Secp256k1CryptoClient.js.map +1 -1
- package/protocols/Sr25519CryptoClient.d.ts +1 -2
- package/protocols/aeternity/AeternityAddress.d.ts +1 -1
- package/protocols/aeternity/AeternityAddress.js +1 -1
- package/protocols/aeternity/AeternityCryptoClient.d.ts +1 -2
- package/protocols/aeternity/AeternityCryptoClient.js +1 -1
- package/protocols/aeternity/AeternityCryptoClient.js.map +1 -1
- package/protocols/aeternity/AeternityProtocol.d.ts +41 -33
- package/protocols/aeternity/AeternityProtocol.js +70 -56
- package/protocols/aeternity/AeternityProtocol.js.map +1 -1
- package/protocols/aeternity/AeternityTypes.d.ts +6 -0
- package/protocols/bitcoin/BitcoinAddress.d.ts +1 -1
- package/protocols/bitcoin/BitcoinAddress.js +1 -1
- package/protocols/bitcoin/BitcoinCryptoClient.d.ts +1 -2
- package/protocols/bitcoin/BitcoinCryptoClient.js +2 -2
- package/protocols/bitcoin/BitcoinCryptoClient.js.map +1 -1
- package/protocols/bitcoin/BitcoinProtocol.d.ts +43 -32
- package/protocols/bitcoin/BitcoinProtocol.js +98 -79
- package/protocols/bitcoin/BitcoinProtocol.js.map +1 -1
- package/protocols/bitcoin/BitcoinSegwitAddress.d.ts +1 -1
- package/protocols/bitcoin/BitcoinSegwitAddress.js +1 -1
- package/protocols/bitcoin/BitcoinSegwitProtocol.d.ts +10 -11
- package/protocols/bitcoin/BitcoinSegwitProtocol.js +42 -29
- package/protocols/bitcoin/BitcoinSegwitProtocol.js.map +1 -1
- package/protocols/bitcoin/BitcoinTestnetProtocol.d.ts +6 -3
- package/protocols/bitcoin/BitcoinTestnetProtocol.js +6 -3
- package/protocols/bitcoin/BitcoinTestnetProtocol.js.map +1 -1
- package/protocols/bitcoin/BitcoinTypes.d.ts +6 -0
- package/protocols/cosmos/CosmosAddress.d.ts +1 -1
- package/protocols/cosmos/CosmosAddress.js +1 -1
- package/protocols/cosmos/CosmosCryptoClient.d.ts +1 -2
- package/protocols/cosmos/CosmosCryptoClient.js +1 -1
- package/protocols/cosmos/CosmosCryptoClient.js.map +1 -1
- package/protocols/cosmos/CosmosProtocol.d.ts +41 -29
- package/protocols/cosmos/CosmosProtocol.js +72 -58
- package/protocols/cosmos/CosmosProtocol.js.map +1 -1
- package/protocols/cosmos/CosmosTransaction.d.ts +3 -2
- package/protocols/cosmos/CosmosTransaction.js +2 -2
- package/protocols/cosmos/CosmosTransaction.js.map +1 -1
- package/protocols/cosmos/CosmosTypes.d.ts +6 -0
- package/protocols/cosmos/CosmosTypes.js.map +1 -1
- package/protocols/cosmos/cosmos-message/CosmosDelegateMessage.d.ts +3 -2
- package/protocols/cosmos/cosmos-message/CosmosDelegateMessage.js +3 -3
- package/protocols/cosmos/cosmos-message/CosmosDelegateMessage.js.map +1 -1
- package/protocols/cosmos/cosmos-message/CosmosMessage.d.ts +3 -2
- package/protocols/cosmos/cosmos-message/CosmosMessage.js.map +1 -1
- package/protocols/cosmos/cosmos-message/CosmosSendMessage.d.ts +2 -2
- package/protocols/cosmos/cosmos-message/CosmosSendMessage.js +3 -3
- package/protocols/cosmos/cosmos-message/CosmosSendMessage.js.map +1 -1
- package/protocols/cosmos/cosmos-message/CosmosWithdrawDelegationRewardMessage.d.ts +3 -2
- package/protocols/cosmos/cosmos-message/CosmosWithdrawDelegationRewardMessage.js +3 -3
- package/protocols/cosmos/cosmos-message/CosmosWithdrawDelegationRewardMessage.js.map +1 -1
- package/protocols/ethereum/BaseEthereumProtocol.d.ts +43 -31
- package/protocols/ethereum/BaseEthereumProtocol.js +95 -76
- package/protocols/ethereum/BaseEthereumProtocol.js.map +1 -1
- package/protocols/ethereum/EthereumAddress.d.ts +1 -1
- package/protocols/ethereum/EthereumAddress.js +1 -1
- package/protocols/ethereum/EthereumCryptoClient.d.ts +1 -2
- package/protocols/ethereum/EthereumCryptoClient.js +8 -7
- package/protocols/ethereum/EthereumCryptoClient.js.map +1 -1
- package/protocols/ethereum/EthereumProtocol.d.ts +6 -4
- package/protocols/ethereum/EthereumProtocol.js +8 -6
- package/protocols/ethereum/EthereumProtocol.js.map +1 -1
- package/protocols/ethereum/EthereumTypes.d.ts +6 -0
- package/protocols/ethereum/clients/info-clients/EtherscanInfoClient.js +82 -58
- package/protocols/ethereum/clients/info-clients/EtherscanInfoClient.js.map +1 -1
- package/protocols/ethereum/clients/info-clients/InfoClient.d.ts +3 -3
- package/protocols/ethereum/erc20/GenericERC20.d.ts +10 -7
- package/protocols/ethereum/erc20/GenericERC20.js +27 -23
- package/protocols/ethereum/erc20/GenericERC20.js.map +1 -1
- package/protocols/groestlcoin/GroestlcoinProtocol.d.ts +29 -15
- package/protocols/groestlcoin/GroestlcoinProtocol.js +31 -17
- package/protocols/groestlcoin/GroestlcoinProtocol.js.map +1 -1
- package/protocols/substrate/SubstrateCryptoClient.d.ts +1 -2
- package/protocols/substrate/SubstrateCryptoClient.js +7 -7
- package/protocols/substrate/SubstrateCryptoClient.js.map +1 -1
- package/protocols/substrate/SubstrateDelegateProtocol.js +35 -35
- package/protocols/substrate/SubstrateDelegateProtocol.js.map +1 -1
- package/protocols/substrate/SubstrateProtocol.d.ts +43 -29
- package/protocols/substrate/SubstrateProtocol.js +60 -52
- package/protocols/substrate/SubstrateProtocol.js.map +1 -1
- package/protocols/substrate/SubstrateTypes.d.ts +6 -0
- package/protocols/substrate/astar/AstarProtocol.d.ts +28 -15
- package/protocols/substrate/astar/AstarProtocol.js +30 -17
- package/protocols/substrate/astar/AstarProtocol.js.map +1 -1
- package/protocols/substrate/astar/shiden/ShidenProtocol.d.ts +22 -11
- package/protocols/substrate/astar/shiden/ShidenProtocol.js +24 -13
- package/protocols/substrate/astar/shiden/ShidenProtocol.js.map +1 -1
- package/protocols/substrate/common/SubstrateAccountController.js +4 -4
- package/protocols/substrate/common/data/account/SubstrateAddress.d.ts +1 -1
- package/protocols/substrate/common/data/account/SubstrateAddress.js +2 -2
- package/protocols/substrate/common/data/scale/type/SCALEAccountId.js +1 -1
- package/protocols/substrate/common/data/transaction/SubstrateTransactionPayload.d.ts +1 -1
- package/protocols/substrate/common/data/transaction/method/SubstrateTransactionMethodArgs.js +12 -12
- package/protocols/substrate/kusama/KusamaProtocol.d.ts +28 -15
- package/protocols/substrate/kusama/KusamaProtocol.js +30 -17
- package/protocols/substrate/kusama/KusamaProtocol.js.map +1 -1
- package/protocols/substrate/moonbeam/MoonbeamProtocol.d.ts +28 -15
- package/protocols/substrate/moonbeam/MoonbeamProtocol.js +61 -48
- package/protocols/substrate/moonbeam/MoonbeamProtocol.js.map +1 -1
- package/protocols/substrate/moonbeam/controllers/MoonbeamAccountController.js +3 -3
- package/protocols/substrate/moonbeam/data/account/MoonbeamAddress.d.ts +1 -1
- package/protocols/substrate/moonbeam/data/account/MoonbeamAddress.js +3 -3
- package/protocols/substrate/moonbeam/moonbase/MoonbaseProtocol.d.ts +20 -12
- package/protocols/substrate/moonbeam/moonbase/MoonbaseProtocol.js +22 -14
- package/protocols/substrate/moonbeam/moonbase/MoonbaseProtocol.js.map +1 -1
- package/protocols/substrate/moonbeam/moonriver/MoonriverProtocol.d.ts +20 -12
- package/protocols/substrate/moonbeam/moonriver/MoonriverProtocol.js +22 -14
- package/protocols/substrate/moonbeam/moonriver/MoonriverProtocol.js.map +1 -1
- package/protocols/substrate/polkadot/PolkadotProtocol.d.ts +28 -15
- package/protocols/substrate/polkadot/PolkadotProtocol.js +30 -17
- package/protocols/substrate/polkadot/PolkadotProtocol.js.map +1 -1
- package/protocols/tezos/TezosAddress.d.ts +1 -1
- package/protocols/tezos/TezosAddress.js +1 -1
- package/protocols/tezos/TezosCryptoClient.d.ts +1 -1
- package/protocols/tezos/TezosCryptoClient.js +1 -1
- package/protocols/tezos/TezosCryptoClient.js.map +1 -1
- package/protocols/tezos/TezosProtocol.d.ts +42 -29
- package/protocols/tezos/TezosProtocol.js +105 -94
- package/protocols/tezos/TezosProtocol.js.map +1 -1
- package/protocols/tezos/contract/TezosContract.js +1 -0
- package/protocols/tezos/contract/TezosContract.js.map +1 -1
- package/protocols/tezos/fa/TezosBTC.d.ts +0 -1
- package/protocols/tezos/fa/TezosBTC.js +1 -3
- package/protocols/tezos/fa/TezosBTC.js.map +1 -1
- package/protocols/tezos/fa/TezosBTCtez.d.ts +0 -1
- package/protocols/tezos/fa/TezosBTCtez.js +1 -3
- package/protocols/tezos/fa/TezosBTCtez.js.map +1 -1
- package/protocols/tezos/fa/TezosCTez.d.ts +0 -1
- package/protocols/tezos/fa/TezosCTez.js +1 -3
- package/protocols/tezos/fa/TezosCTez.js.map +1 -1
- package/protocols/tezos/fa/TezosDOGA.d.ts +0 -1
- package/protocols/tezos/fa/TezosDOGA.js +1 -3
- package/protocols/tezos/fa/TezosDOGA.js.map +1 -1
- package/protocols/tezos/fa/TezosETHtz.d.ts +0 -1
- package/protocols/tezos/fa/TezosETHtz.js +1 -3
- package/protocols/tezos/fa/TezosETHtz.js.map +1 -1
- package/protocols/tezos/fa/TezosFA1Protocol.js +6 -6
- package/protocols/tezos/fa/TezosFA1Protocol.js.map +1 -1
- package/protocols/tezos/fa/TezosFA2Protocol.d.ts +3 -2
- package/protocols/tezos/fa/TezosFA2Protocol.js +10 -9
- package/protocols/tezos/fa/TezosFA2Protocol.js.map +1 -1
- package/protocols/tezos/fa/TezosFAProtocol.d.ts +9 -5
- package/protocols/tezos/fa/TezosFAProtocol.js +48 -35
- package/protocols/tezos/fa/TezosFAProtocol.js.map +1 -1
- package/protocols/tezos/fa/TezosKolibriUSD.d.ts +0 -1
- package/protocols/tezos/fa/TezosKolibriUSD.js +1 -3
- package/protocols/tezos/fa/TezosKolibriUSD.js.map +1 -1
- package/protocols/tezos/fa/TezosPlanty.d.ts +0 -1
- package/protocols/tezos/fa/TezosPlanty.js +1 -3
- package/protocols/tezos/fa/TezosPlanty.js.map +1 -1
- package/protocols/tezos/fa/TezosQUIPU.d.ts +0 -1
- package/protocols/tezos/fa/TezosQUIPU.js +1 -3
- package/protocols/tezos/fa/TezosQUIPU.js.map +1 -1
- package/protocols/tezos/fa/TezosSIRS.d.ts +0 -1
- package/protocols/tezos/fa/TezosSIRS.js +1 -3
- package/protocols/tezos/fa/TezosSIRS.js.map +1 -1
- package/protocols/tezos/fa/TezosStaker.d.ts +0 -1
- package/protocols/tezos/fa/TezosStaker.js +1 -3
- package/protocols/tezos/fa/TezosStaker.js.map +1 -1
- package/protocols/tezos/fa/TezosUBTC.d.ts +0 -1
- package/protocols/tezos/fa/TezosUBTC.js +1 -3
- package/protocols/tezos/fa/TezosUBTC.js.map +1 -1
- package/protocols/tezos/fa/TezosUDEFI.d.ts +0 -1
- package/protocols/tezos/fa/TezosUDEFI.js +1 -3
- package/protocols/tezos/fa/TezosUDEFI.js.map +1 -1
- package/protocols/tezos/fa/TezosUSD.d.ts +0 -1
- package/protocols/tezos/fa/TezosUSD.js +1 -3
- package/protocols/tezos/fa/TezosUSD.js.map +1 -1
- package/protocols/tezos/fa/TezosUSDT.d.ts +0 -1
- package/protocols/tezos/fa/TezosUSDT.js +1 -3
- package/protocols/tezos/fa/TezosUSDT.js.map +1 -1
- package/protocols/tezos/fa/TezosUUSD.d.ts +0 -1
- package/protocols/tezos/fa/TezosUUSD.js +1 -3
- package/protocols/tezos/fa/TezosUUSD.js.map +1 -1
- package/protocols/tezos/fa/TezosWRAP.d.ts +0 -1
- package/protocols/tezos/fa/TezosWRAP.js +1 -3
- package/protocols/tezos/fa/TezosWRAP.js.map +1 -1
- package/protocols/tezos/fa/TezosWrapped.d.ts +0 -1
- package/protocols/tezos/fa/TezosWrapped.js +1 -3
- package/protocols/tezos/fa/TezosWrapped.js.map +1 -1
- package/protocols/tezos/fa/TezosYOU.d.ts +0 -1
- package/protocols/tezos/fa/TezosYOU.js +1 -3
- package/protocols/tezos/fa/TezosYOU.js.map +1 -1
- package/protocols/tezos/kt/TezosKtProtocol.d.ts +10 -7
- package/protocols/tezos/kt/TezosKtProtocol.js +50 -20
- package/protocols/tezos/kt/TezosKtProtocol.js.map +1 -1
- package/protocols/tezos/sapling/TezosSaplingCryptoClient.d.ts +1 -1
- package/protocols/tezos/sapling/TezosSaplingProtocol.d.ts +43 -28
- package/protocols/tezos/sapling/TezosSaplingProtocol.js +129 -69
- package/protocols/tezos/sapling/TezosSaplingProtocol.js.map +1 -1
- package/protocols/tezos/sapling/utils/TezosSaplingBookkeeper.js +7 -7
- package/protocols/tezos/sapling/utils/TezosSaplingBookkeeper.js.map +1 -1
- package/protocols/tezos/types/TezosAddressCursor.d.ts +3 -0
- package/protocols/tezos/types/TezosAddressCursor.js +3 -0
- package/protocols/tezos/types/TezosAddressCursor.js.map +1 -0
- package/protocols/tezos/types/TezosAddressResult.d.ts +4 -0
- package/protocols/tezos/types/TezosAddressResult.js +3 -0
- package/protocols/tezos/types/TezosAddressResult.js.map +1 -0
- package/protocols/tezos/types/kt/TezosKtAddressCursor.d.ts +4 -0
- package/protocols/tezos/types/kt/TezosKtAddressCursor.js +3 -0
- package/protocols/tezos/types/kt/TezosKtAddressCursor.js.map +1 -0
- package/protocols/tezos/types/kt/TezosKtAddressResult.d.ts +5 -0
- package/protocols/tezos/types/kt/TezosKtAddressResult.js +3 -0
- package/protocols/tezos/types/kt/TezosKtAddressResult.js.map +1 -0
- package/protocols/tezos/types/sapling/TezosSaplingAddressCursor.d.ts +4 -0
- package/protocols/tezos/types/sapling/TezosSaplingAddressCursor.js +3 -0
- package/protocols/tezos/types/sapling/TezosSaplingAddressCursor.js.map +1 -0
- package/protocols/tezos/types/sapling/TezosSaplingAddressResult.d.ts +4 -0
- package/protocols/tezos/types/sapling/TezosSaplingAddressResult.js +3 -0
- package/protocols/tezos/types/sapling/TezosSaplingAddressResult.js.map +1 -0
- package/serializer/unsigned-transactions/xtz-btc-transactions.validator.js +23 -10
- package/serializer/unsigned-transactions/xtz-btc-transactions.validator.js.map +1 -1
- package/serializer/validators/validators.js +246 -140
- package/serializer/validators/validators.js.map +1 -1
- package/serializer-v3/unsigned-transactions/xtz-btc-transactions.validator.js +23 -10
- package/serializer-v3/unsigned-transactions/xtz-btc-transactions.validator.js.map +1 -1
- package/serializer-v3/validators/validators.js +246 -140
- package/serializer-v3/validators/validators.js.map +1 -1
- package/utils/AES.d.ts +2 -3
- package/utils/AES.js +3 -1
- package/utils/AES.js.map +1 -1
- package/utils/protocolsByIdentifier.d.ts +1 -1
- package/utils/protocolsByIdentifier.js +114 -24
- package/utils/protocolsByIdentifier.js.map +1 -1
- package/utils/supportedProtocols.d.ts +2 -2
- package/utils/supportedProtocols.js +114 -12
- package/utils/supportedProtocols.js.map +1 -1
- package/wallet/AirGapCoinWallet.d.ts +1 -1
- package/wallet/AirGapCoinWallet.js +45 -27
- package/wallet/AirGapCoinWallet.js.map +1 -1
- package/wallet/AirGapMarketWallet.js +28 -24
- package/wallet/AirGapMarketWallet.js.map +1 -1
- package/wallet/AirGapNFTWallet.d.ts +1 -1
- package/wallet/AirGapNFTWallet.js +26 -5
- package/wallet/AirGapNFTWallet.js.map +1 -1
- package/wallet/AirGapWallet.d.ts +1 -1
- package/wallet/AirGapWallet.js +23 -12
- package/wallet/AirGapWallet.js.map +1 -1
- package/utils/createProtocol.d.ts +0 -3
- package/utils/createProtocol.js +0 -143
- package/utils/createProtocol.js.map +0 -1
- package/utils/subProtocols.d.ts +0 -8
- package/utils/subProtocols.js +0 -53
- package/utils/subProtocols.js.map +0 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { IAirGapSignedTransaction } from '../../interfaces/IAirGapSignedTransaction';
|
|
3
2
|
import { AirGapTransactionStatus, IAirGapTransaction } from '../../interfaces/IAirGapTransaction';
|
|
4
3
|
import { SignedBitcoinTransaction } from '../../serializer/schemas/definitions/signed-transaction-bitcoin';
|
|
@@ -7,8 +6,7 @@ import { RawBitcoinTransaction } from '../../serializer/types';
|
|
|
7
6
|
import { ProtocolSymbols } from '../../utils/ProtocolSymbols';
|
|
8
7
|
import { CurrencyUnit, FeeDefaults, ICoinProtocol } from '../ICoinProtocol';
|
|
9
8
|
import { ICoinSubProtocol } from '../ICoinSubProtocol';
|
|
10
|
-
import { BitcoinBlockbookTransactionCursor, BitcoinBlockbookTransactionResult } from './BitcoinTypes';
|
|
11
|
-
import { BitcoinAddress } from './BitcoinAddress';
|
|
9
|
+
import { BitcoinAddressCursor, BitcoinAddressResult, BitcoinBlockbookTransactionCursor, BitcoinBlockbookTransactionResult } from './BitcoinTypes';
|
|
12
10
|
import { BitcoinProtocolOptions } from './BitcoinProtocolOptions';
|
|
13
11
|
import { BitcoinCryptoClient } from './BitcoinCryptoClient';
|
|
14
12
|
export interface UTXOResponse {
|
|
@@ -88,38 +86,51 @@ export interface AddressResponse {
|
|
|
88
86
|
transactions?: Transaction[];
|
|
89
87
|
}
|
|
90
88
|
export declare class BitcoinProtocol implements ICoinProtocol {
|
|
91
|
-
readonly
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
89
|
+
protected readonly _options: BitcoinProtocolOptions;
|
|
90
|
+
protected _symbol: string;
|
|
91
|
+
symbol: Promise<string>;
|
|
92
|
+
protected _name: string;
|
|
93
|
+
name: Promise<string>;
|
|
94
|
+
protected _marketSymbol: string;
|
|
95
|
+
marketSymbol: Promise<string>;
|
|
96
|
+
protected _feeSymbol: string;
|
|
97
|
+
feeSymbol: Promise<string>;
|
|
98
|
+
protected _feeDefaults: FeeDefaults;
|
|
99
|
+
feeDefaults: Promise<FeeDefaults>;
|
|
100
|
+
protected _decimals: number;
|
|
101
|
+
decimals: Promise<number>;
|
|
102
|
+
protected _feeDecimals: number;
|
|
103
|
+
feeDecimals: Promise<number>;
|
|
104
|
+
protected _identifier: ProtocolSymbols;
|
|
105
|
+
identifier: Promise<ProtocolSymbols>;
|
|
106
|
+
protected _units: CurrencyUnit[];
|
|
107
|
+
units: Promise<CurrencyUnit[]>;
|
|
108
|
+
protected _supportsHD: boolean;
|
|
109
|
+
supportsHD: Promise<boolean>;
|
|
110
|
+
protected _standardDerivationPath: string;
|
|
111
|
+
standardDerivationPath: Promise<string>;
|
|
112
|
+
protected _addressIsCaseSensitive: boolean;
|
|
113
|
+
addressIsCaseSensitive: Promise<boolean>;
|
|
114
|
+
protected _addressValidationPattern: string;
|
|
115
|
+
addressValidationPattern: Promise<string>;
|
|
116
|
+
protected _addressPlaceholder: string;
|
|
117
|
+
addressPlaceholder: Promise<string>;
|
|
107
118
|
readonly cryptoClient: BitcoinCryptoClient;
|
|
108
|
-
|
|
119
|
+
readonly options: Promise<BitcoinProtocolOptions>;
|
|
120
|
+
constructor(_options?: BitcoinProtocolOptions);
|
|
109
121
|
getBlockExplorerLinkForAddress(address: string): Promise<string>;
|
|
110
122
|
getBlockExplorerLinkForTxId(txId: string): Promise<string>;
|
|
111
123
|
getPublicKeyFromMnemonic(mnemonic: string, derivationPath: string, password?: string): Promise<string>;
|
|
112
|
-
getPrivateKeyFromMnemonic(mnemonic: string, derivationPath: string, password?: string): Promise<
|
|
124
|
+
getPrivateKeyFromMnemonic(mnemonic: string, derivationPath: string, password?: string): Promise<string>;
|
|
113
125
|
getExtendedPrivateKeyFromMnemonic(mnemonic: string, derivationPath: string, password?: string): Promise<string>;
|
|
114
126
|
getPublicKeyFromHexSecret(secret: string, derivationPath: string): Promise<string>;
|
|
115
|
-
getPrivateKeyFromHexSecret(secret: string, derivationPath: string): Promise<
|
|
127
|
+
getPrivateKeyFromHexSecret(secret: string, derivationPath: string): Promise<string>;
|
|
116
128
|
getExtendedPrivateKeyFromHexSecret(secret: string, derivationPath: string): Promise<string>;
|
|
117
|
-
getAddressFromPublicKey(publicKey: string): Promise<
|
|
118
|
-
getAddressesFromPublicKey(publicKey: string): Promise<
|
|
119
|
-
getAddressFromExtendedPublicKey(extendedPublicKey: string, visibilityDerivationIndex: number, addressDerivationIndex: number): Promise<
|
|
120
|
-
getAddressesFromExtendedPublicKey(extendedPublicKey: string, visibilityDerivationIndex: number, addressCount: number, offset: number): Promise<
|
|
121
|
-
|
|
122
|
-
signWithPrivateKey(privateKey: Buffer, transaction: RawBitcoinTransaction): Promise<IAirGapSignedTransaction>;
|
|
129
|
+
getAddressFromPublicKey(publicKey: string, cursor?: BitcoinAddressCursor): Promise<BitcoinAddressResult>;
|
|
130
|
+
getAddressesFromPublicKey(publicKey: string, cursor?: BitcoinAddressCursor): Promise<BitcoinAddressResult[]>;
|
|
131
|
+
getAddressFromExtendedPublicKey(extendedPublicKey: string, visibilityDerivationIndex: number, addressDerivationIndex: number): Promise<BitcoinAddressResult>;
|
|
132
|
+
getAddressesFromExtendedPublicKey(extendedPublicKey: string, visibilityDerivationIndex: number, addressCount: number, offset: number): Promise<BitcoinAddressResult[]>;
|
|
133
|
+
signWithPrivateKey(privateKey: string, transaction: RawBitcoinTransaction): Promise<IAirGapSignedTransaction>;
|
|
123
134
|
signWithExtendedPrivateKey(extendedPrivateKey: string, transaction: RawBitcoinTransaction): Promise<string>;
|
|
124
135
|
getTransactionDetails(unsignedTx: UnsignedTransaction): Promise<IAirGapTransaction[]>;
|
|
125
136
|
getTransactionDetailsFromSigned(signedTx: SignedBitcoinTransaction): Promise<IAirGapTransaction[]>;
|
|
@@ -140,15 +151,15 @@ export declare class BitcoinProtocol implements ICoinProtocol {
|
|
|
140
151
|
getTransactionsFromAddresses(addresses: string[], limit: number, cursor?: BitcoinBlockbookTransactionCursor): Promise<BitcoinBlockbookTransactionResult>;
|
|
141
152
|
private containsSome;
|
|
142
153
|
signMessage(message: string, keypair: {
|
|
143
|
-
privateKey:
|
|
154
|
+
privateKey: string;
|
|
144
155
|
}): Promise<string>;
|
|
145
156
|
verifyMessage(message: string, signature: string, publicKey: string): Promise<boolean>;
|
|
146
157
|
encryptAsymmetric(message: string, publicKey: string): Promise<string>;
|
|
147
158
|
decryptAsymmetric(message: string, keypair: {
|
|
148
159
|
publicKey: string;
|
|
149
|
-
privateKey:
|
|
160
|
+
privateKey: string;
|
|
150
161
|
}): Promise<string>;
|
|
151
|
-
encryptAES(message: string, privateKey:
|
|
152
|
-
decryptAES(message: string, privateKey:
|
|
162
|
+
encryptAES(message: string, privateKey: string): Promise<string>;
|
|
163
|
+
decryptAES(message: string, privateKey: string): Promise<string>;
|
|
153
164
|
getTransactionStatuses(transactionHashes: string[]): Promise<AirGapTransactionStatus[]>;
|
|
154
165
|
}
|
|
@@ -78,23 +78,30 @@ var errors_1 = require("../../errors");
|
|
|
78
78
|
var coinlib_error_1 = require("../../errors/coinlib-error");
|
|
79
79
|
var DUST_AMOUNT = 50;
|
|
80
80
|
var BitcoinProtocol = /** @class */ (function () {
|
|
81
|
-
function BitcoinProtocol(
|
|
82
|
-
if (
|
|
83
|
-
this.
|
|
84
|
-
this.
|
|
85
|
-
this.
|
|
86
|
-
this.
|
|
87
|
-
this.
|
|
88
|
-
this.
|
|
89
|
-
this.
|
|
81
|
+
function BitcoinProtocol(_options) {
|
|
82
|
+
if (_options === void 0) { _options = new BitcoinProtocolOptions_1.BitcoinProtocolOptions(); }
|
|
83
|
+
this._options = _options;
|
|
84
|
+
this._symbol = 'BTC';
|
|
85
|
+
this.symbol = Promise.resolve(this._symbol);
|
|
86
|
+
this._name = 'Bitcoin (Legacy)';
|
|
87
|
+
this.name = Promise.resolve(this._name);
|
|
88
|
+
this._marketSymbol = 'btc';
|
|
89
|
+
this.marketSymbol = Promise.resolve(this._marketSymbol);
|
|
90
|
+
this._feeSymbol = 'btc';
|
|
91
|
+
this.feeSymbol = Promise.resolve(this._feeSymbol);
|
|
92
|
+
this._feeDefaults = {
|
|
90
93
|
low: '0.00002',
|
|
91
94
|
medium: '0.00004',
|
|
92
95
|
high: '0.00005'
|
|
93
96
|
};
|
|
94
|
-
this.
|
|
95
|
-
this.
|
|
96
|
-
this.
|
|
97
|
-
this.
|
|
97
|
+
this.feeDefaults = Promise.resolve(this._feeDefaults);
|
|
98
|
+
this._decimals = 8;
|
|
99
|
+
this.decimals = Promise.resolve(this._decimals);
|
|
100
|
+
this._feeDecimals = 8;
|
|
101
|
+
this.feeDecimals = Promise.resolve(this._feeDecimals);
|
|
102
|
+
this._identifier = ProtocolSymbols_1.MainProtocolSymbols.BTC;
|
|
103
|
+
this.identifier = Promise.resolve(this._identifier);
|
|
104
|
+
this._units = [
|
|
98
105
|
{
|
|
99
106
|
unitSymbol: 'BTC',
|
|
100
107
|
factor: '1'
|
|
@@ -108,24 +115,31 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
108
115
|
factor: '0.00000001'
|
|
109
116
|
}
|
|
110
117
|
];
|
|
111
|
-
this.
|
|
112
|
-
this.
|
|
113
|
-
this.
|
|
114
|
-
this.
|
|
115
|
-
this.
|
|
118
|
+
this.units = Promise.resolve(this._units);
|
|
119
|
+
this._supportsHD = true;
|
|
120
|
+
this.supportsHD = Promise.resolve(this._supportsHD);
|
|
121
|
+
this._standardDerivationPath = "m/44'/0'/0'";
|
|
122
|
+
this.standardDerivationPath = Promise.resolve(this._standardDerivationPath);
|
|
123
|
+
this._addressIsCaseSensitive = true;
|
|
124
|
+
this.addressIsCaseSensitive = Promise.resolve(this._addressIsCaseSensitive);
|
|
125
|
+
this._addressValidationPattern = '^(?:[13]{1}[a-km-zA-HJ-NP-Z1-9]{25,34}|bc1[a-z0-9]{39,59})$';
|
|
126
|
+
this.addressValidationPattern = Promise.resolve(this._addressValidationPattern);
|
|
127
|
+
this._addressPlaceholder = '1ABC...';
|
|
128
|
+
this.addressPlaceholder = Promise.resolve(this._addressPlaceholder);
|
|
129
|
+
this.options = Promise.resolve(this._options);
|
|
116
130
|
this.cryptoClient = new BitcoinCryptoClient_1.BitcoinCryptoClient(this, bitcoinJSMessage);
|
|
117
131
|
}
|
|
118
132
|
BitcoinProtocol.prototype.getBlockExplorerLinkForAddress = function (address) {
|
|
119
133
|
return __awaiter(this, void 0, void 0, function () {
|
|
120
134
|
return __generator(this, function (_a) {
|
|
121
|
-
return [2 /*return*/, this.
|
|
135
|
+
return [2 /*return*/, this._options.network.blockExplorer.getAddressLink(address)];
|
|
122
136
|
});
|
|
123
137
|
});
|
|
124
138
|
};
|
|
125
139
|
BitcoinProtocol.prototype.getBlockExplorerLinkForTxId = function (txId) {
|
|
126
140
|
return __awaiter(this, void 0, void 0, function () {
|
|
127
141
|
return __generator(this, function (_a) {
|
|
128
|
-
return [2 /*return*/, this.
|
|
142
|
+
return [2 /*return*/, this._options.network.blockExplorer.getTransactionLink(txId)];
|
|
129
143
|
});
|
|
130
144
|
});
|
|
131
145
|
};
|
|
@@ -160,7 +174,7 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
160
174
|
return __awaiter(this, void 0, void 0, function () {
|
|
161
175
|
var bitcoinNode;
|
|
162
176
|
return __generator(this, function (_a) {
|
|
163
|
-
bitcoinNode = this.
|
|
177
|
+
bitcoinNode = this._options.config.bitcoinJSLib.HDNode.fromSeedHex(secret, this._options.network.extras.network);
|
|
164
178
|
return [2 /*return*/, bitcoinNode.derivePath(derivationPath).neutered().toBase58()];
|
|
165
179
|
});
|
|
166
180
|
});
|
|
@@ -169,8 +183,8 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
169
183
|
return __awaiter(this, void 0, void 0, function () {
|
|
170
184
|
var bitcoinNode;
|
|
171
185
|
return __generator(this, function (_a) {
|
|
172
|
-
bitcoinNode = this.
|
|
173
|
-
return [2 /*return*/, bitcoinNode.derivePath(derivationPath).keyPair.d.toBuffer(32)];
|
|
186
|
+
bitcoinNode = this._options.config.bitcoinJSLib.HDNode.fromSeedHex(secret, this._options.network.extras.network);
|
|
187
|
+
return [2 /*return*/, bitcoinNode.derivePath(derivationPath).keyPair.d.toBuffer(32).toString('hex')];
|
|
174
188
|
});
|
|
175
189
|
});
|
|
176
190
|
};
|
|
@@ -178,25 +192,29 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
178
192
|
return __awaiter(this, void 0, void 0, function () {
|
|
179
193
|
var bitcoinNode;
|
|
180
194
|
return __generator(this, function (_a) {
|
|
181
|
-
bitcoinNode = this.
|
|
195
|
+
bitcoinNode = this._options.config.bitcoinJSLib.HDNode.fromSeedHex(secret, this._options.network.extras.network);
|
|
182
196
|
return [2 /*return*/, bitcoinNode.derivePath(derivationPath).toBase58()];
|
|
183
197
|
});
|
|
184
198
|
});
|
|
185
199
|
};
|
|
186
|
-
BitcoinProtocol.prototype.getAddressFromPublicKey = function (publicKey) {
|
|
200
|
+
BitcoinProtocol.prototype.getAddressFromPublicKey = function (publicKey, cursor) {
|
|
187
201
|
return __awaiter(this, void 0, void 0, function () {
|
|
188
|
-
var node;
|
|
202
|
+
var node, address;
|
|
189
203
|
return __generator(this, function (_a) {
|
|
190
|
-
node = this.
|
|
191
|
-
|
|
204
|
+
node = this._options.config.bitcoinJSLib.HDNode.fromBase58(publicKey, this._options.network.extras.network);
|
|
205
|
+
address = BitcoinAddress_1.BitcoinAddress.from(node);
|
|
206
|
+
return [2 /*return*/, {
|
|
207
|
+
address: address.asString(),
|
|
208
|
+
cursor: { hasNext: false }
|
|
209
|
+
}];
|
|
192
210
|
});
|
|
193
211
|
});
|
|
194
212
|
};
|
|
195
|
-
BitcoinProtocol.prototype.getAddressesFromPublicKey = function (publicKey) {
|
|
213
|
+
BitcoinProtocol.prototype.getAddressesFromPublicKey = function (publicKey, cursor) {
|
|
196
214
|
return __awaiter(this, void 0, void 0, function () {
|
|
197
215
|
return __generator(this, function (_a) {
|
|
198
216
|
switch (_a.label) {
|
|
199
|
-
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
217
|
+
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey, cursor)];
|
|
200
218
|
case 1: return [2 /*return*/, [_a.sent()]];
|
|
201
219
|
}
|
|
202
220
|
});
|
|
@@ -204,10 +222,14 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
204
222
|
};
|
|
205
223
|
BitcoinProtocol.prototype.getAddressFromExtendedPublicKey = function (extendedPublicKey, visibilityDerivationIndex, addressDerivationIndex) {
|
|
206
224
|
return __awaiter(this, void 0, void 0, function () {
|
|
207
|
-
var node;
|
|
225
|
+
var node, address;
|
|
208
226
|
return __generator(this, function (_a) {
|
|
209
|
-
node = this.
|
|
210
|
-
|
|
227
|
+
node = this._options.config.bitcoinJSLib.HDNode.fromBase58(extendedPublicKey, this._options.network.extras.network);
|
|
228
|
+
address = BitcoinAddress_1.BitcoinAddress.from(node, visibilityDerivationIndex, addressDerivationIndex);
|
|
229
|
+
return [2 /*return*/, {
|
|
230
|
+
address: address.asString(),
|
|
231
|
+
cursor: { hasNext: false }
|
|
232
|
+
}];
|
|
211
233
|
});
|
|
212
234
|
});
|
|
213
235
|
};
|
|
@@ -215,18 +237,15 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
215
237
|
return __awaiter(this, void 0, void 0, function () {
|
|
216
238
|
var node, generatorArray;
|
|
217
239
|
return __generator(this, function (_a) {
|
|
218
|
-
node = this.
|
|
240
|
+
node = this._options.config.bitcoinJSLib.HDNode.fromBase58(extendedPublicKey, this._options.network.extras.network);
|
|
219
241
|
generatorArray = Array.from(new Array(addressCount), function (_, i) { return i + offset; });
|
|
220
|
-
return [2 /*return*/, Promise.all(generatorArray.map(function (x) {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
return __generator(this, function (_a) {
|
|
228
|
-
node = this.options.config.bitcoinJSLib.HDNode.fromBase58(publicKey, this.options.network.extras.network);
|
|
229
|
-
return [2 /*return*/, BitcoinAddress_1.BitcoinAddress.from(node, current.visibilityDerivationIndex, current.addressDerivationIndex !== undefined ? current.addressDerivationIndex + 1 : undefined)];
|
|
242
|
+
return [2 /*return*/, Promise.all(generatorArray.map(function (x) {
|
|
243
|
+
var address = BitcoinAddress_1.BitcoinAddress.from(node, visibilityDerivationIndex, x);
|
|
244
|
+
return {
|
|
245
|
+
address: address.asString(),
|
|
246
|
+
cursor: { hasNext: false }
|
|
247
|
+
};
|
|
248
|
+
}))];
|
|
230
249
|
});
|
|
231
250
|
});
|
|
232
251
|
};
|
|
@@ -236,7 +255,7 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
236
255
|
return __generator(this, function (_d) {
|
|
237
256
|
switch (_d.label) {
|
|
238
257
|
case 0:
|
|
239
|
-
transactionBuilder = new this.
|
|
258
|
+
transactionBuilder = new this._options.config.bitcoinJSLib.TransactionBuilder(this._options.network.extras.network);
|
|
240
259
|
for (_i = 0, _a = transaction.ins; _i < _a.length; _i++) {
|
|
241
260
|
input = _a[_i];
|
|
242
261
|
transactionBuilder.addInput(input.txId, input.vout);
|
|
@@ -247,9 +266,9 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
247
266
|
if (!(_b < _c.length)) return [3 /*break*/, 5];
|
|
248
267
|
output = _c[_b];
|
|
249
268
|
if (!output.isChange) return [3 /*break*/, 3];
|
|
250
|
-
return [4 /*yield*/, this.getAddressFromPublicKey(privateKey
|
|
269
|
+
return [4 /*yield*/, this.getAddressFromPublicKey(privateKey)];
|
|
251
270
|
case 2:
|
|
252
|
-
generatedChangeAddress = (_d.sent()).
|
|
271
|
+
generatedChangeAddress = (_d.sent()).address;
|
|
253
272
|
if (generatedChangeAddress !== output.recipient) {
|
|
254
273
|
throw new errors_1.ConditionViolationError(coinlib_error_1.Domain.BITCOIN, 'Change address could not be verified.');
|
|
255
274
|
}
|
|
@@ -262,7 +281,7 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
262
281
|
return [3 /*break*/, 1];
|
|
263
282
|
case 5:
|
|
264
283
|
for (i = 0; i < transaction.ins.length; i++) {
|
|
265
|
-
transactionBuilder.sign(i, privateKey);
|
|
284
|
+
transactionBuilder.sign(i, Buffer.from(privateKey, 'hex'));
|
|
266
285
|
}
|
|
267
286
|
return [2 /*return*/, transactionBuilder.build().toHex()];
|
|
268
287
|
}
|
|
@@ -275,8 +294,8 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
275
294
|
return __generator(this, function (_d) {
|
|
276
295
|
switch (_d.label) {
|
|
277
296
|
case 0:
|
|
278
|
-
transactionBuilder = new this.
|
|
279
|
-
node = this.
|
|
297
|
+
transactionBuilder = new this._options.config.bitcoinJSLib.TransactionBuilder(this._options.network.extras.network);
|
|
298
|
+
node = this._options.config.bitcoinJSLib.HDNode.fromBase58(extendedPrivateKey, this._options.network.extras.network);
|
|
280
299
|
for (_i = 0, _a = transaction.ins; _i < _a.length; _i++) {
|
|
281
300
|
input = _a[_i];
|
|
282
301
|
transactionBuilder.addInput(input.txId, input.vout);
|
|
@@ -293,7 +312,7 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
293
312
|
if (!output.derivationPath) return [3 /*break*/, 3];
|
|
294
313
|
return [4 /*yield*/, this.getAddressesFromExtendedPublicKey(extendedPrivateKey, 1, 1, parseInt(output.derivationPath, 10))];
|
|
295
314
|
case 2:
|
|
296
|
-
generatedChangeAddress = (_d.sent()).map(function (address) { return address.
|
|
315
|
+
generatedChangeAddress = (_d.sent()).map(function (address) { return address.address; });
|
|
297
316
|
changeAddressIsValid = generatedChangeAddress.includes(output.recipient);
|
|
298
317
|
return [3 /*break*/, 7];
|
|
299
318
|
case 3:
|
|
@@ -303,7 +322,7 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
303
322
|
if (!(x < changeAddressMaxAddresses)) return [3 /*break*/, 7];
|
|
304
323
|
return [4 /*yield*/, this.getAddressesFromExtendedPublicKey(extendedPrivateKey, 1, changeAddressBatchSize, x)];
|
|
305
324
|
case 5:
|
|
306
|
-
addresses = (_d.sent()).map(function (address) { return address.
|
|
325
|
+
addresses = (_d.sent()).map(function (address) { return address.address; });
|
|
307
326
|
if (addresses.indexOf(output.recipient) >= 0) {
|
|
308
327
|
changeAddressIsValid = true;
|
|
309
328
|
x = changeAddressMaxAddresses;
|
|
@@ -357,8 +376,8 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
357
376
|
.reduce(function (accumulator, currentValue) { return accumulator.plus(currentValue); })
|
|
358
377
|
.toString(10),
|
|
359
378
|
fee: feeCalculator.toString(10),
|
|
360
|
-
protocolIdentifier: this.
|
|
361
|
-
network: this.
|
|
379
|
+
protocolIdentifier: this._identifier,
|
|
380
|
+
network: this._options.network,
|
|
362
381
|
isInbound: false,
|
|
363
382
|
transactionDetails: unsignedTx.transaction,
|
|
364
383
|
warnings: warnings
|
|
@@ -377,14 +396,14 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
377
396
|
from: signedTx.from,
|
|
378
397
|
amount: signedTx.amount,
|
|
379
398
|
fee: signedTx.fee,
|
|
380
|
-
protocolIdentifier: this.
|
|
381
|
-
network: this.
|
|
399
|
+
protocolIdentifier: this._identifier,
|
|
400
|
+
network: this._options.network,
|
|
382
401
|
isInbound: false,
|
|
383
402
|
transactionDetails: signedTx.transaction
|
|
384
403
|
};
|
|
385
|
-
bitcoinTx = this.
|
|
404
|
+
bitcoinTx = this._options.config.bitcoinJSLib.Transaction.fromHex(signedTx.transaction);
|
|
386
405
|
bitcoinTx.outs.forEach(function (output) {
|
|
387
|
-
var address = _this.
|
|
406
|
+
var address = _this._options.config.bitcoinJSLib.address.fromOutputScript(output.script, _this._options.network.extras.network);
|
|
388
407
|
// only works if one output is target and rest is change, but this way we can filter out change addresses
|
|
389
408
|
if (new bignumber_1.default(output.value).isEqualTo(signedTx.amount)) {
|
|
390
409
|
tx.to.push(address);
|
|
@@ -406,7 +425,7 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
406
425
|
case 1:
|
|
407
426
|
if (!(_i < addresses_1.length)) return [3 /*break*/, 4];
|
|
408
427
|
address = addresses_1[_i];
|
|
409
|
-
return [4 /*yield*/, index_1.default.get(this.
|
|
428
|
+
return [4 /*yield*/, index_1.default.get(this._options.network.extras.indexerApi + "/api/v2/address/" + address + "?details=basic", {
|
|
410
429
|
responseType: 'json'
|
|
411
430
|
})];
|
|
412
431
|
case 2:
|
|
@@ -429,7 +448,7 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
429
448
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
430
449
|
case 1:
|
|
431
450
|
address = _a.sent();
|
|
432
|
-
return [2 /*return*/, this.getBalanceOfAddresses([address.
|
|
451
|
+
return [2 /*return*/, this.getBalanceOfAddresses([address.address])];
|
|
433
452
|
}
|
|
434
453
|
});
|
|
435
454
|
});
|
|
@@ -440,7 +459,7 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
440
459
|
var data;
|
|
441
460
|
return __generator(this, function (_a) {
|
|
442
461
|
switch (_a.label) {
|
|
443
|
-
case 0: return [4 /*yield*/, index_1.default.get(this.
|
|
462
|
+
case 0: return [4 /*yield*/, index_1.default.get(this._options.network.extras.indexerApi + "/api/v2/xpub/" + extendedPublicKey + "?pageSize=1", {
|
|
444
463
|
responseType: 'json'
|
|
445
464
|
})];
|
|
446
465
|
case 1:
|
|
@@ -483,10 +502,10 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
483
502
|
var result, estimatedFee, feeStepFactor, mediumFee, lowFee, highFee;
|
|
484
503
|
return __generator(this, function (_a) {
|
|
485
504
|
switch (_a.label) {
|
|
486
|
-
case 0: return [4 /*yield*/, index_1.default.get(this.
|
|
505
|
+
case 0: return [4 /*yield*/, index_1.default.get(this._options.network.extras.indexerApi + "/api/v2/estimatefee/5")];
|
|
487
506
|
case 1:
|
|
488
507
|
result = (_a.sent()).data.result;
|
|
489
|
-
estimatedFee = new bignumber_1.default(result).shiftedBy(this.
|
|
508
|
+
estimatedFee = new bignumber_1.default(result).shiftedBy(this._feeDecimals);
|
|
490
509
|
if (estimatedFee.isZero()) {
|
|
491
510
|
return [2 /*return*/, this.feeDefaults];
|
|
492
511
|
}
|
|
@@ -526,7 +545,7 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
526
545
|
throw new errors_1.ConditionViolationError(coinlib_error_1.Domain.BITCOIN, 'recipients do not match values');
|
|
527
546
|
}
|
|
528
547
|
return [4 /*yield*/, index_1.default
|
|
529
|
-
.get(this.
|
|
548
|
+
.get(this._options.network.extras.indexerApi + "/api/v2/utxo/" + extendedPublicKey + "?confirmed=true", {
|
|
530
549
|
responseType: 'json'
|
|
531
550
|
})
|
|
532
551
|
.catch(function (error) {
|
|
@@ -562,7 +581,7 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
562
581
|
return [4 /*yield*/, this.getAddressFromExtendedPublicKey(extendedPublicKey, indexes[0], indexes[1])];
|
|
563
582
|
case 3:
|
|
564
583
|
derivedAddress = _a.sent();
|
|
565
|
-
if (derivedAddress.
|
|
584
|
+
if (derivedAddress.address === utxo.address) {
|
|
566
585
|
transaction.ins.push({
|
|
567
586
|
txId: utxo.txid,
|
|
568
587
|
value: new bignumber_1.default(utxo.value).toString(10),
|
|
@@ -605,7 +624,7 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
605
624
|
case 6:
|
|
606
625
|
derivedAddress = _a.sent();
|
|
607
626
|
transaction.outs.push({
|
|
608
|
-
recipient: derivedAddress.
|
|
627
|
+
recipient: derivedAddress.address,
|
|
609
628
|
isChange: true,
|
|
610
629
|
value: changeValue.toString(10),
|
|
611
630
|
derivationPath: changeAddressIndex.toString()
|
|
@@ -633,8 +652,8 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
633
652
|
}
|
|
634
653
|
return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
635
654
|
case 1:
|
|
636
|
-
address = (_a.sent()).
|
|
637
|
-
return [4 /*yield*/, index_1.default.get(this.
|
|
655
|
+
address = (_a.sent()).address;
|
|
656
|
+
return [4 /*yield*/, index_1.default.get(this._options.network.extras.indexerApi + "/api/v2/utxo/" + address, {
|
|
638
657
|
responseType: 'json'
|
|
639
658
|
})];
|
|
640
659
|
case 2:
|
|
@@ -687,7 +706,7 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
687
706
|
var data;
|
|
688
707
|
return __generator(this, function (_a) {
|
|
689
708
|
switch (_a.label) {
|
|
690
|
-
case 0: return [4 /*yield*/, index_1.default.post(this.
|
|
709
|
+
case 0: return [4 /*yield*/, index_1.default.post(this._options.network.extras.indexerApi + '/api/v2/sendtx/', rawTransaction)];
|
|
691
710
|
case 1:
|
|
692
711
|
data = (_a.sent()).data;
|
|
693
712
|
return [2 /*return*/, data.result];
|
|
@@ -704,7 +723,7 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
704
723
|
switch (_g.label) {
|
|
705
724
|
case 0:
|
|
706
725
|
page = (_a = cursor === null || cursor === void 0 ? void 0 : cursor.page) !== null && _a !== void 0 ? _a : 1;
|
|
707
|
-
return [4 /*yield*/, index_1.default.get(this.
|
|
726
|
+
return [4 /*yield*/, index_1.default.get(this._options.network.extras.indexerApi +
|
|
708
727
|
'/api/v2/xpub/' +
|
|
709
728
|
extendedPublicKey +
|
|
710
729
|
("?details=txs&tokens=used&pageSize=" + limit + "&page=" + page), {
|
|
@@ -754,8 +773,8 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
754
773
|
amount: amount.toString(10),
|
|
755
774
|
fee: new bignumber_1.default(transaction.fees).toString(10),
|
|
756
775
|
blockHeight: transaction.blockHeight.toString(),
|
|
757
|
-
protocolIdentifier: this.
|
|
758
|
-
network: this.
|
|
776
|
+
protocolIdentifier: this._identifier,
|
|
777
|
+
network: this._options.network,
|
|
759
778
|
timestamp: transaction.blockTime
|
|
760
779
|
};
|
|
761
780
|
airGapTransactions.push(airGapTransaction);
|
|
@@ -779,7 +798,7 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
779
798
|
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
780
799
|
case 1:
|
|
781
800
|
address = _a.sent();
|
|
782
|
-
return [2 /*return*/, this.getTransactionsFromAddresses([address.
|
|
801
|
+
return [2 /*return*/, this.getTransactionsFromAddresses([address.address], limit, cursor)];
|
|
783
802
|
}
|
|
784
803
|
});
|
|
785
804
|
});
|
|
@@ -793,7 +812,7 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
793
812
|
case 0:
|
|
794
813
|
airGapTransactions = [];
|
|
795
814
|
page = (_a = cursor === null || cursor === void 0 ? void 0 : cursor.page) !== null && _a !== void 0 ? _a : 1;
|
|
796
|
-
url = this.
|
|
815
|
+
url = this._options.network.extras.indexerApi + "/api/v2/address/" + addresses[0] + "?page=" + page + "&pageSize=" + limit + "&details=txs";
|
|
797
816
|
return [4 /*yield*/, index_1.default.get(url, {
|
|
798
817
|
responseType: 'json'
|
|
799
818
|
})];
|
|
@@ -839,8 +858,8 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
839
858
|
amount: amount.toString(10),
|
|
840
859
|
fee: new bignumber_1.default(transaction.fees).toString(10),
|
|
841
860
|
blockHeight: transaction.blockHeight.toString(),
|
|
842
|
-
protocolIdentifier: this.
|
|
843
|
-
network: this.
|
|
861
|
+
protocolIdentifier: this._identifier,
|
|
862
|
+
network: this._options.network,
|
|
844
863
|
timestamp: transaction.blockTime
|
|
845
864
|
};
|
|
846
865
|
airGapTransactions.push(airGapTransaction);
|
|
@@ -883,7 +902,7 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
883
902
|
return __awaiter(this, void 0, void 0, function () {
|
|
884
903
|
var childPublicKey;
|
|
885
904
|
return __generator(this, function (_a) {
|
|
886
|
-
childPublicKey = this.
|
|
905
|
+
childPublicKey = this._options.config.bitcoinJSLib.HDNode.fromBase58(publicKey, this._options.network.extras.network)
|
|
887
906
|
.derive(0)
|
|
888
907
|
.derive(0)
|
|
889
908
|
.getPublicKeyBuffer();
|
|
@@ -895,11 +914,11 @@ var BitcoinProtocol = /** @class */ (function () {
|
|
|
895
914
|
return __awaiter(this, void 0, void 0, function () {
|
|
896
915
|
var childPrivateKey;
|
|
897
916
|
return __generator(this, function (_a) {
|
|
898
|
-
childPrivateKey = this.
|
|
917
|
+
childPrivateKey = this._options.config.bitcoinJSLib.HDNode.fromBase58(keypair.privateKey, this._options.network.extras.network)
|
|
899
918
|
.derive(0)
|
|
900
919
|
.derive(0)
|
|
901
920
|
.keyPair.d.toBuffer(32);
|
|
902
|
-
return [2 /*return*/, this.cryptoClient.decryptAsymmetric(message, { publicKey: '', privateKey: childPrivateKey })];
|
|
921
|
+
return [2 /*return*/, this.cryptoClient.decryptAsymmetric(message, { publicKey: '', privateKey: childPrivateKey.toString('hex') })];
|
|
903
922
|
});
|
|
904
923
|
});
|
|
905
924
|
};
|