Transaction, Input and Output models are wired or stubbed. Tomorrow/Tonight I wire up the API
This commit is contained in:
parent
7d5cade288
commit
43b23b80dc
20
README.md
20
README.md
@ -12,10 +12,23 @@ npm start
|
||||
|
||||
Logging is current defaulting to debug during dev. Bitcore logging is preceded by a timestamp. Bcoin logging with [info]
|
||||
|
||||
# Misc Gotchas / Needs Docs & clarity
|
||||
|
||||
Mongo will create the bitcore db and a blocks/transactions collection automatically. These colls have indexes. Bcoin also syncs to the prefix set in config. To reset/start over you need to drop both collections and delete the bcoin datadir.
|
||||
|
||||
# Nginx
|
||||
|
||||
The API is configured to run on port 3000 by default. Use the standard Nginx reverse proxy to flip http to https and handle ssl certs.
|
||||
|
||||
# Requirements
|
||||
|
||||
1. git clone
|
||||
2. npm install
|
||||
3. npm run start
|
||||
4. Bitcore starts, Bcoin syncs and Insight starts automagically.
|
||||
|
||||
1, 2 & 3 are complete. 4 is also complete but insight still needs wired to mongo and the mongo data models are going to undergo more changes as we consolidate work and discover needs. The goal is still to go as far as possible with a stable framework and fill in the rest afterwards when work can be tasked/delegated.
|
||||
|
||||
# Priorities
|
||||
1. Required Insight-UI
|
||||
|
||||
@ -33,3 +46,10 @@ The API is configured to run on port 3000 by default. Use the standard Nginx rev
|
||||
/txs
|
||||
|
||||
sockets
|
||||
|
||||
2. Mongo Models
|
||||
|
||||
Some data is stubbed. This is due to Bcoin primitives being different from Bitcore. It's unclear whether Mongo models or multiple queries at the api layer will better serve us. Obviously multiple queries are easier but I would prefer a clear cut data model because that leads to fewer problems in the future and gives us greater flexibility in our API and the other microservices we implement in the future.
|
||||
|
||||
# ToDo
|
||||
Reorg testing - Bcoin will handle this but we need to account for this in our mongo indexes.
|
||||
@ -6,6 +6,8 @@ const db = require('../../lib/db');
|
||||
const util = require('../../lib/util');
|
||||
const BlockModel = require('../../models/block');
|
||||
const TxModel = require('../../models/transaction').Transaction;
|
||||
const InputModel = require('../../models/transaction').Input;
|
||||
const OutputModel = require('../../models/transaction').Output;
|
||||
|
||||
function start() {
|
||||
node.open()
|
||||
@ -60,24 +62,29 @@ function processTx(entry, txs) {
|
||||
const txHash = util.revHex(tx.hash().toString('hex'));
|
||||
const blockHash = util.revHex(entry.hash);
|
||||
|
||||
const inputs = tx.inputs.map((input) => {
|
||||
//console.log('input');
|
||||
//console.log(input);
|
||||
//console.log(input.toJSON());
|
||||
});
|
||||
|
||||
const outputs = tx.outputs.map((output) => {
|
||||
//console.log('output');
|
||||
//console.log(output);
|
||||
//console.log(output.toJSON());
|
||||
});
|
||||
|
||||
const t = new TxModel({
|
||||
txid: txHash,
|
||||
version: 1,
|
||||
lockTime: tx.lockTime,
|
||||
vin: [],
|
||||
vout: [],
|
||||
vin: tx.inputs.map((input) => {
|
||||
const inputJSON = input.toJSON();
|
||||
|
||||
return new InputModel({
|
||||
utxo: inputJSON.prevout.hash,
|
||||
vout: inputJSON.prevout.index,
|
||||
address: inputJSON.address,
|
||||
amount: 0,
|
||||
});
|
||||
}),
|
||||
vout: tx.outputs.map((output) => {
|
||||
const outputJSON = output.toJSON();
|
||||
|
||||
return new OutputModel({
|
||||
address: outputJSON.address,
|
||||
amount: outputJSON.value,
|
||||
vout: 0,
|
||||
});
|
||||
}),
|
||||
blockHash: blockHash,
|
||||
blockHeight: entry.height,
|
||||
confirmations: 0,
|
||||
|
||||
@ -6,14 +6,12 @@ const InputSchema = new Schema({
|
||||
vout: Number,
|
||||
address: String,
|
||||
amount: Number,
|
||||
wallets: { type: [Schema.Types.ObjectId] },
|
||||
});
|
||||
|
||||
const OutputSchema = new Schema({
|
||||
address: String,
|
||||
amount: Number,
|
||||
vout: Number,
|
||||
wallets: { type: [Schema.Types.ObjectId] },
|
||||
});
|
||||
|
||||
const TransactionSchema = new Schema({
|
||||
|
||||
17
test/data/bcoin-input.json
Normal file
17
test/data/bcoin-input.json
Normal file
@ -0,0 +1,17 @@
|
||||
{ type: 'pubkeyhash',
|
||||
subtype: undefined,
|
||||
address: <Address: type=pubkeyhash version=-1 str=1G6p7BydsiUyQd9vB1LR4N3uER9XcPiFaV>,
|
||||
script: <Script: 0x48 0x304502210093275988acbf1e540e5860af460517ba65f77c0855c28165ddc01a4933ac94d20220748590fe44ab5d97abc98510d6268d7a3ccbbc4a7a2c60dd7d9b6be530dc7e2e01 0x41 0x0432cfefc384c53965332c503e0815a8134322721c60d62ec46a070a114d80a0bd33e7645bdf78eba6cd23824b233cd78159a22896d79f8ef371cf632b7556657c>,
|
||||
witness: <Witness: >,
|
||||
redeem: undefined,
|
||||
sequence: 4294967295,
|
||||
prevout: <Outpoint: 9b56e70e5f2bf46358d0d5931a3ee9a7af6e1dd9bc6f3ef5730759e89cf8f603/0>,
|
||||
coin: null }
|
||||
{ prevout:
|
||||
{ hash: '9b56e70e5f2bf46358d0d5931a3ee9a7af6e1dd9bc6f3ef5730759e89cf8f603',
|
||||
index: 0 },
|
||||
script: '48304502210093275988acbf1e540e5860af460517ba65f77c0855c28165ddc01a4933ac94d20220748590fe44ab5d97abc98510d6268d7a3ccbbc4a7a2c60dd7d9b6be530dc7e2e01410432cfefc384c53965332c503e0815a8134322721c60d62ec46a070a114d80a0bd33e7645bdf78eba6cd23824b233cd78159a22896d79f8ef371cf632b7556657c',
|
||||
witness: '00',
|
||||
sequence: 4294967295,
|
||||
address: '1G6p7BydsiUyQd9vB1LR4N3uER9XcPiFaV',
|
||||
coin: undefined }
|
||||
Loading…
Reference in New Issue
Block a user