@exodus/bitcoin-plugin 1.3.0 → 1.4.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 (39) hide show
  1. package/jest.config.js +7 -0
  2. package/package.json +2 -3
  3. package/src/__tests__/address.test.js +142 -0
  4. package/src/__tests__/balances.test.js +67 -0
  5. package/src/__tests__/bitcoin-private-seed-safe-report.json +2754 -0
  6. package/src/__tests__/bitcoin-signing.test.js +184 -0
  7. package/src/__tests__/fee-data.test.js +61 -0
  8. package/src/__tests__/fee-estimator.test.js +174 -0
  9. package/src/__tests__/fixtures/segwit-all-unsigned-tx.js +87 -0
  10. package/src/__tests__/fixtures/segwit-legacy-change-unsigned-tx.js +38 -0
  11. package/src/__tests__/fixtures/segwit-segwit-change-unsigned-tx.js +96 -0
  12. package/src/__tests__/fixtures/taproot-15000sats-unsigned-tx.js +149 -0
  13. package/src/__tests__/fixtures/taproot-all-unsigned-tx.js +231 -0
  14. package/src/__tests__/fixtures/taproot-unsigned-tx.js +85 -0
  15. package/src/__tests__/get-size.test.js +70 -0
  16. package/src/__tests__/index.test.js +65 -0
  17. package/src/__tests__/keys.test.js +97 -0
  18. package/src/__tests__/monitor.integration.test.js +170 -0
  19. package/src/__tests__/move-funds.test.js +408 -0
  20. package/src/__tests__/parse-unsigned-tx.test.js +46 -0
  21. package/src/__tests__/reports/unit-test-safe-report.json +2790 -0
  22. package/src/__tests__/send-tx.test.js +145 -0
  23. package/src/__tests__/sign-tx.test.js +32 -0
  24. package/src/__tests__/unsigned-btclike-desktop.json +40 -0
  25. package/src/__tests__/wallet.test.js +78 -0
  26. package/src/create-asset.js +39 -4
  27. package/src/ordinals/__tests__/brc-20-client.integration.test.js +86 -0
  28. package/src/ordinals/__tests__/brc-20-utils.test.js +165 -0
  29. package/src/ordinals/__tests__/fixtures/inscriptions-send-usigned-tx.js +125 -0
  30. package/src/ordinals/__tests__/fixtures/nft-send-usigned-tx.js +97 -0
  31. package/src/ordinals/__tests__/monitor-ordinals-enabled-safe-report-with-inscriptions.json +2908 -0
  32. package/src/ordinals/__tests__/monitor-ordinals-enabled-safe-report.json +2906 -0
  33. package/src/ordinals/__tests__/monitor-ordinals-enabled.integration.test.js +16 -0
  34. package/src/ordinals/__tests__/nfts-api.test.js +221 -0
  35. package/src/ordinals/__tests__/ordinals-send-tx.test.js +103 -0
  36. package/src/ordinals/brc-20-balances-and-fee-adapter.js +41 -0
  37. package/src/ordinals/brc-20-utils.js +79 -0
  38. package/src/ordinals/create-token-factory.js +30 -0
  39. package/src/ordinals/reload-brc20-token-balances.js +154 -0
@@ -0,0 +1,184 @@
1
+ import BIP32 from '@exodus/bip32'
2
+ import { Transaction } from '@exodus/bitcoinjs-lib'
3
+ import HDKey from 'hdkey'
4
+ import { cloneDeep } from 'lodash'
5
+ import { createAsset } from '../index'
6
+ import { FINAL_SEQUENCE, RBF_SEQUENCE } from '@exodus/bitcoin-lib'
7
+ const asset = createAsset()
8
+
9
+ const createHdKey = (xpriv) => BIP32.create(HDKey.fromExtendedKey(xpriv))
10
+
11
+ const fixtures = {
12
+ accountFixture:
13
+ 'xprv9ysniBuk7BcZWMiPKvm9md3NnQi2XVV3XEQfNzsmMrZu4ksDXfiMD5ixiK4FZzS9ioPQxQfGqzEN8oA4fDKUiEML5UsfibQZi8Mr7Yxj6F5',
14
+ accountFixture84:
15
+ 'xprv9z3nXnHr3bvnFtVrHcVoASn5K3dDKCEVnqHoQ2zaAPKbcN9Nf7Tto8W4H2ygzvLKZ9cTRjxERpDybzBk5XJBjFcn4nfs3v1R8hadbuKaYkB',
16
+ accountFixture86:
17
+ 'xprv9zWgX6DKmGDe5AVhZYfgtorgxZfdUecw52Z3hgSm4YQyxqXdNJJQ7PrDBuvRJ9zBaEHGPxqQmpByPUhf6QP9xLRQ6KuTxVvXC53LtunxZ7c',
18
+ }
19
+
20
+ const hdKey = createHdKey(fixtures.accountFixture)
21
+ const hdKey84 = createHdKey(fixtures.accountFixture84)
22
+ const hdKey86 = createHdKey(fixtures.accountFixture86)
23
+
24
+ const createBitcoinSignedTransaction = asset.api.signTx
25
+
26
+ // Ported from desktop!
27
+
28
+ const unsignedTx = {
29
+ txData: {
30
+ inputs: [
31
+ {
32
+ txId: '2c6ec07fb117d2950b88ce6edec09c432d22878487841e76f001bedfd51c17a0', // P2PKH
33
+ vout: 0,
34
+ address: '12sLcvm1KXK5zBmXsAcYrUsqrRcrsuvaUT',
35
+ value: 1913796,
36
+ sequence: FINAL_SEQUENCE,
37
+ },
38
+ {
39
+ txId: '2568a15c1cf8c9eaa30ab2d3c688ef790f73a319569017b75b530e64a27712a0', // P2WPKH
40
+ vout: 0,
41
+ address: 'bc1qdz34y5kjwj5ej0rv5528mwjl49ufkl098l2gd9',
42
+ value: 10000000,
43
+ script: '001468a35252d274a9993c6ca5147dba5fa9789b7de5',
44
+ sequence: RBF_SEQUENCE,
45
+ },
46
+ ],
47
+ outputs: [
48
+ ['15oHUdk7k5N6uNb7d3JdbA7qfhph4n6bK6', 2100000],
49
+ ['bc1qv3ptd9qzv87klf34wnxxpmhlqgwu6fvp9q26yd', 8998000],
50
+ ],
51
+ },
52
+ txMeta: {
53
+ assetName: 'bitcoin',
54
+ addressPathsMap: {
55
+ '12sLcvm1KXK5zBmXsAcYrUsqrRcrsuvaUT': 'm/0/0',
56
+ bc1qdz34y5kjwj5ej0rv5528mwjl49ufkl098l2gd9: 'm/1/1',
57
+ },
58
+ rawTxs: [
59
+ {
60
+ txId: '2c6ec07fb117d2950b88ce6edec09c432d22878487841e76f001bedfd51c17a0',
61
+ rawData:
62
+ '01000000017e879a21dd0243d0a02bbb43a05332f59444df6ae69b37a1edd9b0477e40403f000000006a473044022013afbe1cb93e44ea15f119ab43251945b579599b6d82f9488c9e39a6a685d39702202313e215a94b3ddaba6c1fbc01aa22cb13c5db97a2a3651b850767990e93669e01210233a3643aea86194871d2ba38db890f3bd42bcc9b709e7eef7afaa9f467e74f91ffffffff02c4331d00000000001976a914147d4d251f681599fbea7884ac4021cff378524a88ac7cc67a00000000001976a9140bd42e2594a41443bcc963a1ef9135c4147a3f5588ac00000000',
63
+ },
64
+ ],
65
+ replayProtect: {},
66
+ hasChange: true,
67
+ },
68
+ }
69
+
70
+ test('create replaceable SignedTransaction for bitcoin ', async () => {
71
+ const { rawTx } = await createBitcoinSignedTransaction({
72
+ unsignedTx,
73
+ hdkeys: { 44: hdKey, 84: hdKey84 },
74
+ })
75
+
76
+ const { ins, outs } = Transaction.fromBuffer(rawTx)
77
+
78
+ ins.forEach(({ sequence }, index) => {
79
+ const { sequence: uSequence } = unsignedTx.txData.inputs[index]
80
+ expect(uSequence).toEqual(sequence)
81
+ })
82
+
83
+ outs.forEach(({ value }, index) => {
84
+ const [, uValue] = unsignedTx.txData.outputs[index]
85
+ expect(uValue).toEqual(value)
86
+ })
87
+ expect(ins[1].sequence).toBe(RBF_SEQUENCE)
88
+ })
89
+
90
+ test('non-witness output requires the full previous transaction', async () => {
91
+ const tx = cloneDeep(unsignedTx)
92
+ tx.txMeta.rawTxs = []
93
+ try {
94
+ await createBitcoinSignedTransaction({ unsignedTx: tx, hdkeys: { 44: hdKey, 84: hdKey84 } })
95
+ expect('Expected exception "Non-witness outputs require the full previous transaction"').toBe(
96
+ true
97
+ )
98
+ } catch (err) {
99
+ expect(err.message).toEqual('Non-witness outputs require the full previous transaction.')
100
+ }
101
+ })
102
+
103
+ test('spend from P2SH-P2WPKH using privateKeysAddressMap', async () => {
104
+ const tx = cloneDeep(unsignedTx)
105
+ const p2shAddress = '3JBEtYcWsH6kfLxkKxAgnScxSWHTWaVFJa'
106
+ tx.txData.inputs[0].address = p2shAddress
107
+
108
+ const privateKeysAddressMap = {
109
+ [p2shAddress]: asset.keys.encodePrivate(hdKey.derive('m/0/0').privateKey),
110
+ bc1qdz34y5kjwj5ej0rv5528mwjl49ufkl098l2gd9: asset.keys.encodePrivate(
111
+ hdKey84.derive('m/1/1').privateKey
112
+ ),
113
+ }
114
+
115
+ const { txId, rawTx } = await createBitcoinSignedTransaction({
116
+ unsignedTx: tx,
117
+ privateKeysAddressMap,
118
+ })
119
+
120
+ const { ins } = Transaction.fromBuffer(rawTx)
121
+ const p2shInput = ins[0]
122
+
123
+ expect(txId.toString('hex')).toBe(
124
+ '3a0e3c9e76cf8aed93c1f5a5f212a7de6e88452d125a0bf7aa7aa92d8b18697c'
125
+ )
126
+ expect(p2shInput.witness[0].toString('hex')).toBe(
127
+ '30440220013ecaaa22220e32f024fc0537db877e7897dd3ee72d5a258b056843a4fb525a02201bf51913a87f3629fb1ae479bcd071ec4a45e0a932b99bc151b11da2a5ae3c7701'
128
+ )
129
+ expect(p2shInput.witness[1].toString('hex')).toBe(
130
+ '027135776e6628b3da577e6775193bc219ac054034eda1041138313bc1b4f1110d'
131
+ )
132
+ })
133
+
134
+ test('spend from P2SH-P2WPKH using hdkeys', async () => {
135
+ const tx = cloneDeep(unsignedTx)
136
+ const p2shAddress = '3JBEtYcWsH6kfLxkKxAgnScxSWHTWaVFJa'
137
+ tx.txData.inputs[0].address = p2shAddress
138
+ tx.txMeta.addressPathsMap[p2shAddress] = 'm/0/0'
139
+
140
+ const { txId, rawTx } = await createBitcoinSignedTransaction({
141
+ unsignedTx: tx,
142
+ hdkeys: { 44: hdKey, 49: hdKey, 84: hdKey84, 86: hdKey86 }, // Test is coming from desktop and it picked 44 as the purpose when addresses was 3J...
143
+ })
144
+
145
+ const { ins } = Transaction.fromBuffer(rawTx)
146
+ const p2shInput = ins[0]
147
+
148
+ expect(txId.toString('hex')).toBe(
149
+ '3a0e3c9e76cf8aed93c1f5a5f212a7de6e88452d125a0bf7aa7aa92d8b18697c'
150
+ )
151
+ expect(p2shInput.witness[0].toString('hex')).toBe(
152
+ '30440220013ecaaa22220e32f024fc0537db877e7897dd3ee72d5a258b056843a4fb525a02201bf51913a87f3629fb1ae479bcd071ec4a45e0a932b99bc151b11da2a5ae3c7701'
153
+ )
154
+ expect(p2shInput.witness[1].toString('hex')).toBe(
155
+ '027135776e6628b3da577e6775193bc219ac054034eda1041138313bc1b4f1110d'
156
+ )
157
+ })
158
+
159
+ test('spend from P2TR', async () => {
160
+ const tx = cloneDeep(unsignedTx)
161
+ const p2trAddress = 'bc1p3efq8ujsj0qr5xvms7mv89p8cz0crqdtuxe9ms6grqgxc9sgsntslthf6w'
162
+ tx.txData.inputs.push({
163
+ txId: 'f633a68122e25dc2a8d3e223a5d49f914a70015db654a4d2f7885c5c4299bf5c',
164
+ vout: 0,
165
+ address: p2trAddress,
166
+ value: 22961,
167
+ script: '51208e5203f25093c03a199b87b6c39427c09f8181abe1b25dc34818106c160884d7',
168
+ sequence: FINAL_SEQUENCE,
169
+ })
170
+ tx.txMeta.addressPathsMap[p2trAddress] = 'm/0/2'
171
+
172
+ const { txId, rawTx } = await createBitcoinSignedTransaction({
173
+ unsignedTx: tx,
174
+ hdkeys: { 44: hdKey, 84: hdKey84, 86: hdKey86 },
175
+ })
176
+ expect(txId.toString('hex')).toEqual(
177
+ '71fbc69242791e904a0aa9df3c71ad89e4ec7841d50d7852c992a2f385b08769'
178
+ )
179
+
180
+ const { ins } = Transaction.fromBuffer(rawTx)
181
+ const p2trInput = ins[2]
182
+ expect(p2trInput.witness.length).toEqual(1)
183
+ expect(p2trInput.witness[0].length).toEqual(64)
184
+ })
@@ -0,0 +1,61 @@
1
+ import { asset as bitcoin } from '@exodus/bitcoin-meta'
2
+ import { asset as bitcoinregtest } from '@exodus/bitcoinregtest-meta'
3
+ import { asset as bitcointestnet } from '@exodus/bitcointestnet-meta'
4
+
5
+ import { FeeData } from '@exodus/asset-lib'
6
+ import { bitcoinFeeDataFactory, _defaults } from '../fee-data'
7
+
8
+ describe('bitcoin fee data', () => {
9
+ const assertBitcoinFeeData = (feeData) => {
10
+ test(`${feeData.currency} feeData should we complete`, () => {
11
+ expect(feeData).toBeDefined()
12
+ expect(feeData instanceof FeeData).toBe(true)
13
+ expect(feeData.currency).toBeDefined()
14
+ expect(Object.entries(_defaults).length).toEqual(10)
15
+ Object.entries(_defaults).forEach(([field, value]) => {
16
+ if (typeof value === 'string')
17
+ expect(feeData[field].equals(feeData.currency.parse(value))).toEqual(true)
18
+ else {
19
+ expect(feeData[field]).toEqual(value)
20
+ }
21
+ })
22
+ })
23
+ }
24
+
25
+ const overrideFields = (feeData) => {
26
+ test(`${feeData.currency} feeData update fields`, () => {
27
+ expect(feeData).toBeDefined()
28
+ expect(feeData instanceof FeeData).toBe(true)
29
+ expect(feeData.currency).toBeDefined()
30
+ const newFeeData = feeData.update({
31
+ maxExtraCpfpFee: 500000,
32
+ rbfBumpFeeBlocks: 10,
33
+ rbfBumpFeeThreshold: 0.9,
34
+ iDotExist: 66,
35
+ })
36
+ expect(newFeeData).toBeDefined()
37
+ expect(newFeeData.currency).toBeDefined()
38
+ expect(newFeeData instanceof FeeData).toBe(true)
39
+ expect(newFeeData.maxExtraCpfpFee).toEqual(500000)
40
+ expect(newFeeData.rbfBumpFeeBlocks).toEqual(10)
41
+ expect(newFeeData.rbfBumpFeeThreshold).toEqual(0.9)
42
+ expect(newFeeData.iDotExist).toEqual(66) // still updated
43
+ })
44
+ }
45
+
46
+ describe('bitcoin feeData should be complete', () => {
47
+ const feeData = bitcoinFeeDataFactory(bitcoin.currency)
48
+ assertBitcoinFeeData(feeData)
49
+ overrideFields(feeData)
50
+ })
51
+ describe('bitcoinregtest feeData should be complete', () => {
52
+ const feeData = bitcoinFeeDataFactory(bitcoinregtest.currency)
53
+ assertBitcoinFeeData(feeData)
54
+ overrideFields(feeData)
55
+ })
56
+ describe('bitcointestnet feeData should be complete', () => {
57
+ const feeData = bitcoinFeeDataFactory(bitcointestnet.currency)
58
+ assertBitcoinFeeData(feeData)
59
+ overrideFields(feeData)
60
+ })
61
+ })
@@ -0,0 +1,174 @@
1
+ import { createAsset } from '../index'
2
+ import { asset as baseAsset } from '@exodus/bitcoin-meta'
3
+ import { getPrivateSeed, walletTester } from '@exodus/assets-testing'
4
+ import path from 'path'
5
+ import { mapValues } from 'lodash'
6
+
7
+ const asset = createAsset()
8
+
9
+ const importSafeReportFile = path.join(__dirname, 'reports/unit-test-safe-report.json')
10
+
11
+ describe(`bitcoin fees test`, () => {
12
+ async function resolveAmounts({ assetClientInterface, walletAccount, amount, isSendAll }) {
13
+ const assetName = asset.name
14
+
15
+ const feeData = await assetClientInterface.getFeeConfig({ assetName })
16
+ const accountState = await assetClientInterface.getAccountState({
17
+ assetName,
18
+ walletAccount,
19
+ })
20
+ const txSet = await assetClientInterface.getTxLog({ assetName, walletAccount })
21
+ const { fee, extraFee } = asset.api.getFee({
22
+ asset: baseAsset,
23
+ accountState,
24
+ txSet,
25
+ feeData,
26
+ amount,
27
+ isSendAll,
28
+ })
29
+ const availableBalance = asset.getAvailableBalance({
30
+ asset: baseAsset,
31
+ accountState,
32
+ txSet,
33
+ feeData,
34
+ amount,
35
+ isSendAll,
36
+ })
37
+
38
+ const spendableBalance = asset.getSpendableBalance({
39
+ asset: baseAsset,
40
+ accountState,
41
+ txSet,
42
+ feeData,
43
+ amount,
44
+ isSendAll,
45
+ })
46
+ const { balance } = asset.api.getBalances({ asset, accountState, txLog: txSet })
47
+ const amounts = {
48
+ balance,
49
+ fee,
50
+ availableBalance,
51
+ spendableBalance,
52
+ extraFee,
53
+ }
54
+ return {
55
+ ...amounts,
56
+ all: mapValues(amounts, (balance) => balance.toBaseString({ unit: true })),
57
+ }
58
+ }
59
+
60
+ walletTester({
61
+ asset,
62
+ seed: getPrivateSeed(),
63
+ walletAccountCount: 4,
64
+ importSafeReportFile,
65
+ expectedAddresses: {
66
+ bitcoin_44_exodus_0_0_0: '1Azpg7QEdQ8FHhNLzEpbpo1Uowh3t7B3Ex',
67
+ bitcoin_44_exodus_1_0_0: '1AELPVvN9aDdWsR7hCkpVgA2WAuDjuPDB3',
68
+ bitcoin_44_exodus_2_0_0: '14Gmj5bDcdwq9kCeYboSfNBECfrZ59podu',
69
+ bitcoin_44_exodus_3_0_0: '1cYFm3evxxqJ1r2Fz3mtLWd8XVzTJwd6E',
70
+ bitcoin_84_exodus_0_0_0: 'bc1qz0p68ljq4xslgl09g8rdfzjse7dshm4w6jsh48',
71
+ bitcoin_84_exodus_1_0_0: 'bc1qgxz38crda20mlre427ygezgu67kqvqfr4heayn',
72
+ bitcoin_84_exodus_2_0_0: 'bc1q80wm35xel29d2xd79e4uveudejwmh3jnecvnl4',
73
+ bitcoin_84_exodus_3_0_0: 'bc1q3yt56war2meuc0jkp85y9ty58flkwf9nxmt2rk',
74
+ bitcoin_86_exodus_0_0_0: 'bc1pegpjkdt4mhexjw2k59jewegv2v6lxekapwjf6sk7euel03vnhfkq8dqhrt',
75
+ bitcoin_86_exodus_1_0_0: 'bc1pkhrae7jrlj3wnz0vpm09tffndpu40vh6y4tl42pt2zdhfms575msdfwuew',
76
+ bitcoin_86_exodus_2_0_0: 'bc1p22zuaxepunt587sfjjahmlr844qa99p4xsjgtfxzlhk2x2xjcu7sh9ljqu',
77
+ bitcoin_86_exodus_3_0_0: 'bc1p9zm5z3wqfqkdrtkjg9uhxk3cp00ws4duxver0x74c6crq8adzqxs7hs8lt',
78
+ },
79
+ tests: {
80
+ 'resolve fee of sending 10 satoshis from exodus_0': async ({ assetClientInterface }) => {
81
+ const walletAccount = `exodus_0`
82
+ const amount = asset.currency.parse('10 satoshis')
83
+ const { balance, fee, spendableBalance, availableBalance, all } = await resolveAmounts({
84
+ assetClientInterface,
85
+ walletAccount,
86
+ amount,
87
+ })
88
+ expect(all).toEqual({
89
+ availableBalance: '94972 satoshis',
90
+ balance: '110000 satoshis',
91
+ fee: '15028 satoshis',
92
+ extraFee: '0 satoshis',
93
+ spendableBalance: '110000 satoshis',
94
+ })
95
+
96
+ expect(balance.sub(fee).toBaseString({ unit: true })).toEqual(
97
+ availableBalance.toBaseString({ unit: true })
98
+ )
99
+
100
+ expect(spendableBalance.sub(fee).toBaseString({ unit: true })).toEqual(
101
+ availableBalance.toBaseString({ unit: true })
102
+ )
103
+ },
104
+
105
+ 'resolve fee of sending 10 satoshis from exodus_1': async ({ assetClientInterface }) => {
106
+ const walletAccount = `exodus_1`
107
+ const amount = asset.currency.parse('10 satoshis')
108
+ const { balance, fee, spendableBalance, availableBalance, all } = await resolveAmounts({
109
+ assetClientInterface,
110
+ walletAccount,
111
+ amount,
112
+ })
113
+ expect(all).toEqual({
114
+ availableBalance: '1306719 satoshis',
115
+ balance: '1321067 satoshis',
116
+ fee: '14348 satoshis',
117
+ extraFee: '0 satoshis',
118
+ spendableBalance: '1321067 satoshis',
119
+ })
120
+
121
+ expect(balance.sub(fee).toBaseString({ unit: true })).toEqual(
122
+ availableBalance.toBaseString({ unit: true })
123
+ )
124
+ expect(spendableBalance.sub(fee).toBaseString({ unit: true })).toEqual(
125
+ availableBalance.toBaseString({ unit: true })
126
+ )
127
+ },
128
+
129
+ 'resolve fee of sending all from exodus_0': async ({ assetClientInterface }) => {
130
+ const walletAccount = `exodus_0`
131
+ const { balance, fee, availableBalance, spendableBalance, all } = await resolveAmounts({
132
+ assetClientInterface,
133
+ walletAccount,
134
+ isSendAll: true,
135
+ })
136
+ expect(all).toEqual({
137
+ availableBalance: '97080 satoshis',
138
+ balance: '110000 satoshis',
139
+ fee: '12920 satoshis',
140
+ extraFee: '0 satoshis',
141
+ spendableBalance: '110000 satoshis',
142
+ })
143
+ expect(balance.sub(fee).toBaseString({ unit: true })).toEqual(
144
+ availableBalance.toBaseString({ unit: true })
145
+ )
146
+ expect(spendableBalance.sub(fee).toBaseString({ unit: true })).toEqual(
147
+ availableBalance.toBaseString({ unit: true })
148
+ )
149
+ },
150
+
151
+ 'resolve fee of sending all from exodus_1': async ({ assetClientInterface }) => {
152
+ const walletAccount = `exodus_1`
153
+ const { balance, fee, availableBalance, spendableBalance, all } = await resolveAmounts({
154
+ assetClientInterface,
155
+ walletAccount,
156
+ isSendAll: true,
157
+ })
158
+ expect(all).toEqual({
159
+ availableBalance: '1271631 satoshis',
160
+ balance: '1321067 satoshis',
161
+ fee: '49436 satoshis',
162
+ extraFee: '0 satoshis',
163
+ spendableBalance: '1321067 satoshis',
164
+ })
165
+ expect(balance.sub(fee).toBaseString({ unit: true })).toEqual(
166
+ availableBalance.toBaseString({ unit: true })
167
+ )
168
+ expect(spendableBalance.sub(fee).toBaseString({ unit: true })).toEqual(
169
+ availableBalance.toBaseString({ unit: true })
170
+ )
171
+ },
172
+ },
173
+ })
174
+ })
@@ -0,0 +1,87 @@
1
+ export default {
2
+ accountIndex: 0,
3
+ rawTx:
4
+ '020000000001022ed3c9917a29f91be86eae85c7dd5191d5fb8dacfef7ecaf2f6ab680e8b7cb710100000000fdffffff3a093fcd7edd55e7c6cc76f86a38116acef985f8926d66de62d31714d8ba6abd0000000000fdffffff01387b010000000000225120b5c7dcfa43fca2e989ec0ede55a533687957b2fa2557faa82b509b74ee14f537024830450221009dfc1edd0af29170139cb14665cc6ac755ac53c3981b431cf719863248e23c6c022037ef3c3b5cae5caff013da8b30e05f81bd16ba7801f1f90369399baed55cfc36012102caaad5f27bf56e3571535f5cfa9411887fc262fe8b61f37104aca826c154712c0247304402201a6a6ea75961126aa276d4873a58b317b26ca2447c8dcff4175e20302e9405e202201620f388e02b1970c64edffe6f83c7a872b72d0087706370c1094427fd7c6114012102caaad5f27bf56e3571535f5cfa9411887fc262fe8b61f37104aca826c154712c00000000',
5
+ txId: '257efd0b04349ea6d2de69d81799f6ad46c531e541466d15c21a6d43f3471b31',
6
+ virtualSize: 190,
7
+ txLog: {
8
+ coinAmount: '-0.0009708 BTC',
9
+ coinName: 'bitcoin',
10
+ confirmations: 0,
11
+ data: {
12
+ blockHeight: 768520,
13
+ blocksSeen: 0,
14
+ feePerKB: 68000,
15
+ inputs: {
16
+ bc1qz0p68ljq4xslgl09g8rdfzjse7dshm4w6jsh48: {
17
+ address: 'bc1qz0p68ljq4xslgl09g8rdfzjse7dshm4w6jsh48',
18
+ path: 'm/0/0',
19
+ utxos: [
20
+ {
21
+ confirmations: 1,
22
+ rbfEnabled: true,
23
+ script: '001413c3a3fe40a9a1f47de541c6d48a50cf9b0beeae',
24
+ txId: '71cbb7e880b66a2fafecf7feac8dfbd59151ddc785ae6ee81bf9297a91c9d32e',
25
+ value: '0.0001 BTC',
26
+ vout: 1,
27
+ },
28
+ {
29
+ confirmations: 1,
30
+ rbfEnabled: true,
31
+ script: '001413c3a3fe40a9a1f47de541c6d48a50cf9b0beeae',
32
+ txId: 'bd6abad81417d362de666d92f885f9ce6a11386af876ccc6e755dd7ecd3f093a',
33
+ value: '0.001 BTC',
34
+ vout: 0,
35
+ },
36
+ ],
37
+ },
38
+ },
39
+ rbfEnabled: true,
40
+ sent: [
41
+ {
42
+ address: 'bc1pkhrae7jrlj3wnz0vpm09tffndpu40vh6y4tl42pt2zdhfms575msdfwuew',
43
+ amount: {
44
+ type: 'NumberUnit',
45
+ unit: 'BTC',
46
+ unitType: 'BTC',
47
+ value: '0.0009708',
48
+ },
49
+ },
50
+ ],
51
+ },
52
+ date: 'SOME DATE',
53
+ feeAmount: '12920 satoshis',
54
+ feeCoinName: 'bitcoin',
55
+ txId: '257efd0b04349ea6d2de69d81799f6ad46c531e541466d15c21a6d43f3471b31',
56
+ },
57
+ unsignedTx: {
58
+ txData: {
59
+ inputs: [
60
+ {
61
+ address: 'bc1qz0p68ljq4xslgl09g8rdfzjse7dshm4w6jsh48',
62
+ script: '001413c3a3fe40a9a1f47de541c6d48a50cf9b0beeae',
63
+ sequence: 4294967293,
64
+ txId: '71cbb7e880b66a2fafecf7feac8dfbd59151ddc785ae6ee81bf9297a91c9d32e',
65
+ value: 10000,
66
+ vout: 1,
67
+ },
68
+ {
69
+ address: 'bc1qz0p68ljq4xslgl09g8rdfzjse7dshm4w6jsh48',
70
+ script: '001413c3a3fe40a9a1f47de541c6d48a50cf9b0beeae',
71
+ sequence: 4294967293,
72
+ txId: 'bd6abad81417d362de666d92f885f9ce6a11386af876ccc6e755dd7ecd3f093a',
73
+ value: 100000,
74
+ vout: 0,
75
+ },
76
+ ],
77
+ outputs: [['bc1pkhrae7jrlj3wnz0vpm09tffndpu40vh6y4tl42pt2zdhfms575msdfwuew', 97080]],
78
+ },
79
+ txMeta: {
80
+ addressPathsMap: {
81
+ bc1qz0p68ljq4xslgl09g8rdfzjse7dshm4w6jsh48: 'm/0/0',
82
+ },
83
+ blockHeight: 768520,
84
+ rawTxs: [],
85
+ },
86
+ },
87
+ }
@@ -0,0 +1,38 @@
1
+ export default {
2
+ txId: 'ed27acb1c56dd6b74d2e706dcff34eb6a419012e35ab7af85ad56e70cf110142',
3
+ rawTx:
4
+ '020000000001022ed3c9917a29f91be86eae85c7dd5191d5fb8dacfef7ecaf2f6ab680e8b7cb710100000000fdffffff3a093fcd7edd55e7c6cc76f86a38116acef985f8926d66de62d31714d8ba6abd0000000000fdffffff020a00000000000000225120b5c7dcfa43fca2e989ec0ede55a533687957b2fa2557faa82b509b74ee14f537f2720100000000001976a9146da8a36d9bad2762d037ef60f974df6fd4c7798c88ac02483045022100b3b9b805a1f4c516f6c3e273f02cc16f4776c6f92c4c19754ff3c5e55597069d022079eb1a337b0ff885dd4201d2a75a5be6c25ca03992e222ab17f71780a91fb800012102caaad5f27bf56e3571535f5cfa9411887fc262fe8b61f37104aca826c154712c02473044022012936ea226321c8670895fc85535e998521ba6970a0991e484bc0af3d897b8c80220688ff722f2211bd3435af009602c0e9bca8ccc87860058f140573cfa98d1b177012102caaad5f27bf56e3571535f5cfa9411887fc262fe8b61f37104aca826c154712c00000000',
5
+ accountIndex: 0,
6
+ virtualSize: 224,
7
+ unsignedTx: {
8
+ txData: {
9
+ inputs: [
10
+ {
11
+ txId: '71cbb7e880b66a2fafecf7feac8dfbd59151ddc785ae6ee81bf9297a91c9d32e',
12
+ vout: 1,
13
+ address: 'bc1qz0p68ljq4xslgl09g8rdfzjse7dshm4w6jsh48',
14
+ value: 10000,
15
+ script: '001413c3a3fe40a9a1f47de541c6d48a50cf9b0beeae',
16
+ sequence: 4294967293,
17
+ },
18
+ {
19
+ txId: 'bd6abad81417d362de666d92f885f9ce6a11386af876ccc6e755dd7ecd3f093a',
20
+ vout: 0,
21
+ address: 'bc1qz0p68ljq4xslgl09g8rdfzjse7dshm4w6jsh48',
22
+ value: 100000,
23
+ script: '001413c3a3fe40a9a1f47de541c6d48a50cf9b0beeae',
24
+ sequence: 4294967293,
25
+ },
26
+ ],
27
+ outputs: [
28
+ ['bc1pkhrae7jrlj3wnz0vpm09tffndpu40vh6y4tl42pt2zdhfms575msdfwuew', 10],
29
+ ['1Azpg7QEdQ8FHhNLzEpbpo1Uowh3t7B3Ex', 94962],
30
+ ],
31
+ },
32
+ txMeta: {
33
+ addressPathsMap: { bc1qz0p68ljq4xslgl09g8rdfzjse7dshm4w6jsh48: 'm/0/0' },
34
+ blockHeight: 768520,
35
+ rawTxs: [],
36
+ },
37
+ },
38
+ }
@@ -0,0 +1,96 @@
1
+ export default {
2
+ accountIndex: 0,
3
+ rawTx:
4
+ '020000000001022ed3c9917a29f91be86eae85c7dd5191d5fb8dacfef7ecaf2f6ab680e8b7cb710100000000fdffffff3a093fcd7edd55e7c6cc76f86a38116acef985f8926d66de62d31714d8ba6abd0000000000fdffffff020a00000000000000225120b5c7dcfa43fca2e989ec0ede55a533687957b2fa2557faa82b509b74ee14f537f27201000000000016001413c3a3fe40a9a1f47de541c6d48a50cf9b0beeae02473044022032dc8c29529137f22cb114c86be2163d9585427e1ef1ce034f336d797bfec3070220458d336a6db3f2a36aaf23a507152dee1e734328bb6bdba32afd255390cccdaa012102caaad5f27bf56e3571535f5cfa9411887fc262fe8b61f37104aca826c154712c0247304402202017936d628d2885bb8af3efe9d2e21334c5da37eed410066f5a0140b61886ab022068fb8cc2b69a82f07162a451907de7ca79e01094fb6220fdb4e4114a3eae1a88012102caaad5f27bf56e3571535f5cfa9411887fc262fe8b61f37104aca826c154712c00000000',
5
+ txId: '5786e2480b5b94047cab40157f7627c6f96d653a0fc9c3f4f9cf56a132f15318',
6
+ virtualSize: 220,
7
+ txLog: {
8
+ coinAmount: '-0.0000001 BTC',
9
+ coinName: 'bitcoin',
10
+ confirmations: 0,
11
+ data: {
12
+ blockHeight: 768520,
13
+ blocksSeen: 0,
14
+ changeAddress: {
15
+ address: 'bc1qz0p68ljq4xslgl09g8rdfzjse7dshm4w6jsh48',
16
+ meta: {
17
+ path: 'm/0/0',
18
+ },
19
+ },
20
+ feePerKB: 68309,
21
+ inputs: {
22
+ bc1qz0p68ljq4xslgl09g8rdfzjse7dshm4w6jsh48: {
23
+ address: 'bc1qz0p68ljq4xslgl09g8rdfzjse7dshm4w6jsh48',
24
+ path: 'm/0/0',
25
+ utxos: [
26
+ {
27
+ confirmations: 1,
28
+ rbfEnabled: true,
29
+ script: '001413c3a3fe40a9a1f47de541c6d48a50cf9b0beeae',
30
+ txId: '71cbb7e880b66a2fafecf7feac8dfbd59151ddc785ae6ee81bf9297a91c9d32e',
31
+ value: '0.0001 BTC',
32
+ vout: 1,
33
+ },
34
+ {
35
+ confirmations: 1,
36
+ rbfEnabled: true,
37
+ script: '001413c3a3fe40a9a1f47de541c6d48a50cf9b0beeae',
38
+ txId: 'bd6abad81417d362de666d92f885f9ce6a11386af876ccc6e755dd7ecd3f093a',
39
+ value: '0.001 BTC',
40
+ vout: 0,
41
+ },
42
+ ],
43
+ },
44
+ },
45
+ rbfEnabled: true,
46
+ sent: [
47
+ {
48
+ address: 'bc1pkhrae7jrlj3wnz0vpm09tffndpu40vh6y4tl42pt2zdhfms575msdfwuew',
49
+ amount: {
50
+ type: 'NumberUnit',
51
+ unit: 'satoshis',
52
+ unitType: 'BTC',
53
+ value: '10',
54
+ },
55
+ },
56
+ ],
57
+ },
58
+ date: 'SOME DATE',
59
+ feeAmount: '15028 satoshis',
60
+ feeCoinName: 'bitcoin',
61
+ txId: '5786e2480b5b94047cab40157f7627c6f96d653a0fc9c3f4f9cf56a132f15318',
62
+ },
63
+ unsignedTx: {
64
+ txData: {
65
+ inputs: [
66
+ {
67
+ address: 'bc1qz0p68ljq4xslgl09g8rdfzjse7dshm4w6jsh48',
68
+ script: '001413c3a3fe40a9a1f47de541c6d48a50cf9b0beeae',
69
+ sequence: 4294967293,
70
+ txId: '71cbb7e880b66a2fafecf7feac8dfbd59151ddc785ae6ee81bf9297a91c9d32e',
71
+ value: 10000,
72
+ vout: 1,
73
+ },
74
+ {
75
+ address: 'bc1qz0p68ljq4xslgl09g8rdfzjse7dshm4w6jsh48',
76
+ script: '001413c3a3fe40a9a1f47de541c6d48a50cf9b0beeae',
77
+ sequence: 4294967293,
78
+ txId: 'bd6abad81417d362de666d92f885f9ce6a11386af876ccc6e755dd7ecd3f093a',
79
+ value: 100000,
80
+ vout: 0,
81
+ },
82
+ ],
83
+ outputs: [
84
+ ['bc1pkhrae7jrlj3wnz0vpm09tffndpu40vh6y4tl42pt2zdhfms575msdfwuew', 10],
85
+ ['bc1qz0p68ljq4xslgl09g8rdfzjse7dshm4w6jsh48', 94962],
86
+ ],
87
+ },
88
+ txMeta: {
89
+ addressPathsMap: {
90
+ bc1qz0p68ljq4xslgl09g8rdfzjse7dshm4w6jsh48: 'm/0/0',
91
+ },
92
+ blockHeight: 768520,
93
+ rawTxs: [],
94
+ },
95
+ },
96
+ }