@bitpay-labs/bitcore-client 11.5.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/README.md +131 -0
- package/bin/multi-sig/wallet-derive-address +149 -0
- package/bin/wallet +31 -0
- package/bin/wallet-balance +62 -0
- package/bin/wallet-balance-all +77 -0
- package/bin/wallet-broadcast +35 -0
- package/bin/wallet-bump-tx +65 -0
- package/bin/wallet-check +62 -0
- package/bin/wallet-create +46 -0
- package/bin/wallet-decrypt +31 -0
- package/bin/wallet-delete +21 -0
- package/bin/wallet-derive +70 -0
- package/bin/wallet-flags +84 -0
- package/bin/wallet-import +80 -0
- package/bin/wallet-list +31 -0
- package/bin/wallet-paypro +175 -0
- package/bin/wallet-register +29 -0
- package/bin/wallet-send +146 -0
- package/bin/wallet-sign +64 -0
- package/bin/wallet-sign-message +55 -0
- package/bin/wallet-storage +79 -0
- package/bin/wallet-token +73 -0
- package/bin/wallet-token-rm +33 -0
- package/bin/wallet-tx +106 -0
- package/bin/wallet-tx-list +92 -0
- package/bin/wallet-utxos +28 -0
- package/package.json +71 -0
- package/src/client.ts +271 -0
- package/src/encryption.ts +139 -0
- package/src/index.ts +21 -0
- package/src/storage/level.ts +171 -0
- package/src/storage/mongo.ts +187 -0
- package/src/storage/textFile.ts +250 -0
- package/src/storage.ts +192 -0
- package/src/stream-util.ts +80 -0
- package/src/types/index.d.ts +2 -0
- package/src/types/storage.d.ts +1 -0
- package/src/types/wallet.d.ts +36 -0
- package/src/utils.ts +35 -0
- package/src/wallet.ts +983 -0
- package/test/unit/wallet.test.ts +552 -0
- package/ts_build/src/client.d.ts +77 -0
- package/ts_build/src/client.d.ts.map +1 -0
- package/ts_build/src/client.js +280 -0
- package/ts_build/src/client.js.map +1 -0
- package/ts_build/src/encryption.d.ts +27 -0
- package/ts_build/src/encryption.d.ts.map +1 -0
- package/ts_build/src/encryption.js +130 -0
- package/ts_build/src/encryption.js.map +1 -0
- package/ts_build/src/index.d.ts +11 -0
- package/ts_build/src/index.d.ts.map +1 -0
- package/ts_build/src/index.js +55 -0
- package/ts_build/src/index.js.map +1 -0
- package/ts_build/src/storage/level.d.ts +48 -0
- package/ts_build/src/storage/level.d.ts.map +1 -0
- package/ts_build/src/storage/level.js +194 -0
- package/ts_build/src/storage/level.js.map +1 -0
- package/ts_build/src/storage/mongo.d.ts +62 -0
- package/ts_build/src/storage/mongo.d.ts.map +1 -0
- package/ts_build/src/storage/mongo.js +173 -0
- package/ts_build/src/storage/mongo.js.map +1 -0
- package/ts_build/src/storage/textFile.d.ts +53 -0
- package/ts_build/src/storage/textFile.d.ts.map +1 -0
- package/ts_build/src/storage/textFile.js +268 -0
- package/ts_build/src/storage/textFile.js.map +1 -0
- package/ts_build/src/storage.d.ts +63 -0
- package/ts_build/src/storage.d.ts.map +1 -0
- package/ts_build/src/storage.js +172 -0
- package/ts_build/src/storage.js.map +1 -0
- package/ts_build/src/stream-util.d.ts +15 -0
- package/ts_build/src/stream-util.d.ts.map +1 -0
- package/ts_build/src/stream-util.js +81 -0
- package/ts_build/src/stream-util.js.map +1 -0
- package/ts_build/src/utils.d.ts +8 -0
- package/ts_build/src/utils.d.ts.map +1 -0
- package/ts_build/src/utils.js +37 -0
- package/ts_build/src/utils.js.map +1 -0
- package/ts_build/src/wallet.d.ts +229 -0
- package/ts_build/src/wallet.d.ts.map +1 -0
- package/ts_build/src/wallet.js +806 -0
- package/ts_build/src/wallet.js.map +1 -0
- package/ts_build/test/unit/wallet.test.d.ts +2 -0
- package/ts_build/test/unit/wallet.test.d.ts.map +1 -0
- package/ts_build/test/unit/wallet.test.js +533 -0
- package/ts_build/test/unit/wallet.test.js.map +1 -0
- package/tsconfig.json +40 -0
- package/tsconfig.prod.json +6 -0
|
@@ -0,0 +1,806 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.AddressTypes = exports.Wallet = void 0;
|
|
40
|
+
require("source-map-support/register");
|
|
41
|
+
const bitcore_mnemonic_1 = __importDefault(require("@bitpay-labs/bitcore-mnemonic"));
|
|
42
|
+
const crypto_wallet_core_1 = require("@bitpay-labs/crypto-wallet-core");
|
|
43
|
+
const Bcrypt = __importStar(require("bcrypt"));
|
|
44
|
+
const client_1 = require("./client");
|
|
45
|
+
const encryption_1 = require("./encryption");
|
|
46
|
+
const storage_1 = require("./storage");
|
|
47
|
+
const stream_util_1 = require("./stream-util");
|
|
48
|
+
const { PrivateKey, HDPrivateKey } = crypto_wallet_core_1.BitcoreLib;
|
|
49
|
+
const chainLibs = {
|
|
50
|
+
BTC: crypto_wallet_core_1.BitcoreLib,
|
|
51
|
+
BCH: crypto_wallet_core_1.BitcoreLibCash,
|
|
52
|
+
DOGE: crypto_wallet_core_1.BitcoreLibDoge,
|
|
53
|
+
LTC: crypto_wallet_core_1.BitcoreLibLtc,
|
|
54
|
+
ETH: { Web3: crypto_wallet_core_1.Web3, ethers: crypto_wallet_core_1.ethers },
|
|
55
|
+
MATIC: { Web3: crypto_wallet_core_1.Web3, ethers: crypto_wallet_core_1.ethers },
|
|
56
|
+
ARB: { Web3: crypto_wallet_core_1.Web3, ethers: crypto_wallet_core_1.ethers },
|
|
57
|
+
BASE: { Web3: crypto_wallet_core_1.Web3, ethers: crypto_wallet_core_1.ethers },
|
|
58
|
+
OP: { Web3: crypto_wallet_core_1.Web3, ethers: crypto_wallet_core_1.ethers },
|
|
59
|
+
XRP: crypto_wallet_core_1.xrpl,
|
|
60
|
+
SOL: { SolKit: crypto_wallet_core_1.SolKit, SolanaProgram: crypto_wallet_core_1.SolanaProgram }
|
|
61
|
+
};
|
|
62
|
+
class Wallet {
|
|
63
|
+
constructor(params) {
|
|
64
|
+
Object.assign(this, params);
|
|
65
|
+
if (!this.baseUrl) {
|
|
66
|
+
this.baseUrl = 'https://api.bitcore.io/api';
|
|
67
|
+
}
|
|
68
|
+
this.client = new client_1.Client({
|
|
69
|
+
apiUrl: this.getApiUrl(),
|
|
70
|
+
authKey: this.getAuthSigningKey()
|
|
71
|
+
});
|
|
72
|
+
this.addressIndex = this.addressIndex || 0;
|
|
73
|
+
this.addressType = exports.AddressTypes[this.chain]?.[this.addressType] || 'pubkeyhash';
|
|
74
|
+
if (params.lite) {
|
|
75
|
+
delete this.masterKey;
|
|
76
|
+
delete this.pubKey;
|
|
77
|
+
this.lite = true;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
getApiUrl() {
|
|
81
|
+
return `${this.baseUrl}/${this.chain}/${this.network}`;
|
|
82
|
+
}
|
|
83
|
+
getLib() {
|
|
84
|
+
return chainLibs[this.chain.toUpperCase()];
|
|
85
|
+
}
|
|
86
|
+
saveWallet() {
|
|
87
|
+
const walletInstance = Object.assign({}, this);
|
|
88
|
+
delete walletInstance.unlocked;
|
|
89
|
+
if (walletInstance.masterKey) {
|
|
90
|
+
walletInstance.lite = false;
|
|
91
|
+
}
|
|
92
|
+
return this.storage.saveWallet({ wallet: walletInstance });
|
|
93
|
+
}
|
|
94
|
+
toObject(lite = this.lite) {
|
|
95
|
+
return {
|
|
96
|
+
name: this.name,
|
|
97
|
+
chain: this.chain,
|
|
98
|
+
network: this.network,
|
|
99
|
+
path: this.path,
|
|
100
|
+
baseUrl: this.baseUrl,
|
|
101
|
+
encryptionKey: this.encryptionKey,
|
|
102
|
+
authKey: this.authKey,
|
|
103
|
+
authPubKey: this.authPubKey,
|
|
104
|
+
masterKey: lite ? undefined : this.masterKey,
|
|
105
|
+
password: Bcrypt.hashSync(this.password, 10),
|
|
106
|
+
xPubKey: this.xPubKey,
|
|
107
|
+
pubKey: lite ? undefined : this.pubKey,
|
|
108
|
+
tokens: this.tokens,
|
|
109
|
+
storageType: this.storageType,
|
|
110
|
+
lite,
|
|
111
|
+
addressType: this.addressType,
|
|
112
|
+
addressZero: this.addressZero
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
static async deleteWallet(params) {
|
|
116
|
+
const { name, path, storageType } = params;
|
|
117
|
+
let { storage } = params;
|
|
118
|
+
storage = storage || new storage_1.Storage({ errorIfExists: false, createIfMissing: false, path, storageType });
|
|
119
|
+
await storage.deleteWallet({ name });
|
|
120
|
+
}
|
|
121
|
+
static async create(params) {
|
|
122
|
+
const { network, name, phrase, xpriv, password, path, lite, baseUrl } = params;
|
|
123
|
+
let { chain, storageType, storage, addressType } = params;
|
|
124
|
+
if (phrase && xpriv) {
|
|
125
|
+
throw new Error('You can only provide either a phrase or a xpriv, not both');
|
|
126
|
+
}
|
|
127
|
+
if (!chain || !network || !name) {
|
|
128
|
+
throw new Error('Missing required parameter');
|
|
129
|
+
}
|
|
130
|
+
chain = chain.toUpperCase();
|
|
131
|
+
if (addressType && exports.AddressTypes[chain] && !exports.AddressTypes[chain]?.[addressType]) {
|
|
132
|
+
throw new Error(`Invalid --addressType for chain. Valid address types are: ${Object.keys(exports.AddressTypes[chain]).join(' | ')}`);
|
|
133
|
+
}
|
|
134
|
+
addressType = exports.AddressTypes[chain]?.[addressType] || 'pubkeyhash';
|
|
135
|
+
let hdPrivKey;
|
|
136
|
+
let mnemonic;
|
|
137
|
+
if (xpriv) {
|
|
138
|
+
hdPrivKey = new HDPrivateKey(xpriv, network);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
mnemonic = new bitcore_mnemonic_1.default(phrase);
|
|
142
|
+
const algo = crypto_wallet_core_1.Constants.ALGOS_BY_CHAIN[chain] || crypto_wallet_core_1.Constants.ALGOS_BY_CHAIN['default'];
|
|
143
|
+
const keyType = crypto_wallet_core_1.Constants.ALGO_TO_KEY_TYPE[algo];
|
|
144
|
+
hdPrivKey = mnemonic.toHDPrivateKey('', network).derive(crypto_wallet_core_1.Deriver.pathFor(chain, network), keyType);
|
|
145
|
+
}
|
|
146
|
+
const privKeyObj = hdPrivKey.toObject();
|
|
147
|
+
const authKey = new PrivateKey();
|
|
148
|
+
const authPubKey = authKey.toPublicKey().toString();
|
|
149
|
+
const pubKey = hdPrivKey.publicKey.toString();
|
|
150
|
+
const walletEncryptionKey = encryption_1.Encryption.generateEncryptionKey();
|
|
151
|
+
const encryptionKey = encryption_1.Encryption.encryptEncryptionKey(walletEncryptionKey, password);
|
|
152
|
+
const encPrivateKey = encryption_1.Encryption.encryptPrivateKey(JSON.stringify(privKeyObj), pubKey, walletEncryptionKey);
|
|
153
|
+
storageType = storageType ? storageType : 'Level';
|
|
154
|
+
storage =
|
|
155
|
+
storage ||
|
|
156
|
+
new storage_1.Storage({
|
|
157
|
+
path,
|
|
158
|
+
errorIfExists: false,
|
|
159
|
+
createIfMissing: true,
|
|
160
|
+
storageType
|
|
161
|
+
});
|
|
162
|
+
let alreadyExists;
|
|
163
|
+
try {
|
|
164
|
+
alreadyExists = await this.loadWallet({ storage, name, storageType });
|
|
165
|
+
}
|
|
166
|
+
catch { }
|
|
167
|
+
if (alreadyExists) {
|
|
168
|
+
throw new Error('Wallet already exists');
|
|
169
|
+
}
|
|
170
|
+
const wallet = new Wallet({
|
|
171
|
+
name,
|
|
172
|
+
chain,
|
|
173
|
+
network,
|
|
174
|
+
path,
|
|
175
|
+
baseUrl,
|
|
176
|
+
encryptionKey,
|
|
177
|
+
authKey,
|
|
178
|
+
authPubKey,
|
|
179
|
+
masterKey: encPrivateKey,
|
|
180
|
+
password,
|
|
181
|
+
xPubKey: hdPrivKey.xpubkey,
|
|
182
|
+
pubKey,
|
|
183
|
+
tokens: [],
|
|
184
|
+
storage,
|
|
185
|
+
storageType,
|
|
186
|
+
lite,
|
|
187
|
+
addressType,
|
|
188
|
+
addressZero: null
|
|
189
|
+
});
|
|
190
|
+
await storage.saveWallet({ wallet: wallet.toObject(lite) });
|
|
191
|
+
const loadedWallet = await this.loadWallet({
|
|
192
|
+
storage,
|
|
193
|
+
name,
|
|
194
|
+
storageType
|
|
195
|
+
});
|
|
196
|
+
if (!xpriv) {
|
|
197
|
+
console.log(mnemonic.toString());
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
console.log(hdPrivKey.toString());
|
|
201
|
+
}
|
|
202
|
+
await loadedWallet.register().catch(e => {
|
|
203
|
+
console.debug(e);
|
|
204
|
+
console.error('Failed to register wallet with bitcore-node.');
|
|
205
|
+
});
|
|
206
|
+
return loadedWallet;
|
|
207
|
+
}
|
|
208
|
+
static async exists(params) {
|
|
209
|
+
const { storage, name } = params;
|
|
210
|
+
let alreadyExists;
|
|
211
|
+
try {
|
|
212
|
+
alreadyExists = await Wallet.loadWallet({
|
|
213
|
+
storage,
|
|
214
|
+
name
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
catch (err) {
|
|
218
|
+
console.log(err);
|
|
219
|
+
}
|
|
220
|
+
return alreadyExists != undefined && alreadyExists.length && alreadyExists.length != 0;
|
|
221
|
+
}
|
|
222
|
+
static async loadWallet(params) {
|
|
223
|
+
const { name, path, storageType } = params;
|
|
224
|
+
let { storage } = params;
|
|
225
|
+
storage = storage || new storage_1.Storage({ errorIfExists: false, createIfMissing: false, path, storageType });
|
|
226
|
+
const loadedWallet = await storage.loadWallet({ name });
|
|
227
|
+
if (loadedWallet) {
|
|
228
|
+
return new Wallet(Object.assign(loadedWallet, { storage }));
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
throw new Error('No wallet could be found');
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
isUtxoChain() {
|
|
235
|
+
return ['BTC', 'BCH', 'DOGE', 'LTC'].includes(this.chain?.toUpperCase() || 'BTC');
|
|
236
|
+
}
|
|
237
|
+
isEvmChain() {
|
|
238
|
+
return ['ETH', 'MATIC', 'ARB', 'OP', 'BASE'].includes(this.chain?.toUpperCase());
|
|
239
|
+
}
|
|
240
|
+
isSolanaChain() {
|
|
241
|
+
return ['SOL'].includes(this.chain?.toUpperCase());
|
|
242
|
+
}
|
|
243
|
+
lock() {
|
|
244
|
+
this.unlocked = undefined;
|
|
245
|
+
return this;
|
|
246
|
+
}
|
|
247
|
+
async unlock(password) {
|
|
248
|
+
const validPass = await Bcrypt.compare(password, this.password).catch(() => false);
|
|
249
|
+
if (!validPass) {
|
|
250
|
+
throw new Error('Incorrect Password');
|
|
251
|
+
}
|
|
252
|
+
const encryptionKey = await encryption_1.Encryption.decryptEncryptionKey(this.encryptionKey, password);
|
|
253
|
+
let masterKey;
|
|
254
|
+
if (!this.lite) {
|
|
255
|
+
const encMasterKey = this.masterKey;
|
|
256
|
+
const masterKeyStr = await encryption_1.Encryption.decryptPrivateKey(encMasterKey, this.pubKey, encryptionKey);
|
|
257
|
+
masterKey = JSON.parse(masterKeyStr);
|
|
258
|
+
}
|
|
259
|
+
this.unlocked = {
|
|
260
|
+
encryptionKey,
|
|
261
|
+
masterKey
|
|
262
|
+
};
|
|
263
|
+
return this;
|
|
264
|
+
}
|
|
265
|
+
async register(params = {}) {
|
|
266
|
+
const { baseUrl } = params;
|
|
267
|
+
if (baseUrl) {
|
|
268
|
+
this.baseUrl = baseUrl;
|
|
269
|
+
await this.saveWallet();
|
|
270
|
+
}
|
|
271
|
+
const payload = {
|
|
272
|
+
name: this.name,
|
|
273
|
+
pubKey: this.authPubKey,
|
|
274
|
+
path: this.derivationPath,
|
|
275
|
+
network: this.network,
|
|
276
|
+
chain: this.chain,
|
|
277
|
+
apiUrl: this.getApiUrl()
|
|
278
|
+
};
|
|
279
|
+
return this.client.register({ payload });
|
|
280
|
+
}
|
|
281
|
+
getAuthSigningKey() {
|
|
282
|
+
return new PrivateKey(this.authKey);
|
|
283
|
+
}
|
|
284
|
+
getBalance(params = {}) {
|
|
285
|
+
const { time, token, tokenName, address, hex } = params;
|
|
286
|
+
let payload;
|
|
287
|
+
if (token || tokenName) {
|
|
288
|
+
const tokenObj = this.getTokenObj({ token, tokenName });
|
|
289
|
+
payload = {
|
|
290
|
+
tokenContractAddress: tokenObj.address
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
return this.client.getBalance({ payload, pubKey: this.authPubKey, time, address, hex });
|
|
294
|
+
}
|
|
295
|
+
getNetworkFee(params = {}) {
|
|
296
|
+
const target = params.target || 2;
|
|
297
|
+
const txType = params.txType;
|
|
298
|
+
return this.client.getFee({ target, txType });
|
|
299
|
+
}
|
|
300
|
+
getNetworkPriorityFee(params = {}) {
|
|
301
|
+
const percentile = params.percentile;
|
|
302
|
+
return this.client.getPriorityFee({ percentile });
|
|
303
|
+
}
|
|
304
|
+
getUtxos(params = {}) {
|
|
305
|
+
const { includeSpent = false } = params;
|
|
306
|
+
return this.client.getCoins({
|
|
307
|
+
pubKey: this.authPubKey,
|
|
308
|
+
includeSpent
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
getUtxosArray(params = {}) {
|
|
312
|
+
return new Promise((resolve, reject) => {
|
|
313
|
+
const utxoArray = [];
|
|
314
|
+
const { includeSpent = false } = params;
|
|
315
|
+
const utxoRequest = this.client.getCoins({
|
|
316
|
+
pubKey: this.authPubKey,
|
|
317
|
+
includeSpent
|
|
318
|
+
});
|
|
319
|
+
utxoRequest
|
|
320
|
+
.pipe(new stream_util_1.ParseApiStream())
|
|
321
|
+
.on('data', utxo => utxoArray.push(utxo))
|
|
322
|
+
.on('end', () => resolve(utxoArray))
|
|
323
|
+
.on('err', err => reject(err));
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
getTokenObj(params) {
|
|
327
|
+
const { tokenName, token } = params || {};
|
|
328
|
+
if (!tokenName && !token) {
|
|
329
|
+
return null;
|
|
330
|
+
}
|
|
331
|
+
let tokenObj = tokenName && this.tokens.find(tok => tok.name === tokenName);
|
|
332
|
+
tokenObj = tokenObj || (token && this.tokens.find(tok => tok.symbol === token && [token, undefined].includes(tok.name)));
|
|
333
|
+
if (!tokenObj) {
|
|
334
|
+
throw new Error(`${tokenName || token} not found on wallet ${this.name}`);
|
|
335
|
+
}
|
|
336
|
+
return tokenObj;
|
|
337
|
+
}
|
|
338
|
+
listTransactions(params) {
|
|
339
|
+
const { token, tokenName } = params;
|
|
340
|
+
if (token || tokenName) {
|
|
341
|
+
const tokenObj = this.getTokenObj({ token, tokenName });
|
|
342
|
+
params.tokenContractAddress = tokenObj.address;
|
|
343
|
+
}
|
|
344
|
+
return this.client.listTransactions({
|
|
345
|
+
...params,
|
|
346
|
+
pubKey: this.authPubKey
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
async getToken(contractAddress) {
|
|
350
|
+
if (this.isSolanaChain()) {
|
|
351
|
+
const addresses = await this.client.getSolanaTokens(this.addressZero);
|
|
352
|
+
return addresses.find(addr => addr.mintAddress === contractAddress);
|
|
353
|
+
}
|
|
354
|
+
return this.client.getToken(contractAddress);
|
|
355
|
+
}
|
|
356
|
+
async addToken(params) {
|
|
357
|
+
if (!this.tokens) {
|
|
358
|
+
this.tokens = [];
|
|
359
|
+
}
|
|
360
|
+
this.tokens.push({
|
|
361
|
+
symbol: params.symbol,
|
|
362
|
+
address: params.address,
|
|
363
|
+
decimals: params.decimals,
|
|
364
|
+
name: params.name,
|
|
365
|
+
ataAddress: params.ataAddress
|
|
366
|
+
});
|
|
367
|
+
await this.saveWallet();
|
|
368
|
+
}
|
|
369
|
+
async rmToken({ tokenName }) {
|
|
370
|
+
if (!this.tokens) {
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
this.tokens = this.tokens.filter(tok => (tok.name && tok.name !== tokenName) ||
|
|
374
|
+
(!tok.name && tok.symbol !== tokenName));
|
|
375
|
+
await this.saveWallet();
|
|
376
|
+
}
|
|
377
|
+
async newTx(params) {
|
|
378
|
+
let chain = this.chain;
|
|
379
|
+
let tokenContractAddress;
|
|
380
|
+
let decimals;
|
|
381
|
+
let fromAta;
|
|
382
|
+
if (params.token || params.tokenName) {
|
|
383
|
+
chain = this.isSolanaChain() ? this.chain + 'SPL' : this.chain + 'ERC20';
|
|
384
|
+
const tokenObj = this.getTokenObj(params);
|
|
385
|
+
tokenContractAddress = tokenObj.address;
|
|
386
|
+
decimals = tokenObj.decimals;
|
|
387
|
+
fromAta = tokenObj.ataAddress;
|
|
388
|
+
}
|
|
389
|
+
let change = params.change;
|
|
390
|
+
if (change === 'miner') {
|
|
391
|
+
change = undefined;
|
|
392
|
+
}
|
|
393
|
+
else if (!change) {
|
|
394
|
+
change = await this._getChangeAddress();
|
|
395
|
+
}
|
|
396
|
+
let blockHash = params.blockHash;
|
|
397
|
+
let blockHeight = params.blockHeight;
|
|
398
|
+
if (this.isSolanaChain() && (!blockHash || !blockHeight)) {
|
|
399
|
+
const tip = await this.client.getBlockTip();
|
|
400
|
+
blockHash = tip.hash;
|
|
401
|
+
blockHeight = tip.height;
|
|
402
|
+
}
|
|
403
|
+
const payload = {
|
|
404
|
+
network: this.network,
|
|
405
|
+
chain,
|
|
406
|
+
recipients: params.recipients,
|
|
407
|
+
from: params.from,
|
|
408
|
+
change,
|
|
409
|
+
invoiceID: params.invoiceID,
|
|
410
|
+
memo: params.memo,
|
|
411
|
+
fee: params.fee,
|
|
412
|
+
feeRate: params.feeRate,
|
|
413
|
+
utxos: params.utxos,
|
|
414
|
+
nonce: params.nonce,
|
|
415
|
+
tag: params.tag,
|
|
416
|
+
gasPrice: params.gasPrice || params.feeRate || params.fee,
|
|
417
|
+
gasLimit: params.gasLimit || 200000,
|
|
418
|
+
data: params.data,
|
|
419
|
+
tokenAddress: tokenContractAddress,
|
|
420
|
+
contractAddress: params.contractAddress,
|
|
421
|
+
chainId: params.chainId,
|
|
422
|
+
replaceByFee: params.replaceByFee,
|
|
423
|
+
lockUntilBlock: params.lockUntilBlock,
|
|
424
|
+
lockUntilDate: params.lockUntilDate,
|
|
425
|
+
isSweep: params.isSweep,
|
|
426
|
+
type: params.type,
|
|
427
|
+
flags: params.flags,
|
|
428
|
+
blockHash,
|
|
429
|
+
blockHeight,
|
|
430
|
+
decimals,
|
|
431
|
+
fromAta
|
|
432
|
+
};
|
|
433
|
+
return crypto_wallet_core_1.Transactions.create(payload);
|
|
434
|
+
}
|
|
435
|
+
async createAtaAccount(mintAddress) {
|
|
436
|
+
if (!this.isSolanaChain()) {
|
|
437
|
+
throw new Error('createAtaAccount is only supported for Solana wallets');
|
|
438
|
+
}
|
|
439
|
+
const owner = crypto_wallet_core_1.SolKit.address(this.addressZero);
|
|
440
|
+
if (!mintAddress) {
|
|
441
|
+
throw new Error('mintAddress is required to create an associated token account');
|
|
442
|
+
}
|
|
443
|
+
const [newAccount] = await crypto_wallet_core_1.SolanaProgram.Token.findAssociatedTokenPda({
|
|
444
|
+
owner,
|
|
445
|
+
tokenProgram: crypto_wallet_core_1.SolanaProgram.Token.TOKEN_PROGRAM_ADDRESS,
|
|
446
|
+
mint: crypto_wallet_core_1.SolKit.address(mintAddress),
|
|
447
|
+
});
|
|
448
|
+
const tip = await this.client.getBlockTip();
|
|
449
|
+
const blockHash = tip.hash;
|
|
450
|
+
const blockHeight = tip.height;
|
|
451
|
+
const privateKey = await this.derivePrivateKey(null, 0);
|
|
452
|
+
const privKeyBytes = crypto_wallet_core_1.SolKit.getBase58Encoder().encode(privateKey.privKey);
|
|
453
|
+
const keyPair = await crypto_wallet_core_1.SolKit.createKeyPairSignerFromPrivateKeyBytes(privKeyBytes);
|
|
454
|
+
const tx = crypto_wallet_core_1.Transactions.create({
|
|
455
|
+
network: this.network,
|
|
456
|
+
chain: this.chain,
|
|
457
|
+
category: 'createata',
|
|
458
|
+
fromKeyPair: keyPair,
|
|
459
|
+
from: this.addressZero,
|
|
460
|
+
ataAddress: newAccount,
|
|
461
|
+
blockHash,
|
|
462
|
+
blockHeight,
|
|
463
|
+
mint: mintAddress,
|
|
464
|
+
});
|
|
465
|
+
const sig = await this.signTx({ tx });
|
|
466
|
+
await this.broadcast({ tx: sig });
|
|
467
|
+
return sig;
|
|
468
|
+
}
|
|
469
|
+
async broadcast(params) {
|
|
470
|
+
const { tx } = params;
|
|
471
|
+
const payload = {
|
|
472
|
+
network: this.network,
|
|
473
|
+
chain: this.chain,
|
|
474
|
+
rawTx: tx
|
|
475
|
+
};
|
|
476
|
+
return this.client.broadcast({ payload });
|
|
477
|
+
}
|
|
478
|
+
async getTransactionByTxid(params) {
|
|
479
|
+
const { txid, populated } = params;
|
|
480
|
+
return this.client.getTransaction({ txid, populated });
|
|
481
|
+
}
|
|
482
|
+
async importKeys(params) {
|
|
483
|
+
const { encryptionKey } = this.unlocked;
|
|
484
|
+
const { rederiveAddys } = params;
|
|
485
|
+
let { keys } = params;
|
|
486
|
+
let keysToSave = keys.filter(key => typeof key.privKey === 'string');
|
|
487
|
+
if (rederiveAddys) {
|
|
488
|
+
keysToSave = keysToSave.map(key => ({
|
|
489
|
+
...key,
|
|
490
|
+
address: key.pubKey ? crypto_wallet_core_1.Deriver.getAddress(this.chain, this.network, key.pubKey, this.addressType) : key.address
|
|
491
|
+
}));
|
|
492
|
+
keys = keys.map(key => ({
|
|
493
|
+
...key,
|
|
494
|
+
address: key.pubKey ? crypto_wallet_core_1.Deriver.getAddress(this.chain, this.network, key.pubKey, this.addressType) : key.address
|
|
495
|
+
}));
|
|
496
|
+
}
|
|
497
|
+
if (keysToSave.length) {
|
|
498
|
+
await this.storage.addKeys({
|
|
499
|
+
keys: keysToSave,
|
|
500
|
+
encryptionKey,
|
|
501
|
+
name: this.name
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
const addedAddresses = keys.map(key => {
|
|
505
|
+
return { address: key.address };
|
|
506
|
+
});
|
|
507
|
+
return this.client.importAddresses({
|
|
508
|
+
pubKey: this.authPubKey,
|
|
509
|
+
payload: addedAddresses
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
async signTx(params) {
|
|
513
|
+
const { tx, keys, passphrase, signingKeys, changeAddressIdx } = params;
|
|
514
|
+
const utxos = params.utxos || [];
|
|
515
|
+
if (!utxos.length) {
|
|
516
|
+
await new Promise((resolve, reject) => {
|
|
517
|
+
this.getUtxos()
|
|
518
|
+
.pipe(new stream_util_1.ParseApiStream())
|
|
519
|
+
.on('data', utxo => utxos.push(utxo))
|
|
520
|
+
.on('end', () => resolve())
|
|
521
|
+
.on('err', err => reject(err));
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
let addresses = [];
|
|
525
|
+
let decryptedKeys;
|
|
526
|
+
if (!keys && !signingKeys) {
|
|
527
|
+
for (const utxo of utxos) {
|
|
528
|
+
addresses.push(utxo.address);
|
|
529
|
+
}
|
|
530
|
+
addresses = addresses.length > 0 ? addresses : await this.getAddresses();
|
|
531
|
+
decryptedKeys = await this.storage.getKeys({
|
|
532
|
+
addresses,
|
|
533
|
+
name: this.name,
|
|
534
|
+
encryptionKey: this.unlocked.encryptionKey
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
else if (!signingKeys) {
|
|
538
|
+
addresses.push(keys[0]);
|
|
539
|
+
for (const element of utxos) {
|
|
540
|
+
const keyToDecrypt = keys.find(key => key.address === element.address);
|
|
541
|
+
addresses.push(keyToDecrypt);
|
|
542
|
+
}
|
|
543
|
+
const decryptedParams = encryption_1.Encryption.bitcoinCoreDecrypt(addresses, passphrase);
|
|
544
|
+
decryptedKeys = [...decryptedParams.jsonlDecrypted];
|
|
545
|
+
}
|
|
546
|
+
if (this.isUtxoChain()) {
|
|
547
|
+
const changeKey = await this.derivePrivateKey(true, changeAddressIdx == null ? this.addressIndex : changeAddressIdx);
|
|
548
|
+
await this.importKeys({ keys: [changeKey] });
|
|
549
|
+
}
|
|
550
|
+
const payload = {
|
|
551
|
+
chain: this.chain,
|
|
552
|
+
network: this.network,
|
|
553
|
+
tx,
|
|
554
|
+
keys: signingKeys || decryptedKeys,
|
|
555
|
+
key: signingKeys ? signingKeys[0] : decryptedKeys[0],
|
|
556
|
+
utxos
|
|
557
|
+
};
|
|
558
|
+
return crypto_wallet_core_1.Transactions.sign({ ...payload });
|
|
559
|
+
}
|
|
560
|
+
async checkWallet() {
|
|
561
|
+
return this.client.checkWallet({
|
|
562
|
+
pubKey: this.authPubKey
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
async syncAddresses(withChangeAddress = false) {
|
|
566
|
+
const addresses = new Array();
|
|
567
|
+
if (this.addressIndex !== undefined) {
|
|
568
|
+
for (let i = 0; i < this.addressIndex; i++) {
|
|
569
|
+
addresses.push(this.deriveAddress(i, false));
|
|
570
|
+
if (withChangeAddress) {
|
|
571
|
+
addresses.push(this.deriveAddress(i, true));
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
return this.client.importAddresses({
|
|
576
|
+
pubKey: this.authPubKey,
|
|
577
|
+
payload: addresses.map(a => ({ address: a }))
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
async getAddresses() {
|
|
581
|
+
const walletAddresses = await this.client.getAddresses({
|
|
582
|
+
pubKey: this.authPubKey
|
|
583
|
+
});
|
|
584
|
+
return walletAddresses.map(walletAddress => walletAddress.address);
|
|
585
|
+
}
|
|
586
|
+
async getLocalAddress(address) {
|
|
587
|
+
return this.storage.getAddress({ name: this.name, address });
|
|
588
|
+
}
|
|
589
|
+
async getLocalAddresses(limit, skip) {
|
|
590
|
+
return this.storage.getAddresses({ name: this.name, limit, skip });
|
|
591
|
+
}
|
|
592
|
+
async checkAddressOnServer(address) {
|
|
593
|
+
const walletAddresses = await this.getAddresses();
|
|
594
|
+
return !!walletAddresses.find(a => a === address);
|
|
595
|
+
}
|
|
596
|
+
deriveAddress(addressIndex, isChange) {
|
|
597
|
+
if (addressIndex === 0 && this.addressZero) {
|
|
598
|
+
return this.addressZero;
|
|
599
|
+
}
|
|
600
|
+
const address = crypto_wallet_core_1.Deriver.deriveAddress(this.chain, this.network, this.xPubKey, addressIndex, isChange, this.addressType);
|
|
601
|
+
return address;
|
|
602
|
+
}
|
|
603
|
+
async solSignMessage(privateKey, message) {
|
|
604
|
+
const privKeyBytes = crypto_wallet_core_1.SolKit.getBase58Encoder().encode(privateKey);
|
|
605
|
+
const keypair = await crypto_wallet_core_1.SolKit.createKeyPairFromPrivateKeyBytes(privKeyBytes);
|
|
606
|
+
const encodedMessage = crypto_wallet_core_1.SolKit.getUtf8Encoder().encode(message);
|
|
607
|
+
const signedBytes = await crypto_wallet_core_1.SolKit.signBytes(keypair.privateKey, encodedMessage);
|
|
608
|
+
return crypto_wallet_core_1.SolKit.getBase58Decoder().decode(signedBytes);
|
|
609
|
+
}
|
|
610
|
+
async getBlockTip() {
|
|
611
|
+
return this.client.getBlockTip();
|
|
612
|
+
}
|
|
613
|
+
async derivePrivateKey(isChange, addressIndex = this.addressIndex) {
|
|
614
|
+
const keyToImport = await crypto_wallet_core_1.Deriver.derivePrivateKey(this.chain, this.network, this.unlocked.masterKey, addressIndex || 0, isChange, this.addressType);
|
|
615
|
+
return keyToImport;
|
|
616
|
+
}
|
|
617
|
+
async nextAddressPair(withChangeAddress) {
|
|
618
|
+
return this.generateAddressPair(this.addressIndex, withChangeAddress);
|
|
619
|
+
}
|
|
620
|
+
async generateAddressPair(addressIndex, withChangeAddress) {
|
|
621
|
+
if (this.lite) {
|
|
622
|
+
return this.nextAddressPairLite(withChangeAddress);
|
|
623
|
+
}
|
|
624
|
+
addressIndex = addressIndex || 0;
|
|
625
|
+
const newPrivateKey = await this.derivePrivateKey(false, addressIndex);
|
|
626
|
+
const keys = [newPrivateKey];
|
|
627
|
+
if (withChangeAddress) {
|
|
628
|
+
const newChangePrivateKey = await this.derivePrivateKey(true, addressIndex);
|
|
629
|
+
keys.push(newChangePrivateKey);
|
|
630
|
+
}
|
|
631
|
+
if (addressIndex === this.addressIndex) {
|
|
632
|
+
this.addressIndex++;
|
|
633
|
+
}
|
|
634
|
+
await this.importKeys({ keys });
|
|
635
|
+
if (addressIndex === 0) {
|
|
636
|
+
this.addressZero = newPrivateKey.address.toString();
|
|
637
|
+
}
|
|
638
|
+
await this.saveWallet();
|
|
639
|
+
return keys.map(key => key.address.toString());
|
|
640
|
+
}
|
|
641
|
+
async nextAddressPairLite(withChangeAddress) {
|
|
642
|
+
return this.generateAddressPairLite(this.addressIndex, withChangeAddress);
|
|
643
|
+
}
|
|
644
|
+
async generateAddressPairLite(addressIndex, withChangeAddress) {
|
|
645
|
+
addressIndex = addressIndex || 0;
|
|
646
|
+
const addresses = [];
|
|
647
|
+
addresses.push(this.deriveAddress(this.addressIndex, false));
|
|
648
|
+
if (withChangeAddress) {
|
|
649
|
+
addresses.push(this.deriveAddress(this.addressIndex, true));
|
|
650
|
+
}
|
|
651
|
+
if (addressIndex === this.addressIndex) {
|
|
652
|
+
this.addressIndex++;
|
|
653
|
+
}
|
|
654
|
+
await this.client.importAddresses({
|
|
655
|
+
pubKey: this.authPubKey,
|
|
656
|
+
payload: addresses
|
|
657
|
+
});
|
|
658
|
+
await this.saveWallet();
|
|
659
|
+
return addresses;
|
|
660
|
+
}
|
|
661
|
+
async getNonce(_addressIndex = 0, isChange) {
|
|
662
|
+
const address = this.deriveAddress(0, isChange);
|
|
663
|
+
const count = await this.client.getNonce({ address });
|
|
664
|
+
if (!count || typeof count.nonce !== 'number') {
|
|
665
|
+
throw new Error('Unable to get nonce');
|
|
666
|
+
}
|
|
667
|
+
return count.nonce;
|
|
668
|
+
}
|
|
669
|
+
async _getChangeAddress() {
|
|
670
|
+
if (!this.isUtxoChain()) {
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
const key = await this.derivePrivateKey(true, this.addressIndex);
|
|
674
|
+
await this.importKeys({ keys: [key] });
|
|
675
|
+
return key.address;
|
|
676
|
+
}
|
|
677
|
+
async bumpTxFee({ txid, rawTx, changeIdx, feeRate, feeTarget, feePriority, noRbf, isSweep } = {}) {
|
|
678
|
+
if (changeIdx == null && this.isUtxoChain()) {
|
|
679
|
+
throw new Error('Must provide changeIdx for UTXO chains');
|
|
680
|
+
}
|
|
681
|
+
const lib = this.getLib();
|
|
682
|
+
let existingTx;
|
|
683
|
+
if (rawTx) {
|
|
684
|
+
if (lib.ethers) {
|
|
685
|
+
existingTx = lib.ethers.utils.parseTransaction(rawTx);
|
|
686
|
+
}
|
|
687
|
+
else {
|
|
688
|
+
const tx = new lib.Transaction(rawTx);
|
|
689
|
+
txid = tx.id;
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
if (txid) {
|
|
693
|
+
existingTx = await this.getTransactionByTxid({ txid, populated: this.isUtxoChain() });
|
|
694
|
+
}
|
|
695
|
+
else if (!existingTx) {
|
|
696
|
+
throw new Error('Must provide either rawTx or txid');
|
|
697
|
+
}
|
|
698
|
+
const params = {};
|
|
699
|
+
if (this.isUtxoChain()) {
|
|
700
|
+
const { coins: { inputs, outputs }, locktime } = existingTx;
|
|
701
|
+
params.utxos = inputs;
|
|
702
|
+
params.change = outputs.find(o => o.mintIndex == changeIdx).address;
|
|
703
|
+
params.recipients = outputs.filter(o => o.mintIndex != changeIdx).map(o => ({ address: o.address, amount: o.value }));
|
|
704
|
+
params.lockUntilBlock = locktime > 0 ? locktime : undefined;
|
|
705
|
+
params.replaceByFee = !noRbf;
|
|
706
|
+
params.isSweep = isSweep ?? outputs.length === 1;
|
|
707
|
+
if (feeRate) {
|
|
708
|
+
params.feeRate = feeRate;
|
|
709
|
+
}
|
|
710
|
+
else {
|
|
711
|
+
const scale = 1e5;
|
|
712
|
+
params.feeRate = Math.ceil((await this.getNetworkFee({ target: feeTarget })).feerate * scale);
|
|
713
|
+
console.log(`Bumping fee rate to ${params.feeRate} sats/byte`);
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
else {
|
|
717
|
+
const { nonce, gasLimit, gasPrice, to, data, value, chainId, type } = existingTx;
|
|
718
|
+
params.nonce = nonce;
|
|
719
|
+
params.gasLimit = gasLimit?.toString();
|
|
720
|
+
params.gasPrice = gasPrice;
|
|
721
|
+
params.data = data;
|
|
722
|
+
params.chainId = chainId;
|
|
723
|
+
params.type = type;
|
|
724
|
+
params.recipients = [{ address: to, amount: value.toString() }];
|
|
725
|
+
if (false && existingTx.type === 2) {
|
|
726
|
+
if (feeRate) {
|
|
727
|
+
params.maxGasFee = crypto_wallet_core_1.Web3.utils.toWei(feeRate.toString(), 'gwei');
|
|
728
|
+
}
|
|
729
|
+
else {
|
|
730
|
+
}
|
|
731
|
+
if (feePriority) {
|
|
732
|
+
params.maxPriorityFee = crypto_wallet_core_1.Web3.utils.toWei(feePriority.toString(), 'gwei');
|
|
733
|
+
}
|
|
734
|
+
else {
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
else {
|
|
738
|
+
if (feeRate) {
|
|
739
|
+
params.gasPrice = crypto_wallet_core_1.Web3.utils.toWei(feeRate.toString(), 'gwei');
|
|
740
|
+
}
|
|
741
|
+
else {
|
|
742
|
+
params.gasPrice = (await this.getNetworkFee({ target: feeTarget })).feerate;
|
|
743
|
+
console.log(`Bumping gas price to ${crypto_wallet_core_1.Web3.utils.fromWei(params.gasPrice.toString(), 'gwei')} gwei`);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
const tx = await this.newTx(params);
|
|
748
|
+
return { tx, params };
|
|
749
|
+
}
|
|
750
|
+
async getAccountFlags({ index }) {
|
|
751
|
+
const account = this.deriveAddress(index ?? 0, false);
|
|
752
|
+
return this.client.getAccountFlags({ address: account });
|
|
753
|
+
}
|
|
754
|
+
async estimateGas(params) {
|
|
755
|
+
return this.client.estimateGas(params);
|
|
756
|
+
}
|
|
757
|
+
async getL1Fee(rawTx) {
|
|
758
|
+
try {
|
|
759
|
+
return this.client.getL1Fee({ rawTx });
|
|
760
|
+
}
|
|
761
|
+
catch {
|
|
762
|
+
return 0;
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
isMainnet() {
|
|
766
|
+
return this.network === 'mainnet' || this.network === 'livenet';
|
|
767
|
+
}
|
|
768
|
+
isUnlocked() {
|
|
769
|
+
return !!this.unlocked;
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
exports.Wallet = Wallet;
|
|
773
|
+
Wallet.XrpAccountFlags = crypto_wallet_core_1.xrpl.AccountSetTfFlags;
|
|
774
|
+
exports.AddressTypes = {
|
|
775
|
+
BTC: {
|
|
776
|
+
pubkeyhash: 'pubkeyhash',
|
|
777
|
+
p2pkh: 'pubkeyhash',
|
|
778
|
+
scripthash: 'scripthash',
|
|
779
|
+
p2sh: 'scripthash',
|
|
780
|
+
witnesspubkeyhash: 'witnesspubkeyhash',
|
|
781
|
+
p2wpkh: 'witnesspubkeyhash',
|
|
782
|
+
taproot: 'taproot',
|
|
783
|
+
p2tr: 'taproot'
|
|
784
|
+
},
|
|
785
|
+
BCH: {
|
|
786
|
+
pubkeyhash: 'pubkeyhash',
|
|
787
|
+
p2pkh: 'pubkeyhash',
|
|
788
|
+
scripthash: 'scripthash',
|
|
789
|
+
p2sh: 'scripthash'
|
|
790
|
+
},
|
|
791
|
+
LTC: {
|
|
792
|
+
pubkeyhash: 'pubkeyhash',
|
|
793
|
+
p2pkh: 'pubkeyhash',
|
|
794
|
+
scripthash: 'scripthash',
|
|
795
|
+
p2sh: 'scripthash',
|
|
796
|
+
witnesspubkeyhash: 'witnesspubkeyhash',
|
|
797
|
+
p2wpkh: 'witnesspubkeyhash',
|
|
798
|
+
},
|
|
799
|
+
DOGE: {
|
|
800
|
+
pubkeyhash: 'pubkeyhash',
|
|
801
|
+
p2pkh: 'pubkeyhash',
|
|
802
|
+
scripthash: 'scripthash',
|
|
803
|
+
p2sh: 'scripthash'
|
|
804
|
+
}
|
|
805
|
+
};
|
|
806
|
+
//# sourceMappingURL=wallet.js.map
|