@psf/bch-js 5.4.0 → 6.2.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.
- package/.on-save.json +8 -0
- package/LICENSE.md +1 -2
- package/package.json +6 -6
- package/src/slp/utils.js +0 -1762
- package/src/transaction.js +1 -498
- package/src/utxo.js +0 -270
- package/test/integration/chains/bchn/utxo-integration.js +0 -107
- package/test/integration/slp.js +0 -470
- package/test/unit/slp-utils.js +0 -2105
- package/test/unit/transaction-unit.js +4 -688
- package/test/unit/utxo-unit.js +0 -131
- package/test/integration/chains/abc/slp.js +0 -226
- package/test/integration/chains/bchn-no-wl-slpdb/rawtransaction.js +0 -71
- package/test/integration/chains/bchn-no-wl-slpdb/slp.js +0 -273
- package/test/integration/chains/bchn-no-wl-slpdb/utxo-integration.js +0 -105
package/test/unit/utxo-unit.js
CHANGED
|
@@ -15,137 +15,6 @@ describe('#utxo', () => {
|
|
|
15
15
|
beforeEach(() => (sandbox = sinon.createSandbox()))
|
|
16
16
|
afterEach(() => sandbox.restore())
|
|
17
17
|
|
|
18
|
-
describe('#getOld', () => {
|
|
19
|
-
it('should get hydrated and filtered UTXOs for an address', async () => {
|
|
20
|
-
// Mock dependencies.
|
|
21
|
-
sandbox.stub(bchjs.Utxo.electrumx, 'utxo').resolves(mockData.mockUtxoData)
|
|
22
|
-
sandbox
|
|
23
|
-
.stub(bchjs.Utxo.slp.Utils, 'hydrateUtxos')
|
|
24
|
-
.resolves(mockData.mockHydratedUtxos)
|
|
25
|
-
|
|
26
|
-
const addr = 'simpleledger:qzv3zz2trz0xgp6a96lu4m6vp2nkwag0kvyucjzqt9'
|
|
27
|
-
|
|
28
|
-
const result = await bchjs.Utxo.getOld(addr)
|
|
29
|
-
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
|
|
30
|
-
|
|
31
|
-
assert.isArray(result)
|
|
32
|
-
assert.property(result[0], 'address')
|
|
33
|
-
assert.property(result[0], 'bchUtxos')
|
|
34
|
-
assert.property(result[0], 'nullUtxos')
|
|
35
|
-
assert.property(result[0], 'slpUtxos')
|
|
36
|
-
assert.isArray(result[0].bchUtxos)
|
|
37
|
-
assert.isArray(result[0].nullUtxos)
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
it('should catch and throw an error', async () => {
|
|
41
|
-
try {
|
|
42
|
-
// Force an error
|
|
43
|
-
sandbox
|
|
44
|
-
.stub(bchjs.Utxo.electrumx, 'utxo')
|
|
45
|
-
.rejects(new Error('test error'))
|
|
46
|
-
|
|
47
|
-
const addr = 'simpleledger:qzv3zz2trz0xgp6a96lu4m6vp2nkwag0kvyucjzqt9'
|
|
48
|
-
|
|
49
|
-
await bchjs.Utxo.getOld(addr)
|
|
50
|
-
|
|
51
|
-
assert.fail('Unexpected code path')
|
|
52
|
-
} catch (err) {
|
|
53
|
-
assert.include(err.message, 'test error')
|
|
54
|
-
}
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
it('should handle an array of addresses', async () => {
|
|
58
|
-
// Mock dependencies.
|
|
59
|
-
sandbox.stub(bchjs.Utxo.electrumx, 'utxo').resolves({ utxos: {} })
|
|
60
|
-
sandbox
|
|
61
|
-
.stub(bchjs.Utxo.slp.Utils, 'hydrateUtxos')
|
|
62
|
-
.resolves(mockData.mockTwoHydratedAddrs)
|
|
63
|
-
|
|
64
|
-
const addr = [
|
|
65
|
-
'simpleledger:qzv3zz2trz0xgp6a96lu4m6vp2nkwag0kvyucjzqt9',
|
|
66
|
-
'bitcoincash:qqh793x9au6ehvh7r2zflzguanlme760wuzehgzjh9'
|
|
67
|
-
]
|
|
68
|
-
|
|
69
|
-
const result = await bchjs.Utxo.getOld(addr)
|
|
70
|
-
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
|
|
71
|
-
|
|
72
|
-
assert.isArray(result)
|
|
73
|
-
assert.equal(result.length, 2)
|
|
74
|
-
assert.property(result[0], 'address')
|
|
75
|
-
assert.property(result[0], 'bchUtxos')
|
|
76
|
-
assert.property(result[0], 'nullUtxos')
|
|
77
|
-
assert.property(result[0], 'slpUtxos')
|
|
78
|
-
assert.isArray(result[0].bchUtxos)
|
|
79
|
-
assert.isArray(result[0].nullUtxos)
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
it('should throw an error for array of 21 elements', async () => {
|
|
83
|
-
try {
|
|
84
|
-
const addr = 'simpleledger:qzv3zz2trz0xgp6a96lu4m6vp2nkwag0kvyucjzqt9'
|
|
85
|
-
|
|
86
|
-
const addrs = []
|
|
87
|
-
for (let i = 0; i < 21; i++) {
|
|
88
|
-
addrs.push(addr)
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
await bchjs.Utxo.getOld(addrs)
|
|
92
|
-
|
|
93
|
-
assert.fail('Unexpected code path')
|
|
94
|
-
} catch (err) {
|
|
95
|
-
assert.include(err.message, 'Too many elements, 20 max.')
|
|
96
|
-
}
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
it('should handle NFTs and minting batons', async () => {
|
|
100
|
-
// Mock dependencies.
|
|
101
|
-
sandbox.stub(bchjs.Utxo.electrumx, 'utxo').resolves({ utxos: {} })
|
|
102
|
-
sandbox
|
|
103
|
-
.stub(bchjs.Utxo.slp.Utils, 'hydrateUtxos')
|
|
104
|
-
.resolves(mockData.mockEveryUtxoType)
|
|
105
|
-
|
|
106
|
-
const addr = 'simpleledger:qrm0c67wwqh0w7wjxua2gdt2xggnm90xwsr5k22euj'
|
|
107
|
-
|
|
108
|
-
const result = await bchjs.Utxo.getOld(addr)
|
|
109
|
-
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
|
|
110
|
-
|
|
111
|
-
assert.isArray(result)
|
|
112
|
-
assert.property(result[0], 'address')
|
|
113
|
-
assert.property(result[0], 'bchUtxos')
|
|
114
|
-
assert.property(result[0], 'nullUtxos')
|
|
115
|
-
assert.property(result[0], 'slpUtxos')
|
|
116
|
-
assert.isArray(result[0].bchUtxos)
|
|
117
|
-
assert.isArray(result[0].nullUtxos)
|
|
118
|
-
|
|
119
|
-
assert.isArray(result[0].slpUtxos.type1.mintBatons)
|
|
120
|
-
assert.isArray(result[0].slpUtxos.type1.tokens)
|
|
121
|
-
assert.isArray(result[0].slpUtxos.nft.groupMintBatons)
|
|
122
|
-
assert.isArray(result[0].slpUtxos.nft.groupTokens)
|
|
123
|
-
assert.isArray(result[0].slpUtxos.nft.tokens)
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
it('should use the whitelist when flag is set', async () => {
|
|
127
|
-
// Mock dependencies.
|
|
128
|
-
sandbox.stub(bchjs.Utxo.electrumx, 'utxo').resolves(mockData.mockUtxoData)
|
|
129
|
-
sandbox
|
|
130
|
-
.stub(bchjs.Utxo.slp.Utils, 'hydrateUtxosWL')
|
|
131
|
-
.resolves(mockData.mockHydratedUtxos)
|
|
132
|
-
|
|
133
|
-
const addr = 'simpleledger:qzv3zz2trz0xgp6a96lu4m6vp2nkwag0kvyucjzqt9'
|
|
134
|
-
const useWhitelist = true
|
|
135
|
-
|
|
136
|
-
const result = await bchjs.Utxo.getOld(addr, useWhitelist)
|
|
137
|
-
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
|
|
138
|
-
|
|
139
|
-
assert.isArray(result)
|
|
140
|
-
assert.property(result[0], 'address')
|
|
141
|
-
assert.property(result[0], 'bchUtxos')
|
|
142
|
-
assert.property(result[0], 'nullUtxos')
|
|
143
|
-
assert.property(result[0], 'slpUtxos')
|
|
144
|
-
assert.isArray(result[0].bchUtxos)
|
|
145
|
-
assert.isArray(result[0].nullUtxos)
|
|
146
|
-
})
|
|
147
|
-
})
|
|
148
|
-
|
|
149
18
|
describe('#findBiggestUtxo', () => {
|
|
150
19
|
it('should throw error for non-array input', async () => {
|
|
151
20
|
try {
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Integration tests for the bchjs covering SLP tokens.
|
|
3
|
-
These tests are specific to the ABC chain.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
const chai = require('chai')
|
|
7
|
-
const assert = chai.assert
|
|
8
|
-
|
|
9
|
-
const BCHJS = require('../../../../src/bch-js')
|
|
10
|
-
let bchjs
|
|
11
|
-
|
|
12
|
-
// Inspect utility used for debugging.
|
|
13
|
-
const util = require('util')
|
|
14
|
-
util.inspect.defaultOptions = {
|
|
15
|
-
showHidden: true,
|
|
16
|
-
colors: true,
|
|
17
|
-
depth: 1
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
describe('#SLP', () => {
|
|
21
|
-
// before(() => {
|
|
22
|
-
// console.log(`bchjs.SLP.restURL: ${bchjs.SLP.restURL}`)
|
|
23
|
-
// console.log(`bchjs.SLP.apiToken: ${bchjs.SLP.apiToken}`)
|
|
24
|
-
// })
|
|
25
|
-
|
|
26
|
-
beforeEach(async () => {
|
|
27
|
-
// Introduce a delay so that the BVT doesn't trip the rate limits.
|
|
28
|
-
if (process.env.IS_USING_FREE_TIER) await sleep(1500)
|
|
29
|
-
|
|
30
|
-
bchjs = new BCHJS({ restURL: process.env.RESTURL })
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
describe('#util', () => {
|
|
34
|
-
describe('#tokenUtxoDetails', () => {
|
|
35
|
-
it('should handle a range of UTXO types', async () => {
|
|
36
|
-
const utxos = [
|
|
37
|
-
// Malformed SLP tx
|
|
38
|
-
{
|
|
39
|
-
note: 'Malformed SLP tx',
|
|
40
|
-
tx_hash:
|
|
41
|
-
'f7e5199ef6669ad4d078093b3ad56e355b6ab84567e59ad0f08a5ad0244f783a',
|
|
42
|
-
tx_pos: 1,
|
|
43
|
-
value: 546
|
|
44
|
-
},
|
|
45
|
-
// Normal TX (non-SLP)
|
|
46
|
-
{
|
|
47
|
-
note: 'Normal TX (non-SLP)',
|
|
48
|
-
tx_hash:
|
|
49
|
-
'01cdaec2f8b311fc2d6ecc930247bd45fa696dc204ab684596e281fe1b06c1f0',
|
|
50
|
-
tx_pos: 0,
|
|
51
|
-
value: 400000
|
|
52
|
-
},
|
|
53
|
-
// Valid PSF SLP tx
|
|
54
|
-
{
|
|
55
|
-
note: 'Valid PSF SLP tx',
|
|
56
|
-
tx_hash:
|
|
57
|
-
'daf4d8b8045e7a90b7af81bfe2370178f687da0e545511bce1c9ae539eba5ffd',
|
|
58
|
-
tx_pos: 1,
|
|
59
|
-
value: 546
|
|
60
|
-
},
|
|
61
|
-
// Valid SLP token not in whitelist
|
|
62
|
-
{
|
|
63
|
-
note: 'Valid SLP token not in whitelist',
|
|
64
|
-
tx_hash:
|
|
65
|
-
'3a4b628cbcc183ab376d44ce5252325f042268307ffa4a53443e92b6d24fb488',
|
|
66
|
-
tx_pos: 1,
|
|
67
|
-
value: 546
|
|
68
|
-
},
|
|
69
|
-
// Token send on BCHN network.
|
|
70
|
-
{
|
|
71
|
-
note: 'Token send on BCHN network',
|
|
72
|
-
tx_hash:
|
|
73
|
-
'402c663379d9699b6e2dd38737061e5888c5a49fca77c97ab98e79e08959e019',
|
|
74
|
-
tx_pos: 1,
|
|
75
|
-
value: 546
|
|
76
|
-
},
|
|
77
|
-
// Token send on ABC network.
|
|
78
|
-
{
|
|
79
|
-
note: 'Token send on ABC network',
|
|
80
|
-
tx_hash:
|
|
81
|
-
'336bfe2168aac4c3303508a9e8548a0d33797a83b85b76a12d845c8d6674f79d',
|
|
82
|
-
tx_pos: 1,
|
|
83
|
-
value: 546
|
|
84
|
-
},
|
|
85
|
-
// Known invalid SLP token send of PSF tokens.
|
|
86
|
-
{
|
|
87
|
-
note: 'Known invalid SLP token send of PSF tokens',
|
|
88
|
-
tx_hash:
|
|
89
|
-
'2bf691ad3679d928fef880b8a45b93b233f8fa0d0a92cf792313dbe77b1deb74',
|
|
90
|
-
tx_pos: 1,
|
|
91
|
-
value: 546
|
|
92
|
-
}
|
|
93
|
-
]
|
|
94
|
-
|
|
95
|
-
const data = await bchjs.SLP.Utils.tokenUtxoDetails(utxos)
|
|
96
|
-
// console.log(`data: ${JSON.stringify(data, null, 2)}`)
|
|
97
|
-
|
|
98
|
-
// Malformed SLP tx
|
|
99
|
-
assert.equal(data[0].tx_hash, utxos[0].tx_hash)
|
|
100
|
-
assert.equal(data[0].isValid, false)
|
|
101
|
-
|
|
102
|
-
// Normal TX (non-SLP)
|
|
103
|
-
assert.equal(data[1].tx_hash, utxos[1].tx_hash)
|
|
104
|
-
assert.equal(data[1].isValid, false)
|
|
105
|
-
|
|
106
|
-
// Valid PSF SLP tx
|
|
107
|
-
assert.equal(data[2].tx_hash, utxos[2].tx_hash)
|
|
108
|
-
assert.equal(data[2].isValid, true)
|
|
109
|
-
|
|
110
|
-
// Valid SLP token not in whitelist
|
|
111
|
-
assert.equal(data[3].tx_hash, utxos[3].tx_hash)
|
|
112
|
-
assert.equal(data[3].isValid, true)
|
|
113
|
-
|
|
114
|
-
// Token send on BCHN network
|
|
115
|
-
assert.equal(data[4].tx_hash, utxos[4].tx_hash)
|
|
116
|
-
// assert.equal(data[4].isValid, true)
|
|
117
|
-
assert.equal(data[4].isValid, null)
|
|
118
|
-
|
|
119
|
-
// Token send on ABC network
|
|
120
|
-
assert.equal(data[5].tx_hash, utxos[5].tx_hash)
|
|
121
|
-
assert.equal(data[5].isValid, true)
|
|
122
|
-
|
|
123
|
-
// Known invalid SLP token send of PSF tokens
|
|
124
|
-
assert.equal(data[6].tx_hash, utxos[6].tx_hash)
|
|
125
|
-
assert.equal(data[6].isValid, false)
|
|
126
|
-
})
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
describe('#validateTxid3', () => {
|
|
130
|
-
it('should invalidate a known invalid TXID', async () => {
|
|
131
|
-
const txid =
|
|
132
|
-
'f7e5199ef6669ad4d078093b3ad56e355b6ab84567e59ad0f08a5ad0244f783a'
|
|
133
|
-
|
|
134
|
-
const result = await bchjs.SLP.Utils.validateTxid3(txid)
|
|
135
|
-
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
|
|
136
|
-
|
|
137
|
-
assert.isArray(result)
|
|
138
|
-
|
|
139
|
-
assert.property(result[0], 'txid')
|
|
140
|
-
assert.equal(result[0].txid, txid)
|
|
141
|
-
|
|
142
|
-
assert.property(result[0], 'valid')
|
|
143
|
-
assert.equal(result[0].valid, null)
|
|
144
|
-
})
|
|
145
|
-
|
|
146
|
-
it('should validate a known valid TXID', async () => {
|
|
147
|
-
const txid =
|
|
148
|
-
'daf4d8b8045e7a90b7af81bfe2370178f687da0e545511bce1c9ae539eba5ffd'
|
|
149
|
-
|
|
150
|
-
const result = await bchjs.SLP.Utils.validateTxid3(txid)
|
|
151
|
-
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
|
|
152
|
-
|
|
153
|
-
assert.isArray(result)
|
|
154
|
-
|
|
155
|
-
assert.property(result[0], 'txid')
|
|
156
|
-
assert.equal(result[0].txid, txid)
|
|
157
|
-
|
|
158
|
-
assert.property(result[0], 'valid')
|
|
159
|
-
assert.equal(result[0].valid, true)
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
it('should handle a mix of valid, invalid, and non-SLP txs', async () => {
|
|
163
|
-
const txids = [
|
|
164
|
-
// Malformed SLP tx
|
|
165
|
-
'f7e5199ef6669ad4d078093b3ad56e355b6ab84567e59ad0f08a5ad0244f783a',
|
|
166
|
-
// Normal TX (non-SLP)
|
|
167
|
-
'01cdaec2f8b311fc2d6ecc930247bd45fa696dc204ab684596e281fe1b06c1f0',
|
|
168
|
-
// Valid PSF SLP tx
|
|
169
|
-
'daf4d8b8045e7a90b7af81bfe2370178f687da0e545511bce1c9ae539eba5ffd',
|
|
170
|
-
// Valid SLP token not in whitelist
|
|
171
|
-
'3a4b628cbcc183ab376d44ce5252325f042268307ffa4a53443e92b6d24fb488',
|
|
172
|
-
// Unprocessed SLP TX
|
|
173
|
-
// "a0d6406eecfd8634158efa9314ff15b4cbf451938e9dc7b5678c46b41eabc6ed" // Mint baton
|
|
174
|
-
'402c663379d9699b6e2dd38737061e5888c5a49fca77c97ab98e79e08959e019'
|
|
175
|
-
]
|
|
176
|
-
|
|
177
|
-
const result = await bchjs.SLP.Utils.validateTxid3(txids)
|
|
178
|
-
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
|
|
179
|
-
|
|
180
|
-
assert.isArray(result)
|
|
181
|
-
assert.equal(result[0].valid, null)
|
|
182
|
-
assert.equal(result[1].valid, null)
|
|
183
|
-
assert.equal(result[2].valid, true)
|
|
184
|
-
// assert.equal(result[2].valid, null)
|
|
185
|
-
assert.equal(result[3].valid, true)
|
|
186
|
-
assert.equal(result[4].valid, null)
|
|
187
|
-
})
|
|
188
|
-
})
|
|
189
|
-
|
|
190
|
-
describe('#validateTxid', () => {
|
|
191
|
-
it('should handle a mix of valid, invalid, and non-SLP txs', async () => {
|
|
192
|
-
const txids = [
|
|
193
|
-
// Malformed SLP tx
|
|
194
|
-
'f7e5199ef6669ad4d078093b3ad56e355b6ab84567e59ad0f08a5ad0244f783a',
|
|
195
|
-
// Normal TX (non-SLP)
|
|
196
|
-
'01cdaec2f8b311fc2d6ecc930247bd45fa696dc204ab684596e281fe1b06c1f0',
|
|
197
|
-
// Valid PSF SLP tx
|
|
198
|
-
'daf4d8b8045e7a90b7af81bfe2370178f687da0e545511bce1c9ae539eba5ffd',
|
|
199
|
-
// Valid SLP token not in whitelist
|
|
200
|
-
'3a4b628cbcc183ab376d44ce5252325f042268307ffa4a53443e92b6d24fb488',
|
|
201
|
-
// Token send on BCHN network.
|
|
202
|
-
'402c663379d9699b6e2dd38737061e5888c5a49fca77c97ab98e79e08959e019',
|
|
203
|
-
// Token send on ABC network.
|
|
204
|
-
'336bfe2168aac4c3303508a9e8548a0d33797a83b85b76a12d845c8d6674f79d'
|
|
205
|
-
]
|
|
206
|
-
|
|
207
|
-
const result = await bchjs.SLP.Utils.validateTxid(txids)
|
|
208
|
-
// console.log(`result: ${JSON.stringify(result, null, 2)}`)
|
|
209
|
-
|
|
210
|
-
assert.isArray(result)
|
|
211
|
-
assert.equal(result[0].valid, null)
|
|
212
|
-
assert.equal(result[1].valid, null)
|
|
213
|
-
assert.equal(result[2].valid, true)
|
|
214
|
-
// assert.equal(result[2].valid, null)
|
|
215
|
-
assert.equal(result[3].valid, true)
|
|
216
|
-
assert.equal(result[4].valid, null)
|
|
217
|
-
assert.equal(result[5].valid, true)
|
|
218
|
-
})
|
|
219
|
-
})
|
|
220
|
-
})
|
|
221
|
-
})
|
|
222
|
-
|
|
223
|
-
// Promise-based sleep function
|
|
224
|
-
function sleep (ms) {
|
|
225
|
-
return new Promise(resolve => setTimeout(resolve, ms))
|
|
226
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Integration tests for the bchjs. Only covers calls made to
|
|
3
|
-
rest.bitcoin.com.
|
|
4
|
-
|
|
5
|
-
TODO
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const chai = require('chai')
|
|
9
|
-
const assert = chai.assert
|
|
10
|
-
const BCHJS = require('../../../../src/bch-js')
|
|
11
|
-
const bchjs = new BCHJS()
|
|
12
|
-
|
|
13
|
-
// Inspect utility used for debugging.
|
|
14
|
-
const util = require('util')
|
|
15
|
-
util.inspect.defaultOptions = {
|
|
16
|
-
showHidden: true,
|
|
17
|
-
colors: true,
|
|
18
|
-
depth: 3
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
describe('#rawtransaction', () => {
|
|
22
|
-
beforeEach(async () => {
|
|
23
|
-
if (process.env.IS_USING_FREE_TIER) await sleep(3000)
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
/*
|
|
27
|
-
Testing sentRawTransaction isn't really possible with an integration test,
|
|
28
|
-
as the endpoint really needs an e2e test to be properly tested. The tests
|
|
29
|
-
below expect error messages returned from the server, but at least test
|
|
30
|
-
that the server is responding on those endpoints, and responds consistently.
|
|
31
|
-
*/
|
|
32
|
-
describe('sendRawTransaction', () => {
|
|
33
|
-
it('should send a single transaction hex', async () => {
|
|
34
|
-
try {
|
|
35
|
-
const hex =
|
|
36
|
-
'01000000013ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000006a4730440220540986d1c58d6e76f8f05501c520c38ce55393d0ed7ed3c3a82c69af04221232022058ea43ed6c05fec0eccce749a63332ed4525460105346f11108b9c26df93cd72012103083dfc5a0254613941ddc91af39ff90cd711cdcde03a87b144b883b524660c39ffffffff01807c814a000000001976a914d7e7c4e0b70eaa67ceff9d2823d1bbb9f6df9a5188ac00000000'
|
|
37
|
-
|
|
38
|
-
await bchjs.RawTransactions.sendRawTransaction(hex)
|
|
39
|
-
// console.log(`result ${JSON.stringify(result, null, 2)}`)
|
|
40
|
-
|
|
41
|
-
assert.equal(true, false, 'Unexpected result!')
|
|
42
|
-
} catch (err) {
|
|
43
|
-
// console.log(`err: ${util.inspect(err)}`)
|
|
44
|
-
|
|
45
|
-
assert.hasAllKeys(err, ['error'])
|
|
46
|
-
assert.include(err.error, 'Missing inputs')
|
|
47
|
-
}
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
it('should send an array of tx hexes', async () => {
|
|
51
|
-
try {
|
|
52
|
-
const hexes = [
|
|
53
|
-
'01000000013ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000006a4730440220540986d1c58d6e76f8f05501c520c38ce55393d0ed7ed3c3a82c69af04221232022058ea43ed6c05fec0eccce749a63332ed4525460105346f11108b9c26df93cd72012103083dfc5a0254613941ddc91af39ff90cd711cdcde03a87b144b883b524660c39ffffffff01807c814a000000001976a914d7e7c4e0b70eaa67ceff9d2823d1bbb9f6df9a5188ac00000000',
|
|
54
|
-
'01000000013ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000006a4730440220540986d1c58d6e76f8f05501c520c38ce55393d0ed7ed3c3a82c69af04221232022058ea43ed6c05fec0eccce749a63332ed4525460105346f11108b9c26df93cd72012103083dfc5a0254613941ddc91af39ff90cd711cdcde03a87b144b883b524660c39ffffffff01807c814a000000001976a914d7e7c4e0b70eaa67ceff9d2823d1bbb9f6df9a5188ac00000000'
|
|
55
|
-
]
|
|
56
|
-
|
|
57
|
-
const result = await bchjs.RawTransactions.sendRawTransaction(hexes)
|
|
58
|
-
console.log(`result ${JSON.stringify(result, null, 2)}`)
|
|
59
|
-
} catch (err) {
|
|
60
|
-
// console.log(`err: ${util.inspect(err)}`)
|
|
61
|
-
|
|
62
|
-
assert.hasAllKeys(err, ['error'])
|
|
63
|
-
assert.include(err.error, 'Missing inputs')
|
|
64
|
-
}
|
|
65
|
-
})
|
|
66
|
-
})
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
function sleep (ms) {
|
|
70
|
-
return new Promise(resolve => setTimeout(resolve, ms))
|
|
71
|
-
}
|