@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,552 @@
|
|
|
1
|
+
import * as chai from 'chai';
|
|
2
|
+
import * as CWC from '@bitpay-labs/crypto-wallet-core';
|
|
3
|
+
import { AddressTypes, Wallet } from '../../src/wallet';
|
|
4
|
+
import { Api as bcnApi } from '../../../bitcore-node/build/src/services/api';
|
|
5
|
+
import { Storage as bcnStorage } from '../../../bitcore-node/build/src/services/storage';
|
|
6
|
+
import crypto from 'crypto';
|
|
7
|
+
import { Modules } from '../../../bitcore-node/build/src/modules';
|
|
8
|
+
import request from 'request-promise-native';
|
|
9
|
+
import requestStream from 'request';
|
|
10
|
+
import { Server } from 'http';
|
|
11
|
+
import sinon from 'sinon';
|
|
12
|
+
import { StorageType } from '../../src/types/storage';
|
|
13
|
+
import supertest from 'supertest';
|
|
14
|
+
import { utils } from '../../src/utils';
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
const should = chai.should();
|
|
18
|
+
const expect = chai.expect;
|
|
19
|
+
|
|
20
|
+
const libMap = {
|
|
21
|
+
BTC: CWC.BitcoreLib,
|
|
22
|
+
BCH: CWC.BitcoreLibCash,
|
|
23
|
+
LTC: CWC.BitcoreLibLtc,
|
|
24
|
+
DOGE: CWC.BitcoreLibDoge
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
describe('Wallet', function() {
|
|
28
|
+
const sandbox = sinon.createSandbox();
|
|
29
|
+
const storageType = 'Level';
|
|
30
|
+
const baseUrl = 'http://127.0.0.1:3000/api';
|
|
31
|
+
let walletName;
|
|
32
|
+
let wallet: Wallet;
|
|
33
|
+
let api;
|
|
34
|
+
before(async function() {
|
|
35
|
+
this.timeout(20000);
|
|
36
|
+
await bcnStorage.start({
|
|
37
|
+
dbHost: process.env.DB_HOST || 'localhost',
|
|
38
|
+
dbPort: process.env.DB_PORT || '27017',
|
|
39
|
+
dbName: process.env.DB_NAME || 'bitcore-client-tests'
|
|
40
|
+
});
|
|
41
|
+
Modules.loadConfigured();
|
|
42
|
+
const httpServer: Server = await bcnApi.start();
|
|
43
|
+
api = supertest(httpServer);
|
|
44
|
+
});
|
|
45
|
+
after(async function() {
|
|
46
|
+
this.timeout(20000);
|
|
47
|
+
await bcnApi.stop();
|
|
48
|
+
await bcnStorage.stop();
|
|
49
|
+
});
|
|
50
|
+
beforeEach(function() {
|
|
51
|
+
sandbox.stub(request, 'Request').callsFake(function(args) {
|
|
52
|
+
args.url = args.url.replace('https://api.bitcore.io/api', baseUrl);
|
|
53
|
+
args.url = args.url.replace(baseUrl, '/api');
|
|
54
|
+
const req = api[args.method.toLowerCase()](args.url);
|
|
55
|
+
for (const [key, value] of Object.entries(args.headers)) {
|
|
56
|
+
req.set(key, value);
|
|
57
|
+
}
|
|
58
|
+
req.send(args.body);
|
|
59
|
+
return req;
|
|
60
|
+
});
|
|
61
|
+
sandbox.stub(requestStream, 'defaults').callsFake(function(args) {
|
|
62
|
+
console.log(args);
|
|
63
|
+
throw new Error('Need to implement requestStream stub in tests');
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
afterEach(async function() {
|
|
67
|
+
await Wallet.deleteWallet({ name: walletName, storageType });
|
|
68
|
+
sandbox.restore();
|
|
69
|
+
});
|
|
70
|
+
for (const chain of ['BTC', 'BCH', 'LTC', 'DOGE', 'ETH', 'XRP', 'MATIC']) {
|
|
71
|
+
for (const addressType of Object.keys(AddressTypes[chain] || { 'pubkeyhash': 1 })) {
|
|
72
|
+
|
|
73
|
+
it(`should create a wallet for chain and addressType: ${chain} ${addressType}`, async function() {
|
|
74
|
+
walletName = 'BitcoreClientTest' + chain + addressType;
|
|
75
|
+
|
|
76
|
+
wallet = await Wallet.create({
|
|
77
|
+
chain,
|
|
78
|
+
network: 'mainnet',
|
|
79
|
+
name: walletName,
|
|
80
|
+
phrase: 'snap impact summer because must pipe weasel gorilla actor acid web whip',
|
|
81
|
+
password: 'abc123',
|
|
82
|
+
lite: false,
|
|
83
|
+
addressType,
|
|
84
|
+
storageType,
|
|
85
|
+
baseUrl
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
expect(wallet.addressType).to.equal(AddressTypes[chain]?.[addressType] || 'pubkeyhash');
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it(`should generate an address for chain and addressType: ${chain} ${addressType}`, function() {
|
|
92
|
+
const address = wallet.deriveAddress(0, false);
|
|
93
|
+
expect(address).to.exist;
|
|
94
|
+
switch (chain) {
|
|
95
|
+
case 'BTC':
|
|
96
|
+
case 'BCH':
|
|
97
|
+
case 'DOGE':
|
|
98
|
+
case 'LTC':
|
|
99
|
+
const a = new libMap[chain].Address(address);
|
|
100
|
+
expect(a.toString(true)).to.equal(address);
|
|
101
|
+
expect(a.type).to.equal(wallet.addressType);
|
|
102
|
+
break;
|
|
103
|
+
case 'XRP':
|
|
104
|
+
// TODO verify XRP address
|
|
105
|
+
break;
|
|
106
|
+
default:
|
|
107
|
+
expect(CWC.Web3.utils.isAddress(address)).to.equal(true);
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
describe('bumpTxFee', function() {
|
|
115
|
+
describe('UTXO', function() {
|
|
116
|
+
walletName = 'BitcoreClientTestBumpFee-UTXO';
|
|
117
|
+
|
|
118
|
+
beforeEach(async function() {
|
|
119
|
+
wallet = await Wallet.create({
|
|
120
|
+
name: walletName,
|
|
121
|
+
chain: 'BTC',
|
|
122
|
+
network: 'testnet',
|
|
123
|
+
phrase: 'snap impact summer because must pipe weasel gorilla actor acid web whip',
|
|
124
|
+
password: 'abc123',
|
|
125
|
+
storageType,
|
|
126
|
+
baseUrl
|
|
127
|
+
});
|
|
128
|
+
await wallet.unlock('abc123');
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('should throw an error if changeIdx is null for UTXO chains', async () => {
|
|
132
|
+
try {
|
|
133
|
+
await wallet.bumpTxFee({});
|
|
134
|
+
expect.fail('Expected method to throw');
|
|
135
|
+
} catch (err) {
|
|
136
|
+
expect(err.message).to.equal('Must provide changeIdx for UTXO chains');
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('should throw an error if neither rawTx nor txid is provided', async () => {
|
|
141
|
+
try {
|
|
142
|
+
await wallet.bumpTxFee({ changeIdx: 0 });
|
|
143
|
+
expect.fail('Expected method to throw');
|
|
144
|
+
} catch (err) {
|
|
145
|
+
expect(err.message).to.equal('Must provide either rawTx or txid');
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('should bump the fee of a transaction with feeTarget', async function() {
|
|
150
|
+
sandbox.stub(wallet, 'getTransactionByTxid').resolves({ '_id': '65982807d85e75f781a0d56f', 'txid': '8b78e4d2ac2211472454f940445210b6487aaa0f889e18066eb3f623352607f5', 'network': 'regtest', 'chain': 'BTC', 'blockHeight': -1, 'blockHash': '', 'blockTime': '2024-01-05T16:02:15.678Z', 'blockTimeNormalized': '2024-01-05T16:02:15.678Z', 'coinbase': false, 'locktime': -1, 'inputCount': 5, 'outputCount': 1, 'size': 780, 'fee': 2409, 'value': 950891, 'confirmations': 0, 'coins': { 'inputs': [{ '_id': '659825bed85e75f781a01812', 'chain': 'BTC', 'network': 'regtest', 'coinbase': false, 'mintIndex': 1, 'spentTxid': '8b78e4d2ac2211472454f940445210b6487aaa0f889e18066eb3f623352607f5', 'mintTxid': '330716a75c23512202e45ffee478bdce7a33f298edf7eef30a42dbde06746c48', 'mintHeight': 154, 'spentHeight': -1, 'address': 'n2vpyzbBPBEni9FgkeQSnXvAQAfnRmKxFZ', 'script': '76a914eade85745090388e64a9341a82d8f94371430d1a88ac', 'value': 244000, 'confirmations': -1, 'sequenceNumber': 4294967293 }, { '_id': '65982587d85e75f781a0046f', 'chain': 'BTC', 'network': 'regtest', 'coinbase': false, 'mintIndex': 1, 'spentTxid': '8b78e4d2ac2211472454f940445210b6487aaa0f889e18066eb3f623352607f5', 'mintTxid': '7b83f82a22f94fc3e615743a5e6fb2345ed79aad8a2b564af2ace49da1e27ebb', 'mintHeight': 152, 'spentHeight': -1, 'address': 'muEU9KaNEw5doymy59ScrgEE3Eq4CQ45U9', 'script': '76a91496739b4ef4e793c05a78624da38d96f2c4059c6b88ac', 'value': 239400, 'confirmations': -1, 'sequenceNumber': 4294967293 }, { '_id': '65982511d85e75f7819fdd40', 'chain': 'BTC', 'network': 'regtest', 'coinbase': false, 'mintIndex': 0, 'spentTxid': '8b78e4d2ac2211472454f940445210b6487aaa0f889e18066eb3f623352607f5', 'mintTxid': 'fb4d8039024c80a655fea29e01faf202f30e936af5738e31c5841a84215ca4d6', 'mintHeight': 149, 'spentHeight': -1, 'address': 'muEU9KaNEw5doymy59ScrgEE3Eq4CQ45U9', 'script': '76a91496739b4ef4e793c05a78624da38d96f2c4059c6b88ac', 'value': 239400, 'confirmations': -1, 'sequenceNumber': 4294967293 }, { '_id': '659824d7d85e75f7819fc75d', 'chain': 'BTC', 'network': 'regtest', 'coinbase': false, 'mintIndex': 0, 'spentTxid': '8b78e4d2ac2211472454f940445210b6487aaa0f889e18066eb3f623352607f5', 'mintTxid': '8221ed6891f6ba82ab72bb8298a661e21b47b04408861b0c3268c4a04a0435b3', 'mintHeight': 145, 'spentHeight': -1, 'address': 'miEzS8fSvtDjwkEjY14FEuWumFKg8nTPV9', 'script': '76a9141de381fc20d34d20e11a5543f536a4b74f495a9888ac', 'value': 228000, 'confirmations': -1, 'sequenceNumber': 4294967293 }, { '_id': '65982389d85e75f7819f57ff', 'chain': 'BTC', 'network': 'regtest', 'coinbase': false, 'mintIndex': 0, 'spentTxid': '8b78e4d2ac2211472454f940445210b6487aaa0f889e18066eb3f623352607f5', 'mintTxid': '95f713c2d7e09ab57ec3016bb767b26e6ee849cf487e86d8ed6126ae1b893e0f', 'mintHeight': 143, 'spentHeight': -1, 'address': 'msnM9VB5usfBahZNo57ZUq9uzwRxQXksUz', 'script': '76a914868ad3308906626182d1c6cd703cc7ce78b3a28d88ac', 'value': 2500, 'confirmations': -1, 'sequenceNumber': 4294967293 }], 'outputs': [{ '_id': '65982807d85e75f781a0d55d', 'chain': 'BTC', 'network': 'regtest', 'coinbase': false, 'mintIndex': 0, 'spentTxid': '', 'mintTxid': '8b78e4d2ac2211472454f940445210b6487aaa0f889e18066eb3f623352607f5', 'mintHeight': -1, 'spentHeight': -2, 'address': 'mwwrGzk9q8xugY97C8BiNbcgqXNyjH4kp8', 'script': '76a914b4376347e4cffb1e9a475b2661bbe74de3c1f86a88ac', 'value': 950891, 'confirmations': -1 }] } });
|
|
151
|
+
sandbox.stub(wallet, 'getNetworkFee').resolves({ feerate: 0.00064803, blocks: 2 }); // this is a real response from mainnet
|
|
152
|
+
sandbox.stub(wallet.client, 'importAddresses').resolves();
|
|
153
|
+
sandbox.spy(CWC.BitcoreLib.Transaction.prototype, 'feePerByte');
|
|
154
|
+
|
|
155
|
+
await wallet.generateAddressPair(1310066242, true);
|
|
156
|
+
await wallet.generateAddressPair(1087984800, true);
|
|
157
|
+
await wallet.generateAddressPair(1310064953, true);
|
|
158
|
+
await wallet.generateAddressPair(1310062823, true);
|
|
159
|
+
|
|
160
|
+
const { tx: newTx } = await wallet.bumpTxFee({
|
|
161
|
+
txid: '8b78e4d2ac2211472454f940445210b6487aaa0f889e18066eb3f623352607f5',
|
|
162
|
+
changeIdx: 0,
|
|
163
|
+
feeTarget: 2
|
|
164
|
+
});
|
|
165
|
+
CWC.BitcoreLib.Transaction.prototype.feePerByte.callCount.should.equal(1);
|
|
166
|
+
CWC.BitcoreLib.Transaction.prototype.feePerByte.args[0][0].should.equal(65);
|
|
167
|
+
expect(newTx).to.equal('0200000005486c7406dedb420af3eef7ed98f2337acebd78e4fe5fe4022251235ca71607330100000000fdffffffbb7ee2a19de4acf24a562b8aad9ad75e34b26f5e3a7415e6c34ff9222af8837b0100000000fdffffffd6a45c21841a84c5318e73f56a930ef302f2fa019ea2fe55a6804c0239804dfb0000000000fdffffffb335044aa0c468320c1b860844b0471be261a69882bb72ab82baf69168ed21820000000000fdffffff0f3e891bae2661edd8867e48cf49e86e6eb267b76b01c37eb59ae0d7c213f7950000000000fdffffff01c4c40d00000000001976a914b4376347e4cffb1e9a475b2661bbe74de3c1f86a88ac00000000');
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('should bump the fee of a transaction with feeRate', async function() {
|
|
171
|
+
sandbox.stub(wallet, 'getTransactionByTxid').resolves({ '_id': '65982807d85e75f781a0d56f', 'txid': '8b78e4d2ac2211472454f940445210b6487aaa0f889e18066eb3f623352607f5', 'network': 'regtest', 'chain': 'BTC', 'blockHeight': -1, 'blockHash': '', 'blockTime': '2024-01-05T16:02:15.678Z', 'blockTimeNormalized': '2024-01-05T16:02:15.678Z', 'coinbase': false, 'locktime': -1, 'inputCount': 5, 'outputCount': 1, 'size': 780, 'fee': 2409, 'value': 950891, 'confirmations': 0, 'coins': { 'inputs': [{ '_id': '659825bed85e75f781a01812', 'chain': 'BTC', 'network': 'regtest', 'coinbase': false, 'mintIndex': 1, 'spentTxid': '8b78e4d2ac2211472454f940445210b6487aaa0f889e18066eb3f623352607f5', 'mintTxid': '330716a75c23512202e45ffee478bdce7a33f298edf7eef30a42dbde06746c48', 'mintHeight': 154, 'spentHeight': -1, 'address': 'n2vpyzbBPBEni9FgkeQSnXvAQAfnRmKxFZ', 'script': '76a914eade85745090388e64a9341a82d8f94371430d1a88ac', 'value': 244000, 'confirmations': -1, 'sequenceNumber': 4294967293 }, { '_id': '65982587d85e75f781a0046f', 'chain': 'BTC', 'network': 'regtest', 'coinbase': false, 'mintIndex': 1, 'spentTxid': '8b78e4d2ac2211472454f940445210b6487aaa0f889e18066eb3f623352607f5', 'mintTxid': '7b83f82a22f94fc3e615743a5e6fb2345ed79aad8a2b564af2ace49da1e27ebb', 'mintHeight': 152, 'spentHeight': -1, 'address': 'muEU9KaNEw5doymy59ScrgEE3Eq4CQ45U9', 'script': '76a91496739b4ef4e793c05a78624da38d96f2c4059c6b88ac', 'value': 239400, 'confirmations': -1, 'sequenceNumber': 4294967293 }, { '_id': '65982511d85e75f7819fdd40', 'chain': 'BTC', 'network': 'regtest', 'coinbase': false, 'mintIndex': 0, 'spentTxid': '8b78e4d2ac2211472454f940445210b6487aaa0f889e18066eb3f623352607f5', 'mintTxid': 'fb4d8039024c80a655fea29e01faf202f30e936af5738e31c5841a84215ca4d6', 'mintHeight': 149, 'spentHeight': -1, 'address': 'muEU9KaNEw5doymy59ScrgEE3Eq4CQ45U9', 'script': '76a91496739b4ef4e793c05a78624da38d96f2c4059c6b88ac', 'value': 239400, 'confirmations': -1, 'sequenceNumber': 4294967293 }, { '_id': '659824d7d85e75f7819fc75d', 'chain': 'BTC', 'network': 'regtest', 'coinbase': false, 'mintIndex': 0, 'spentTxid': '8b78e4d2ac2211472454f940445210b6487aaa0f889e18066eb3f623352607f5', 'mintTxid': '8221ed6891f6ba82ab72bb8298a661e21b47b04408861b0c3268c4a04a0435b3', 'mintHeight': 145, 'spentHeight': -1, 'address': 'miEzS8fSvtDjwkEjY14FEuWumFKg8nTPV9', 'script': '76a9141de381fc20d34d20e11a5543f536a4b74f495a9888ac', 'value': 228000, 'confirmations': -1, 'sequenceNumber': 4294967293 }, { '_id': '65982389d85e75f7819f57ff', 'chain': 'BTC', 'network': 'regtest', 'coinbase': false, 'mintIndex': 0, 'spentTxid': '8b78e4d2ac2211472454f940445210b6487aaa0f889e18066eb3f623352607f5', 'mintTxid': '95f713c2d7e09ab57ec3016bb767b26e6ee849cf487e86d8ed6126ae1b893e0f', 'mintHeight': 143, 'spentHeight': -1, 'address': 'msnM9VB5usfBahZNo57ZUq9uzwRxQXksUz', 'script': '76a914868ad3308906626182d1c6cd703cc7ce78b3a28d88ac', 'value': 2500, 'confirmations': -1, 'sequenceNumber': 4294967293 }], 'outputs': [{ '_id': '65982807d85e75f781a0d55d', 'chain': 'BTC', 'network': 'regtest', 'coinbase': false, 'mintIndex': 0, 'spentTxid': '', 'mintTxid': '8b78e4d2ac2211472454f940445210b6487aaa0f889e18066eb3f623352607f5', 'mintHeight': -1, 'spentHeight': -2, 'address': 'mwwrGzk9q8xugY97C8BiNbcgqXNyjH4kp8', 'script': '76a914b4376347e4cffb1e9a475b2661bbe74de3c1f86a88ac', 'value': 950891, 'confirmations': -1 }] } });
|
|
172
|
+
sandbox.stub(wallet.client, 'importAddresses').resolves();
|
|
173
|
+
sandbox.spy(CWC.BitcoreLib.Transaction.prototype, 'feePerByte');
|
|
174
|
+
|
|
175
|
+
await wallet.generateAddressPair(1310066242, true);
|
|
176
|
+
await wallet.generateAddressPair(1087984800, true);
|
|
177
|
+
await wallet.generateAddressPair(1310064953, true);
|
|
178
|
+
await wallet.generateAddressPair(1310062823, true);
|
|
179
|
+
|
|
180
|
+
const { tx: newTx } = await wallet.bumpTxFee({
|
|
181
|
+
txid: '8b78e4d2ac2211472454f940445210b6487aaa0f889e18066eb3f623352607f5',
|
|
182
|
+
changeIdx: 0,
|
|
183
|
+
feeRate: 2
|
|
184
|
+
});
|
|
185
|
+
CWC.BitcoreLib.Transaction.prototype.feePerByte.callCount.should.equal(1);
|
|
186
|
+
CWC.BitcoreLib.Transaction.prototype.feePerByte.args[0][0].should.equal(2);
|
|
187
|
+
expect(newTx).to.equal('0200000005486c7406dedb420af3eef7ed98f2337acebd78e4fe5fe4022251235ca71607330100000000fdffffffbb7ee2a19de4acf24a562b8aad9ad75e34b26f5e3a7415e6c34ff9222af8837b0100000000fdffffffd6a45c21841a84c5318e73f56a930ef302f2fa019ea2fe55a6804c0239804dfb0000000000fdffffffb335044aa0c468320c1b860844b0471be261a69882bb72ab82baf69168ed21820000000000fdffffff0f3e891bae2661edd8867e48cf49e86e6eb267b76b01c37eb59ae0d7c213f7950000000000fdffffff01b4850e00000000001976a914b4376347e4cffb1e9a475b2661bbe74de3c1f86a88ac00000000');
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
describe('EVM', function() {
|
|
192
|
+
walletName = 'BitcoreClientTestBumpFee-EVM';
|
|
193
|
+
|
|
194
|
+
beforeEach(async function() {
|
|
195
|
+
wallet = await Wallet.create({
|
|
196
|
+
name: walletName,
|
|
197
|
+
chain: 'ETH',
|
|
198
|
+
network: 'testnet',
|
|
199
|
+
phrase: 'snap impact summer because must pipe weasel gorilla actor acid web whip',
|
|
200
|
+
password: 'abc123',
|
|
201
|
+
storageType,
|
|
202
|
+
baseUrl
|
|
203
|
+
});
|
|
204
|
+
await wallet.unlock('abc123');
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
it('should throw an error if neither rawTx nor txid is provided', async () => {
|
|
209
|
+
try {
|
|
210
|
+
await wallet.bumpTxFee({ changeIdx: 0 });
|
|
211
|
+
expect.fail('Expected method to throw');
|
|
212
|
+
} catch (err) {
|
|
213
|
+
expect(err.message).to.equal('Must provide either rawTx or txid');
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it('should bump the fee of a transaction with feeTarget', async function() {
|
|
218
|
+
sandbox.stub(wallet, 'getTransactionByTxid').resolves({ 'txid': '0x0cf410cfe7fb268ad06ae115edfa8a30a8dea3979336a647b09b5a789c4b53d5', 'network': 'regtest', 'chain': 'ETH', 'blockHeight': 43245, 'blockHash': '0x9edb8d10883a360f7ff0c26860b6a159f5b7a74226949a4365691a879fafcdfc', 'blockTime': '2024-01-08T16:31:46.000Z', 'blockTimeNormalized': '2024-01-08T16:31:46.000Z', 'fee': 42000000000000, 'value': 1000000000000000000, 'gasLimit': 200000, 'gasPrice': 2000000000, 'nonce': 0, 'to': '0x7ee308b49e36Ab516cd0186B3a47CFD31d2499A1', 'from': '0x5FbdD2712d05D1a73e0b3Eba5efE8c3d42a336C3', 'effects': [], 'data': '0x', 'internal': [], 'calls': [], 'confirmations': 33 });
|
|
219
|
+
sandbox.stub(wallet, 'getNetworkFee').resolves({ feerate: 26550000000, blocks: 2 }); // this is a real response from mainnet
|
|
220
|
+
sandbox.stub(wallet.client, 'importAddresses').resolves();
|
|
221
|
+
|
|
222
|
+
const { tx: newTx, params } = await wallet.bumpTxFee({
|
|
223
|
+
txid: '0x0cf410cfe7fb268ad06ae115edfa8a30a8dea3979336a647b09b5a789c4b53d5',
|
|
224
|
+
feeTarget: 2
|
|
225
|
+
});
|
|
226
|
+
params.gasPrice.should.equal(26550000000);
|
|
227
|
+
expect(newTx).to.equal('0xf08085062e80d98083030d40947ee308b49e36ab516cd0186b3a47cfd31d2499a1880de0b6b3a76400008083aa36a78080');
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
it('should bump the fee of a transaction with feeRate', async function() {
|
|
231
|
+
sandbox.stub(wallet, 'getTransactionByTxid').resolves({ 'txid': '0x0cf410cfe7fb268ad06ae115edfa8a30a8dea3979336a647b09b5a789c4b53d5', 'network': 'regtest', 'chain': 'ETH', 'blockHeight': 43245, 'blockHash': '0x9edb8d10883a360f7ff0c26860b6a159f5b7a74226949a4365691a879fafcdfc', 'blockTime': '2024-01-08T16:31:46.000Z', 'blockTimeNormalized': '2024-01-08T16:31:46.000Z', 'fee': 42000000000000, 'value': 1000000000000000000, 'gasLimit': 200000, 'gasPrice': 2000000000, 'nonce': 0, 'to': '0x7ee308b49e36Ab516cd0186B3a47CFD31d2499A1', 'from': '0x5FbdD2712d05D1a73e0b3Eba5efE8c3d42a336C3', 'effects': [], 'data': '0x', 'internal': [], 'calls': [], 'confirmations': 33 });
|
|
232
|
+
sandbox.stub(wallet.client, 'importAddresses').resolves();
|
|
233
|
+
|
|
234
|
+
const { tx: newTx, params } = await wallet.bumpTxFee({
|
|
235
|
+
txid: '0x0cf410cfe7fb268ad06ae115edfa8a30a8dea3979336a647b09b5a789c4b53d5',
|
|
236
|
+
feeRate: 300
|
|
237
|
+
});
|
|
238
|
+
params.gasPrice.should.equal(CWC.Web3.utils.toWei('300', 'gwei'));
|
|
239
|
+
expect(newTx).to.equal('0xf0808545d964b80083030d40947ee308b49e36ab516cd0186b3a47cfd31d2499a1880de0b6b3a76400008083aa36a78080');
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
describe('getLocalAddress', function() {
|
|
245
|
+
for (const storageType of ['Level', 'Mongo', 'TextFile'] as StorageType[]) {
|
|
246
|
+
describe(storageType, function() {
|
|
247
|
+
let wallet;
|
|
248
|
+
const walletName = 'BitcoreClientTestGetLocalAddress' + storageType;
|
|
249
|
+
let address1, caddress1, address2, caddress2, address3, caddress3;
|
|
250
|
+
let path;
|
|
251
|
+
if (storageType === 'Mongo' && (process.env.DB_NAME || process.env.DB_HOST || process.env.DB_PORT)) {
|
|
252
|
+
path = `mongodb://${process.env.DB_HOST || 'localhost'}:${process.env.DB_PORT || 27017}/${process.env.DB_NAME || 'bitcoreWallets-test'}`;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
before(async function() {
|
|
256
|
+
this.timeout(5000);
|
|
257
|
+
try {
|
|
258
|
+
wallet = await Wallet.create({
|
|
259
|
+
name: walletName,
|
|
260
|
+
chain: 'BTC',
|
|
261
|
+
network: 'regtest',
|
|
262
|
+
password: 'abc123',
|
|
263
|
+
storageType,
|
|
264
|
+
path,
|
|
265
|
+
baseUrl
|
|
266
|
+
});
|
|
267
|
+
await wallet.unlock('abc123');
|
|
268
|
+
// 3 address pairs
|
|
269
|
+
[address1, caddress1] = await wallet.nextAddressPair(true);
|
|
270
|
+
[address2, caddress2] = await wallet.nextAddressPair(true);
|
|
271
|
+
[address3, caddress3] = await wallet.nextAddressPair(true);
|
|
272
|
+
} catch (e) {
|
|
273
|
+
wallet?.storage.close();
|
|
274
|
+
throw e;
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
after(async function() {
|
|
279
|
+
await Wallet.deleteWallet({ name: walletName, storageType, path });
|
|
280
|
+
wallet?.storage.close();
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
it('should return the local address', async function() {
|
|
284
|
+
const localAddress = await wallet.getLocalAddress(address2);
|
|
285
|
+
expect(localAddress.address).to.equal(address2);
|
|
286
|
+
expect(localAddress.path).to.equal('m/0/1');
|
|
287
|
+
expect(localAddress.pubKey).to.exist;
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
describe('importKeys', function() {
|
|
294
|
+
walletName = 'BitcoreClientTestImportKeys';
|
|
295
|
+
let requestStub;
|
|
296
|
+
let sleepStub;
|
|
297
|
+
|
|
298
|
+
beforeEach(async function() {
|
|
299
|
+
wallet = await Wallet.create({
|
|
300
|
+
name: walletName,
|
|
301
|
+
chain: 'BTC',
|
|
302
|
+
network: 'testnet',
|
|
303
|
+
phrase: 'snap impact summer because must pipe weasel gorilla actor acid web whip',
|
|
304
|
+
password: 'abc123',
|
|
305
|
+
storageType,
|
|
306
|
+
baseUrl
|
|
307
|
+
});
|
|
308
|
+
await wallet.unlock('abc123');
|
|
309
|
+
requestStub = sandbox.stub(wallet.client, '_request').resolves();
|
|
310
|
+
sleepStub = sandbox.stub(utils, 'sleep').resolves();
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
it('should import 1 key', async function() {
|
|
314
|
+
const keys = [];
|
|
315
|
+
for (let i = 0; i < 1; i++) {
|
|
316
|
+
const pk = crypto.randomBytes(32).toString('hex');
|
|
317
|
+
keys.push({
|
|
318
|
+
privKey: pk,
|
|
319
|
+
address: libMap.BTC.PrivateKey(pk).toAddress().toString()
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
await wallet.importKeys({
|
|
323
|
+
keys,
|
|
324
|
+
rederiveAddys: false
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
requestStub.callCount.should.equal(1);
|
|
328
|
+
sleepStub.callCount.should.equal(0);
|
|
329
|
+
requestStub.args.flatMap(arg => arg[0].body).should.deep.equal(keys.map(k => ({ address: k.address })));
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
it('should import <100 keys', async function() {
|
|
333
|
+
const keys = [];
|
|
334
|
+
for (let i = 0; i < 100; i++) {
|
|
335
|
+
const pk = crypto.randomBytes(32).toString('hex');
|
|
336
|
+
keys.push({
|
|
337
|
+
privKey: pk,
|
|
338
|
+
address: libMap.BTC.PrivateKey(pk).toAddress().toString()
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
await wallet.importKeys({
|
|
342
|
+
keys,
|
|
343
|
+
rederiveAddys: false
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
requestStub.callCount.should.equal(1);
|
|
347
|
+
sleepStub.callCount.should.equal(0);
|
|
348
|
+
requestStub.args.flatMap(arg => arg[0].body).should.deep.equal(keys.map(k => ({ address: k.address })));
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
it('should import >100 keys', async function() {
|
|
352
|
+
const keys = [];
|
|
353
|
+
for (let i = 0; i < 101; i++) {
|
|
354
|
+
const pk = crypto.randomBytes(32).toString('hex');
|
|
355
|
+
keys.push({
|
|
356
|
+
privKey: pk,
|
|
357
|
+
address: libMap.BTC.PrivateKey(pk).toAddress().toString()
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
await wallet.importKeys({
|
|
361
|
+
keys,
|
|
362
|
+
rederiveAddys: false
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
requestStub.callCount.should.equal(2);
|
|
366
|
+
sleepStub.callCount.should.equal(1);
|
|
367
|
+
requestStub.args.flatMap(arg => arg[0].body).should.deep.equal(keys.map(k => ({ address: k.address })));
|
|
368
|
+
});
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
describe('getBalance', function() {
|
|
372
|
+
walletName = 'BitcoreClientTestGetBalance';
|
|
373
|
+
beforeEach(async function() {
|
|
374
|
+
wallet = await Wallet.create({
|
|
375
|
+
name: walletName,
|
|
376
|
+
chain: 'MATIC',
|
|
377
|
+
network: 'testnet',
|
|
378
|
+
phrase: 'snap impact summer because must pipe weasel gorilla actor acid web whip',
|
|
379
|
+
password: 'abc123',
|
|
380
|
+
storageType: 'Level',
|
|
381
|
+
});
|
|
382
|
+
await wallet.unlock('abc123');
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
it('should get correct token balance with conflicting token objects and old token object', async function() {
|
|
386
|
+
// Old token object (no name)
|
|
387
|
+
wallet.tokens.push({
|
|
388
|
+
symbol: 'USDC',
|
|
389
|
+
address: '0x123',
|
|
390
|
+
decimals: '6',
|
|
391
|
+
});
|
|
392
|
+
wallet.tokens.push({
|
|
393
|
+
symbol: 'USDC',
|
|
394
|
+
address: '0xabc',
|
|
395
|
+
decimals: '6',
|
|
396
|
+
name: 'USDCn_m'
|
|
397
|
+
});
|
|
398
|
+
sinon.stub(wallet.client, 'getBalance').callsFake(async function(params) {
|
|
399
|
+
switch (params.payload.tokenContractAddress) {
|
|
400
|
+
case '0x123':
|
|
401
|
+
return 1;
|
|
402
|
+
case '0xabc':
|
|
403
|
+
return 2;
|
|
404
|
+
default:
|
|
405
|
+
return 0;
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
const balance1 = await wallet.getBalance({ token: 'USDC' });
|
|
410
|
+
const balance2 = await wallet.getBalance({ token: 'USDC', tokenName: 'USDC_m' });
|
|
411
|
+
const balance3 = await wallet.getBalance({ tokenName: 'USDCn_m' });
|
|
412
|
+
const balance4 = await wallet.getBalance({ token: 'USDC', tokenName: 'USDCn_m' });
|
|
413
|
+
balance1.should.equal(1);
|
|
414
|
+
balance2.should.equal(1);
|
|
415
|
+
balance3.should.equal(2);
|
|
416
|
+
balance4.should.equal(2);
|
|
417
|
+
});
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
describe('getTokenObj', function() {
|
|
421
|
+
walletName = 'BitcoreClientTestGetTokenObj';
|
|
422
|
+
beforeEach(async function() {
|
|
423
|
+
wallet = await Wallet.create({
|
|
424
|
+
name: walletName,
|
|
425
|
+
chain: 'MATIC',
|
|
426
|
+
network: 'testnet',
|
|
427
|
+
phrase: 'snap impact summer because must pipe weasel gorilla actor acid web whip',
|
|
428
|
+
password: 'abc123',
|
|
429
|
+
storageType: 'Level',
|
|
430
|
+
});
|
|
431
|
+
await wallet.unlock('abc123');
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
it('should get correct token object', async function() {
|
|
435
|
+
// Old token object (no name)
|
|
436
|
+
wallet.tokens.push({
|
|
437
|
+
symbol: 'USDC',
|
|
438
|
+
address: '0x123',
|
|
439
|
+
decimals: '6',
|
|
440
|
+
});
|
|
441
|
+
wallet.tokens.push({
|
|
442
|
+
symbol: 'USDC',
|
|
443
|
+
address: '0xabc',
|
|
444
|
+
decimals: '6',
|
|
445
|
+
name: 'USDC.e'
|
|
446
|
+
});
|
|
447
|
+
const obj1 = wallet.getTokenObj({ token: 'USDC' });
|
|
448
|
+
const obj2 = wallet.getTokenObj({ token: 'USDC', tokenName: 'USDC.other' }); // no object with "USDC.other"
|
|
449
|
+
const obj3 = wallet.getTokenObj({ token: 'USDC', tokenName: 'USDC.e' });
|
|
450
|
+
const obj4 = wallet.getTokenObj({ tokenName: 'USDC.e' });
|
|
451
|
+
obj1.address.should.equal('0x123');
|
|
452
|
+
obj2.address.should.equal('0x123');
|
|
453
|
+
obj3.address.should.equal('0xabc');
|
|
454
|
+
obj4.address.should.equal('0xabc');
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
it('should fallback to old token object if matching `token` is given', async function() {
|
|
458
|
+
// Old token object (no name)
|
|
459
|
+
wallet.tokens.push({
|
|
460
|
+
symbol: 'USDC',
|
|
461
|
+
address: '0x123',
|
|
462
|
+
decimals: '6',
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
const obj1 = wallet.getTokenObj({ token: 'USDC' });
|
|
466
|
+
obj1.address.should.equal('0x123');
|
|
467
|
+
const obj2 = wallet.getTokenObj({ token: 'USDC', tokenName: 'USDC.e' }); // falls back
|
|
468
|
+
obj2.address.should.equal('0x123');
|
|
469
|
+
try {
|
|
470
|
+
const obj3 = wallet.getTokenObj({ tokenName: 'USDC.e' }); // token not given, so cannot fall back
|
|
471
|
+
should.not.exist(obj3);
|
|
472
|
+
} catch (err) {
|
|
473
|
+
err.message.should.equal('USDC.e not found on wallet ' + walletName);
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
describe('rmToken', function() {
|
|
479
|
+
walletName = 'BitcoreClientTestRmToken';
|
|
480
|
+
const usdcLegacyObj = {
|
|
481
|
+
symbol: 'USDC',
|
|
482
|
+
address: '0x123',
|
|
483
|
+
decimals: '6',
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
const usdcObj = {
|
|
487
|
+
symbol: 'USDC',
|
|
488
|
+
address: '0xabc',
|
|
489
|
+
decimals: '6',
|
|
490
|
+
name: 'USDCn'
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
const daiObj = {
|
|
494
|
+
symbol: 'DAI',
|
|
495
|
+
address: '0x1a2b3c',
|
|
496
|
+
decimals: '6',
|
|
497
|
+
name: 'DAIn'
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
beforeEach(async function() {
|
|
501
|
+
wallet = await Wallet.create({
|
|
502
|
+
chain: 'ETH',
|
|
503
|
+
network: 'mainnet',
|
|
504
|
+
name: walletName,
|
|
505
|
+
phrase: 'snap impact summer because must pipe weasel gorilla actor acid web whip',
|
|
506
|
+
password: 'abc123',
|
|
507
|
+
lite: false,
|
|
508
|
+
storageType,
|
|
509
|
+
baseUrl
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
wallet.tokens = [
|
|
513
|
+
usdcLegacyObj,
|
|
514
|
+
usdcObj,
|
|
515
|
+
daiObj
|
|
516
|
+
];
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
it('should remove a legacy token object', function() {
|
|
520
|
+
wallet.rmToken({ tokenName: 'USDC' });
|
|
521
|
+
wallet.tokens.length.should.equal(2);
|
|
522
|
+
wallet.tokens.filter(t => t.symbol === 'USDC').length.should.equal(1);
|
|
523
|
+
wallet.tokens.filter(t => t.symbol === 'USDC')[0].should.deep.equal(usdcObj);
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
it('should remove a token object', function() {
|
|
527
|
+
wallet.rmToken({ tokenName: 'USDCn' });
|
|
528
|
+
wallet.tokens.length.should.equal(2);
|
|
529
|
+
wallet.tokens.filter(t => t.symbol === 'USDC').length.should.equal(1);
|
|
530
|
+
wallet.tokens.filter(t => t.symbol === 'USDC')[0].should.deep.equal(usdcLegacyObj);
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
it('should remove the correct token object regardless of order', function() {
|
|
534
|
+
wallet.tokens = [
|
|
535
|
+
usdcObj,
|
|
536
|
+
daiObj,
|
|
537
|
+
usdcLegacyObj // this should be ordered after usdcObj
|
|
538
|
+
];
|
|
539
|
+
|
|
540
|
+
wallet.rmToken({ tokenName: 'USDC' });
|
|
541
|
+
wallet.tokens.length.should.equal(2);
|
|
542
|
+
wallet.tokens.filter(t => t.symbol === 'USDC').length.should.equal(1);
|
|
543
|
+
wallet.tokens.filter(t => t.symbol === 'USDC')[0].should.deep.equal(usdcObj);
|
|
544
|
+
});
|
|
545
|
+
|
|
546
|
+
it('should not remove any unmatched token object', function() {
|
|
547
|
+
wallet.rmToken({ tokenName: 'BOGUS' });
|
|
548
|
+
wallet.tokens.length.should.equal(3);
|
|
549
|
+
});
|
|
550
|
+
});
|
|
551
|
+
});
|
|
552
|
+
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { BitcoreLib } from '@bitpay-labs/crypto-wallet-core';
|
|
2
|
+
import requestStream from 'request';
|
|
3
|
+
import request from 'request-promise-native';
|
|
4
|
+
export declare class Client {
|
|
5
|
+
apiUrl: string;
|
|
6
|
+
authKey: any;
|
|
7
|
+
constructor(params: {
|
|
8
|
+
apiUrl: string;
|
|
9
|
+
authKey: BitcoreLib.PrivateKey;
|
|
10
|
+
});
|
|
11
|
+
_request(params: request.OptionsWithUrl): Promise<any>;
|
|
12
|
+
_buildQueryString(params: any): string;
|
|
13
|
+
getMessage(params: {
|
|
14
|
+
method: string;
|
|
15
|
+
url: string;
|
|
16
|
+
payload?: any;
|
|
17
|
+
}): string;
|
|
18
|
+
sign(params: {
|
|
19
|
+
method: string;
|
|
20
|
+
url: string;
|
|
21
|
+
payload?: any;
|
|
22
|
+
}): string;
|
|
23
|
+
register(params: {
|
|
24
|
+
payload: {
|
|
25
|
+
baseUrl?: string;
|
|
26
|
+
} & any;
|
|
27
|
+
}): Promise<any>;
|
|
28
|
+
getToken(contractAddress: any): Promise<any>;
|
|
29
|
+
getSolanaTokens(address: any): Promise<any>;
|
|
30
|
+
getBalance(params: {
|
|
31
|
+
payload?: any;
|
|
32
|
+
pubKey: string;
|
|
33
|
+
time?: string;
|
|
34
|
+
address?: string;
|
|
35
|
+
hex?: boolean;
|
|
36
|
+
}): Promise<any>;
|
|
37
|
+
getTransaction(params: {
|
|
38
|
+
txid: string;
|
|
39
|
+
populated?: boolean;
|
|
40
|
+
}): Promise<any>;
|
|
41
|
+
getNonce(params: any): Promise<any>;
|
|
42
|
+
getAddressTxos: (params: any) => Promise<any>;
|
|
43
|
+
getCoins(params: {
|
|
44
|
+
payload?: any;
|
|
45
|
+
pubKey: string;
|
|
46
|
+
includeSpent: boolean;
|
|
47
|
+
}): requestStream.Request;
|
|
48
|
+
listTransactions(params: any): requestStream.Request;
|
|
49
|
+
getFee(params: any): Promise<any>;
|
|
50
|
+
getPriorityFee(params: any): Promise<any>;
|
|
51
|
+
importAddresses(params: {
|
|
52
|
+
pubKey: string;
|
|
53
|
+
payload: Array<{
|
|
54
|
+
address: string;
|
|
55
|
+
}>;
|
|
56
|
+
}): Promise<void>;
|
|
57
|
+
broadcast(params: any): Promise<any>;
|
|
58
|
+
checkWallet(params: any): Promise<any>;
|
|
59
|
+
getAddresses(params: {
|
|
60
|
+
pubKey: string;
|
|
61
|
+
}): Promise<any>;
|
|
62
|
+
getAccountFlags(params: {
|
|
63
|
+
address: string;
|
|
64
|
+
}): Promise<any>;
|
|
65
|
+
estimateGas(params: {
|
|
66
|
+
to: string;
|
|
67
|
+
from: string;
|
|
68
|
+
data: string;
|
|
69
|
+
value: string;
|
|
70
|
+
}): Promise<any>;
|
|
71
|
+
getL1Fee(params: {
|
|
72
|
+
rawTx: string;
|
|
73
|
+
safe?: boolean;
|
|
74
|
+
}): Promise<any>;
|
|
75
|
+
getBlockTip(): Promise<any>;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,aAAa,MAAM,SAAS,CAAC;AACpC,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAM7C,qBAAa,MAAM;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,GAAG,CAAC;gBAED,MAAM,EAAE;QAClB,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,EAAE,UAAU,CAAC,UAAU,CAAC;KAChC;IAKK,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,cAAc;IAa7C,iBAAiB,CAAE,MAAM,EAAE,GAAG;IAQ9B,UAAU,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,GAAG,CAAA;KAAE;IAMjE,IAAI,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,GAAG,CAAA;KAAE;IAOrD,QAAQ,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE;YAAE,OAAO,CAAC,EAAE,MAAM,CAAA;SAAE,GAAG,GAAG,CAAA;KAAE;IAexD,QAAQ,CAAC,eAAe,KAAA;IAKxB,eAAe,CAAC,OAAO,KAAA;IAKvB,UAAU,CAAC,MAAM,EAAE;QAAE,OAAO,CAAC,EAAE,GAAG,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,OAAO,CAAA;KAAE;IA0BpG,cAAc,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE;IAM5D,QAAQ,CAAC,MAAM,KAAA;IAMrB,cAAc,gCAKZ;IAEF,QAAQ,CAAC,MAAM,EAAE;QAAE,OAAO,CAAC,EAAE,GAAG,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,OAAO,CAAA;KAAE;IAWzE,gBAAgB,CAAC,MAAM,KAAA;IAqCjB,MAAM,CAAC,MAAM,KAAA;IAUb,cAAc,CAAC,MAAM,KAAA;IAUrB,eAAe,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,KAAK,CAAC;YAAE,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAuB/F,SAAS,CAAC,MAAM,KAAA;IAMhB,WAAW,CAAC,MAAM,KAAA;IAYxB,YAAY,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE;IAYvC,eAAe,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE;IAM3C,WAAW,CAAC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;IAO7E,QAAQ,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE;IAOlD,WAAW;CAIZ"}
|