Skip to content

Commit

Permalink
Add 'packages/bitcore-node/' from commit '226fc0de85d74968937e3daea23…
Browse files Browse the repository at this point in the history
…e43db491b998d'

git-subtree-dir: packages/bitcore-node
git-subtree-mainline: 95fd216
git-subtree-split: 226fc0d
  • Loading branch information
Micah Riggan committed Apr 5, 2018
2 parents 95fd216 + 226fc0d commit 385e791
Show file tree
Hide file tree
Showing 38 changed files with 6,288 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/bitcore-node/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"parserOptions": {
"ecmaVersion": 2017
},
"env": {
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"rules": {
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
}
}
3 changes: 3 additions & 0 deletions packages/bitcore-node/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
config.json
.bcoin
21 changes: 21 additions & 0 deletions packages/bitcore-node/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Justin Langston

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
110 changes: 110 additions & 0 deletions packages/bitcore-node/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
Bitcore Node
============
_Requirements_:
- Trusted P2P Peer
- MongoDB Server >= v3.4
## Config Example
./config.json

```
{
"pruneSpentScripts": true,
"chains": {
"BTC": {
"mainnet": {
"trustedPeers": [
{
"host": "127.0.0.1",
"port": 8333
}
]
}
},
"BCH": {
"mainnet": {
"parentChain": "BTC",
"forkHeight": 478558,
"trustedPeers": [
{
"host": "127.0.0.1",
"port": 9333
}
]
}
}
}
}
```

# Wallet

## Add Wallet:

POST `/api/wallet`

BODY:
```
{
"name": "WalletName"
}
```

## Get Wallet:

GET `/api/wallet/:walletId`

## Import Addresses:

POST `/api/wallet/:walletId`

BODY: raw jsonl wallet file of the form
```
{"address": "bItCoInAddReSSHeRe"}
```

## Get Wallet Addresses

GET `/api/wallet/:walletId/addresses`

## Get Wallet Transactions:

GET `/api/wallet/:walletId/transactions`

## Get Balance:

GET `/api/wallet/:walletId/balance`

## Get Wallet UTXOS

GET `/api/wallet/:walletId/utxos`

# Transactions

## Get Transactions by block

GET `/api/BTC/mainnet/tx/?blockHeight=123456`

GET `/api/BTC/mainnet/tx/?blockHash=0000000000002917ed80650c6174aac8dfc46f5fe36480aaef682ff6cd83c3ca`

## Get Transaction by txid

GET `/api/BTC/mainnet/tx/5c8a63e695caf95c28a0155beaa22b84a7adb18b8693ba90f04d94891d122afe`

# Address

## Get Transaction Outputs by Address

GET `/api/BTC/mainnet/address/mmEsgUprBEQkGDKowPQSLEYDbMtGRKxaF4/?unspent=true`

## Get Balance for an Address

GET `/api/BTC/mainnet/address/mmEsgUprBEQkGDKowPQSLEYDbMtGRKxaF4/balance`

# Block

## Get Block

GET `/api/BTC/mainnet/block/0000000000002917ed80650c6174aac8dfc46f5fe36480aaef682ff6cd83c3ca`

GET `/api/BTC/mainnet/block/123456`
10 changes: 10 additions & 0 deletions packages/bitcore-node/lib/chain.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
BTC: {
lib: require('bitcore-lib'),
p2p: require('bitcore-p2p'),
},
BCH: {
lib: require('bitcore-lib-cash'),
p2p: require('bitcore-p2p-cash'),
},
}
33 changes: 33 additions & 0 deletions packages/bitcore-node/lib/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const Config = function(){
let config = {
maxPoolSize: 20,
port: 3000,
dbHost: '127.0.0.1',
dbName: 'bitcore',
numWorkers: require('os').cpus().length,
chains: {}
};

let options;
try {
options = require('../config.json');
} catch(e) {
options = {};
}

Object.assign(config, options);
if (!Object.keys(config.chains).length){
config.chains.BTC = {
mainnet: {
chainSource: 'p2p',
trustedPeers: [
{ host: '127.0.0.1', port: 8333 }
]
}
};
}

return config;
};

module.exports = new Config();
13 changes: 13 additions & 0 deletions packages/bitcore-node/lib/logger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const winston = require('winston');

const logger = winston.createLogger({
format: winston.format.combine(
winston.format.colorize({ all: true }),
winston.format.simple()
),
transports: [
new winston.transports.Console()
]
});

module.exports = logger;
Loading

0 comments on commit 385e791

Please sign in to comment.