@exodus/bitcoin-plugin 1.4.1 → 1.5.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/package.json +4 -3
  2. package/src/create-asset.js +1 -1
  3. package/jest.config.js +0 -7
  4. package/src/__tests__/address.test.js +0 -142
  5. package/src/__tests__/balances.test.js +0 -67
  6. package/src/__tests__/bitcoin-private-seed-safe-report.json +0 -2754
  7. package/src/__tests__/bitcoin-signing.test.js +0 -184
  8. package/src/__tests__/fee-data.test.js +0 -61
  9. package/src/__tests__/fee-estimator.test.js +0 -174
  10. package/src/__tests__/fixtures/segwit-all-unsigned-tx.js +0 -87
  11. package/src/__tests__/fixtures/segwit-legacy-change-unsigned-tx.js +0 -38
  12. package/src/__tests__/fixtures/segwit-segwit-change-unsigned-tx.js +0 -96
  13. package/src/__tests__/fixtures/taproot-15000sats-unsigned-tx.js +0 -149
  14. package/src/__tests__/fixtures/taproot-all-unsigned-tx.js +0 -231
  15. package/src/__tests__/fixtures/taproot-unsigned-tx.js +0 -85
  16. package/src/__tests__/get-size.test.js +0 -71
  17. package/src/__tests__/index.test.js +0 -65
  18. package/src/__tests__/keys.test.js +0 -97
  19. package/src/__tests__/monitor.integration.test.js +0 -170
  20. package/src/__tests__/move-funds.test.js +0 -408
  21. package/src/__tests__/parse-unsigned-tx.test.js +0 -46
  22. package/src/__tests__/reports/unit-test-safe-report.json +0 -2790
  23. package/src/__tests__/send-tx.test.js +0 -145
  24. package/src/__tests__/sign-tx.test.js +0 -32
  25. package/src/__tests__/unsigned-btclike-desktop.json +0 -40
  26. package/src/__tests__/wallet.test.js +0 -78
  27. package/src/ordinals/__tests__/brc-20-client.integration.test.js +0 -86
  28. package/src/ordinals/__tests__/brc-20-utils.test.js +0 -165
  29. package/src/ordinals/__tests__/fixtures/inscriptions-send-usigned-tx.js +0 -125
  30. package/src/ordinals/__tests__/fixtures/nft-send-usigned-tx.js +0 -97
  31. package/src/ordinals/__tests__/monitor-ordinals-enabled-safe-report-with-inscriptions.json +0 -2908
  32. package/src/ordinals/__tests__/monitor-ordinals-enabled-safe-report.json +0 -2906
  33. package/src/ordinals/__tests__/monitor-ordinals-enabled.integration.test.js +0 -16
  34. package/src/ordinals/__tests__/nfts-api.test.js +0 -221
  35. package/src/ordinals/__tests__/ordinals-send-tx.test.js +0 -103
@@ -1,16 +0,0 @@
1
- import { createAsset } from '../../index'
2
-
3
- import { getPrivateSeed, monitorIntegrationTester } from '@exodus/assets-testing'
4
- import * as path from 'path'
5
- const asset = createAsset({ ordinalChainIndex: 2, ordinalsEnabled: true })
6
-
7
- const safeReportFile = path.join(__dirname, 'monitor-ordinals-enabled-safe-report.json')
8
- const walletAccountCount = 4
9
- describe(`bitcoin with ordinals enabled integration test`, () => {
10
- monitorIntegrationTester({
11
- asset,
12
- seed: getPrivateSeed(),
13
- walletAccountCount,
14
- safeReportFile,
15
- })
16
- })
@@ -1,221 +0,0 @@
1
- import { createAsset } from '../../index'
2
- import { getPrivateSeed, walletTester } from '@exodus/assets-testing'
3
- import path from 'path'
4
- const asset = createAsset({ ordinalChainIndex: 2, ordinalsEnabled: true })
5
-
6
- const beforeSafeReportFile = path.join(__dirname, './monitor-ordinals-enabled-safe-report.json')
7
- const afterSafeReportFile = path.join(
8
- __dirname,
9
- './monitor-ordinals-enabled-safe-report-with-inscriptions.json'
10
- )
11
-
12
- describe(`bitcoin.nfts enabled can update utxos`, () => {
13
- walletTester({
14
- asset,
15
- seed: getPrivateSeed(),
16
- walletAccountCount: 4,
17
- importSafeReportFile: beforeSafeReportFile,
18
- tests: {
19
- 'load all nfts from proxy server': async ({ assetClientInterface, assertSafeReport }) => {
20
- const walletAccount = 'exodus_1'
21
-
22
- // forcing setting up aci in nfts
23
- asset.api.createHistoryMonitor({ asset, assetClientInterface })
24
-
25
- const addresses = await asset.api.nfts.getNftsAddresses({
26
- assetClientInterface,
27
- walletAccount: walletAccount,
28
- })
29
- expect(addresses).toEqual([
30
- 'bc1pe59l2tsfe6t5x6wrcgtsaxy3nrpnky8chq4cvf7zndat99f8t4xsetgm4w',
31
- 'bc1pkhrae7jrlj3wnz0vpm09tffndpu40vh6y4tl42pt2zdhfms575msdfwuew',
32
- 'bc1qgxz38crda20mlre427ygezgu67kqvqfr4heayn',
33
- 'bc1qux2sjzksvgzwu2wdlvgtm8ggfp0azwff53yar6',
34
- 'bc1qpk5g380fe5u0tfd8gz9h3lsga402q49kf2c5ny',
35
- ])
36
- // const proxy = new NftsProxyApi({ baseUrl: 'https://nfts-proxy-d.exodus.io/v2' })
37
- // const nfts = (
38
- // await Promise.all(addresses.map((address) => proxy.api.bitcoin.getNftsByOwner(address)))
39
- // ).flat(
40
- //
41
- const nfts = [
42
- {
43
- network: 'bitcoin',
44
- attributes: [],
45
- collectionName: '',
46
- image:
47
- 'https://fetch-n-cache.a.exodus.io/?url=https%3A%2F%2Ford-mirror.magiceden.dev%2Fcontent%2F45199d28c76a6d2b82c35772ed4d1d7b5156dfe7aa385490ac0799c95187038fi0&maxage=2678400&apikey=nftproxy_zDKMFoRw6e8xrWCmXNccium43xLz4xxt9vWNBCfHMr',
48
- name: '#7010622',
49
- number: 7010622,
50
- owner: 'bc1pe59l2tsfe6t5x6wrcgtsaxy3nrpnky8chq4cvf7zndat99f8t4xsetgm4w',
51
- id: 'bitcoin:45199d28c76a6d2b82c35772ed4d1d7b5156dfe7aa385490ac0799c95187038fi0',
52
- tokenId: '45199d28c76a6d2b82c35772ed4d1d7b5156dfe7aa385490ac0799c95187038fi0',
53
- contentType: 'text/plain;charset=utf-8',
54
- output: 'fad4bdad739a21e409b5d3e0c3a9d5fb1ac188cd1ec9b172ee8912dde7063c91:0',
55
- inscriptionNumber: 7010622,
56
- },
57
- {
58
- network: 'bitcoin',
59
- attributes: [],
60
- number: 7010623,
61
- owner: 'bc1qpk5g380fe5u0tfd8gz9h3lsga402q49kf2c5ny',
62
- id: 'bitcoin:11199d28c76a6d2b82c35772ed4d1d7b5156dfe7aa385490ac0799c95187038fi0',
63
- tokenId: '11199d28c76a6d2b82c35772ed4d1d7b5156dfe7aa385490ac0799c95187038fi0',
64
- contentType: 'text/plain;charset=utf-8',
65
- output: 'd2627ebefccc448fea0dfaa8e8b365f3d96f3fc32c0551ed539f4329312e54ad:1',
66
- inscriptionNumber: 7010622,
67
- },
68
- {
69
- network: 'bitcoin',
70
- attributes: [],
71
- number: 7010624,
72
- owner: 'bc1qpk5g380fe5u0tfd8gz9h3lsga402q49kf2c5ny',
73
- id: 'bitcoin:22299d28c76a6d2b82c35772ed4d1d7b5156dfe7aa385490ac0799c95187038fi0',
74
- tokenId: '22299d28c76a6d2b82c35772ed4d1d7b5156dfe7aa385490ac0799c95187038fi0',
75
- contentType: 'text/plain;charset=utf-8',
76
- output: '1111ebefccc448fea0dfaa8e8b365f3d96f3fc32c0551ed539f4329312e54ad:1', // Utxos is not in the list! AKA Ordinal NFTs in transit out
77
- inscriptionNumber: 7010622,
78
- },
79
- ]
80
-
81
- const assetName = asset.name
82
- const beforeAccountState = await assetClientInterface.getAccountState({
83
- walletAccount,
84
- assetName: assetName,
85
- })
86
-
87
- expect(beforeAccountState.utxos.toJSON()).toEqual({
88
- bc1qgxz38crda20mlre427ygezgu67kqvqfr4heayn: {
89
- address: 'bc1qgxz38crda20mlre427ygezgu67kqvqfr4heayn',
90
- path: 'm/0/0',
91
- utxos: [
92
- {
93
- confirmations: 1,
94
- rbfEnabled: true,
95
- script: '0014418513e06dea9fbf8f3557888c891cd7ac060123',
96
- txId: '4be8bec21742975ffa27145d6683637c2bc8e8ad7b29bedfdb013a844603bbac',
97
- value: '0.00933282 BTC',
98
- vout: 0,
99
- },
100
- ],
101
- },
102
- bc1qpk5g380fe5u0tfd8gz9h3lsga402q49kf2c5ny: {
103
- address: 'bc1qpk5g380fe5u0tfd8gz9h3lsga402q49kf2c5ny',
104
- path: 'm/1/3',
105
- utxos: [
106
- {
107
- confirmations: 1,
108
- script: '00140da8889de9cd38f5a5a7408b78fe08ed5ea054b6',
109
- txId: 'd2627ebefccc448fea0dfaa8e8b365f3d96f3fc32c0551ed539f4329312e54ad',
110
- value: '0.00083929 BTC',
111
- vout: 1,
112
- },
113
- ],
114
- },
115
- bc1qux2sjzksvgzwu2wdlvgtm8ggfp0azwff53yar6: {
116
- address: 'bc1qux2sjzksvgzwu2wdlvgtm8ggfp0azwff53yar6',
117
- path: 'm/1/0',
118
- utxos: [
119
- {
120
- confirmations: 1,
121
- rbfEnabled: true,
122
- script: '0014e195090ad06204ee29cdfb10bd9d08485fd13929',
123
- txId: '43771d0143ccfd5df0e5784127e4e54b40bc93172ff6ffab311ffec9abfe9ebc',
124
- value: '0.00210842 BTC',
125
- vout: 2,
126
- },
127
- ],
128
- },
129
- })
130
- expect(beforeAccountState.ordinalsUtxos.toJSON()).toEqual({
131
- bc1pe59l2tsfe6t5x6wrcgtsaxy3nrpnky8chq4cvf7zndat99f8t4xsetgm4w: {
132
- address: 'bc1pe59l2tsfe6t5x6wrcgtsaxy3nrpnky8chq4cvf7zndat99f8t4xsetgm4w',
133
- path: 'm/2/0',
134
- utxos: [
135
- {
136
- confirmations: 1,
137
- rbfEnabled: true,
138
- script: '5120cd0bf52e09ce974369c3c2170e989198c33b10f8b82b8627c29b7ab295275d4d',
139
- txId: 'fad4bdad739a21e409b5d3e0c3a9d5fb1ac188cd1ec9b172ee8912dde7063c91',
140
- value: '0.00006673 BTC',
141
- vout: 0,
142
- },
143
- ],
144
- },
145
- })
146
-
147
- const postProcessedNfts = await asset.api.nfts.postProcessNfts({ nfts, walletAccount })
148
- expect(postProcessedNfts).toEqual(nfts.slice(0, 2))
149
-
150
- const afterAccountState = await assetClientInterface.getAccountState({
151
- walletAccount,
152
- assetName: assetName,
153
- })
154
-
155
- expect(afterAccountState.utxos.toJSON()).toEqual({
156
- bc1qgxz38crda20mlre427ygezgu67kqvqfr4heayn: {
157
- address: 'bc1qgxz38crda20mlre427ygezgu67kqvqfr4heayn',
158
- path: 'm/0/0',
159
- utxos: [
160
- {
161
- confirmations: 1,
162
- rbfEnabled: true,
163
- script: '0014418513e06dea9fbf8f3557888c891cd7ac060123',
164
- txId: '4be8bec21742975ffa27145d6683637c2bc8e8ad7b29bedfdb013a844603bbac',
165
- value: '0.00933282 BTC',
166
- vout: 0,
167
- },
168
- ],
169
- },
170
- bc1qux2sjzksvgzwu2wdlvgtm8ggfp0azwff53yar6: {
171
- address: 'bc1qux2sjzksvgzwu2wdlvgtm8ggfp0azwff53yar6',
172
- path: 'm/1/0',
173
- utxos: [
174
- {
175
- confirmations: 1,
176
- rbfEnabled: true,
177
- script: '0014e195090ad06204ee29cdfb10bd9d08485fd13929',
178
- txId: '43771d0143ccfd5df0e5784127e4e54b40bc93172ff6ffab311ffec9abfe9ebc',
179
- value: '0.00210842 BTC',
180
- vout: 2,
181
- },
182
- ],
183
- },
184
- })
185
- expect(afterAccountState.ordinalsUtxos.toJSON()).toEqual({
186
- bc1pe59l2tsfe6t5x6wrcgtsaxy3nrpnky8chq4cvf7zndat99f8t4xsetgm4w: {
187
- address: 'bc1pe59l2tsfe6t5x6wrcgtsaxy3nrpnky8chq4cvf7zndat99f8t4xsetgm4w',
188
- path: 'm/2/0',
189
- utxos: [
190
- {
191
- confirmations: 1,
192
- inscriptionId: '45199d28c76a6d2b82c35772ed4d1d7b5156dfe7aa385490ac0799c95187038fi0',
193
- rbfEnabled: true,
194
- script: '5120cd0bf52e09ce974369c3c2170e989198c33b10f8b82b8627c29b7ab295275d4d',
195
- txId: 'fad4bdad739a21e409b5d3e0c3a9d5fb1ac188cd1ec9b172ee8912dde7063c91',
196
- value: '0.00006673 BTC',
197
- vout: 0,
198
- },
199
- ],
200
- },
201
- bc1qpk5g380fe5u0tfd8gz9h3lsga402q49kf2c5ny: {
202
- address: 'bc1qpk5g380fe5u0tfd8gz9h3lsga402q49kf2c5ny',
203
- path: 'm/1/3',
204
- utxos: [
205
- {
206
- confirmations: 1,
207
- inscriptionId: '11199d28c76a6d2b82c35772ed4d1d7b5156dfe7aa385490ac0799c95187038fi0',
208
- script: '00140da8889de9cd38f5a5a7408b78fe08ed5ea054b6',
209
- txId: 'd2627ebefccc448fea0dfaa8e8b365f3d96f3fc32c0551ed539f4329312e54ad',
210
- value: '0.00083929 BTC',
211
- vout: 1,
212
- },
213
- ],
214
- },
215
- })
216
-
217
- await assertSafeReport({ safeReportFile: afterSafeReportFile, override: false })
218
- },
219
- },
220
- })
221
- })
@@ -1,103 +0,0 @@
1
- import shuffle from 'lodash/shuffle'
2
-
3
- import { createAsset } from '../../index'
4
- import { getPrivateSeed, walletTester } from '@exodus/assets-testing'
5
- import path from 'path'
6
-
7
- import { getSchnorrEntropy } from '@exodus/bitcoin-api/src/tx-sign/default-entropy'
8
-
9
- import { sendTxTest } from '@exodus/bitcoin-api/src/__tests__/tx-send-testing-utils'
10
- import inscriptionsSendUsignedTx from './fixtures/inscriptions-send-usigned-tx'
11
- import nftSendUsignedTx from './fixtures/nft-send-usigned-tx'
12
-
13
- const asset = createAsset({ ordinalChainIndex: 2, ordinalsEnabled: true, brc20Enabled: true })
14
-
15
- // Tell jest to mock this import
16
- jest.mock('lodash/shuffle')
17
- jest.mock('@exodus/bitcoin-api/src/insight-api-client/index')
18
- jest.mock('@exodus/bitcoin-api/src/tx-sign/default-entropy')
19
-
20
- // avoid shuffle so order and tx hash can be asserted
21
- shuffle.mockImplementation((list) => {
22
- return list
23
- })
24
-
25
- getSchnorrEntropy.mockImplementation(() => {
26
- return Buffer.from('1230000000000000000000000000000000000000000000000000000000000000', 'hex')
27
- })
28
-
29
- const importSafeReportFile = path.join(
30
- __dirname,
31
- './monitor-ordinals-enabled-safe-report-with-inscriptions.json'
32
- )
33
-
34
- describe(`bitcoin inscriptions tx-send test`, () => {
35
- beforeEach(() => {
36
- jest.spyOn(asset.api, 'signTx')
37
- asset.insightClient.fetchBlockHeight.mockImplementation(async () => {
38
- return 768520
39
- })
40
- })
41
-
42
- afterEach(() => {
43
- jest.clearAllMocks()
44
- jest.restoreAllMocks()
45
- })
46
-
47
- walletTester({
48
- asset,
49
- seed: getPrivateSeed(),
50
- importSafeReportFile,
51
- walletAccountCount: 4,
52
- tests: {
53
- 'can send 2 inscriptions from wallet 1': async ({ assetClientInterface, asset }) => {
54
- const address = 'bc1pkhrae7jrlj3wnz0vpm09tffndpu40vh6y4tl42pt2zdhfms575msdfwuew'
55
-
56
- const expectedBalance = asset.currency.parse('1136644 satoshis')
57
- const expectedFee = asset.currency.parse('13328 satoshis')
58
-
59
- // sending 2 transfer of a brc20
60
- const brc20 = {
61
- inscriptionIds: [
62
- '11199d28c76a6d2b82c35772ed4d1d7b5156dfe7aa385490ac0799c95187038fi0',
63
- '45199d28c76a6d2b82c35772ed4d1d7b5156dfe7aa385490ac0799c95187038fi0',
64
- ],
65
- }
66
-
67
- const params = {
68
- assetClientInterface,
69
- asset,
70
- address,
71
- options: { multipleAddressesEnabled: false, isSendAll: false, brc20 },
72
- expectedBalance,
73
- expectedFee,
74
- expectedTxData: inscriptionsSendUsignedTx,
75
- }
76
- await sendTxTest(params)
77
- },
78
-
79
- 'can send 1 nft from wallet 1': async ({ assetClientInterface, asset }) => {
80
- const address = 'bc1pkhrae7jrlj3wnz0vpm09tffndpu40vh6y4tl42pt2zdhfms575msdfwuew'
81
-
82
- const expectedBalance = asset.currency.parse('1136644 satoshis')
83
- const expectedFee = asset.currency.parse('10404 satoshis')
84
-
85
- // sending 2 transfer of a brc20
86
- const nft = {
87
- tokenId: '11199d28c76a6d2b82c35772ed4d1d7b5156dfe7aa385490ac0799c95187038fi0',
88
- }
89
-
90
- const params = {
91
- assetClientInterface,
92
- asset,
93
- address,
94
- options: { multipleAddressesEnabled: false, isSendAll: false, nft },
95
- expectedBalance,
96
- expectedFee,
97
- expectedTxData: nftSendUsignedTx,
98
- }
99
- await sendTxTest(params)
100
- },
101
- },
102
- })
103
- })