Skip to content

Commit 4ca6bf4

Browse files
committed
use https://api.dcousens.cloud reg-test server instead of testnet
1 parent f3cc30d commit 4ca6bf4

File tree

8 files changed

+299
-311
lines changed

8 files changed

+299
-311
lines changed

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,9 @@
4747
"wif": "^2.0.1"
4848
},
4949
"devDependencies": {
50-
"async": "^2.0.1",
5150
"bip39": "^2.3.0",
5251
"bs58": "^4.0.0",
53-
"cb-http-client": "^0.2.0",
54-
"coinselect": "^3.1.1",
55-
"dhttp": "^2.3.5",
52+
"dhttp": "^2.4.2",
5653
"minimaldata": "^1.0.2",
5754
"mocha": "^3.1.0",
5855
"nyc": "^10.2.0",

test/integration/_mainnet.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/integration/_regtest.js

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
var bitcoin = require('../../')
2+
var dhttp = require('dhttp/200')
3+
4+
var APIPASS = process.env.APIPASS || 'satoshi'
5+
var APIURL = 'https://api.dcousens.cloud/1'
6+
7+
function broadcast (txHex, callback) {
8+
dhttp({
9+
method: 'PUT',
10+
url: APIURL + '/t/push',
11+
body: txHex
12+
}, callback)
13+
}
14+
15+
function mine (count, callback) {
16+
dhttp({
17+
method: 'POST',
18+
url: APIURL + '/r/generate?count=' + count + '&key=' + APIPASS
19+
}, callback)
20+
}
21+
22+
function faucet (address, value, callback) {
23+
dhttp({
24+
method: 'POST',
25+
url: APIURL + '/r/faucet?address=' + address + '&value=' + value + '&key=' + APIPASS
26+
}, function (err, txId) {
27+
if (err) return callback(err)
28+
29+
unspents(address, function (err, results) {
30+
if (err) return callback(err)
31+
32+
callback(null, results.filter(x => x.txId === txId).pop())
33+
})
34+
})
35+
}
36+
37+
function fetch (txId, callback) {
38+
dhttp({
39+
method: 'GET',
40+
url: APIURL + '/t/' + txId
41+
}, callback)
42+
}
43+
44+
function unspents (address, callback) {
45+
dhttp({
46+
method: 'GET',
47+
url: APIURL + '/a/' + address + '/unspents'
48+
}, callback)
49+
}
50+
51+
function verify (txo, callback) {
52+
let { txId } = txo
53+
54+
fetch(txId, function (err, txHex) {
55+
if (err) return callback(err)
56+
57+
// TODO: verify address and value
58+
callback()
59+
})
60+
}
61+
62+
function randomAddress () {
63+
return bitcoin.ECPair.makeRandom({
64+
network: bitcoin.networks.testnet
65+
}).getAddress()
66+
}
67+
68+
module.exports = {
69+
broadcast: broadcast,
70+
faucet: faucet,
71+
fetch: fetch,
72+
mine: mine,
73+
network: bitcoin.networks.testnet,
74+
unspents: unspents,
75+
verify: verify,
76+
randomAddress: randomAddress,
77+
RANDOM_ADDRESS: randomAddress()
78+
}

test/integration/_testnet.js

Lines changed: 0 additions & 99 deletions
This file was deleted.

test/integration/addresses.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ describe('bitcoinjs-lib (addresses)', function () {
9797
assert.strictEqual(address, '3P4mrxQfmExfhxqjLnR2Ah4WES5EB1KBrN')
9898
})
9999

100-
it('can support the retrieval of transactions for an address (3rd party blockchain)', function (done) {
100+
it('can support the retrieval of transactions for an address (via 3PBP)', function (done) {
101101
var keyPair = bitcoin.ECPair.makeRandom()
102102
var address = keyPair.getAddress()
103103

0 commit comments

Comments
 (0)