2020-07-27 11:44:26 +02:00
|
|
|
/*
|
|
|
|
|
* This file is part of the Flowee project
|
2021-02-15 12:15:07 +01:00
|
|
|
* Copyright (C) 2019-2021 Tom Zander <tom@flowee.org>
|
2020-07-27 11:44:26 +02:00
|
|
|
* Copyright (C) 2020 James Zuccon <zuccon@gmail.com>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
2020-07-16 23:23:57 +02:00
|
|
|
const _floweeGlobal = require('bindings')('flowee')
|
|
|
|
|
const BlockchainService = require('./service.blockchain');
|
2020-07-27 12:41:23 +02:00
|
|
|
const LiveTransactionsService = require('./service.livetransactions');
|
2020-07-16 23:23:57 +02:00
|
|
|
|
|
|
|
|
const Message = require('./message');
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Flowee
|
|
|
|
|
* @example
|
|
|
|
|
* const Flowee = require('FloweeJS');
|
|
|
|
|
*
|
|
|
|
|
* async function main() {
|
|
|
|
|
* // Connect
|
|
|
|
|
* let flowee = new Flowee();
|
|
|
|
|
* await flowee.connect();
|
|
|
|
|
* }
|
|
|
|
|
*
|
|
|
|
|
* main();
|
|
|
|
|
*/
|
|
|
|
|
class Flowee {
|
|
|
|
|
constructor() {
|
|
|
|
|
this.network = _floweeGlobal
|
|
|
|
|
|
|
|
|
|
// Create Services
|
|
|
|
|
this.services = {};
|
|
|
|
|
this.services.Blockchain = new BlockchainService(this.network)
|
2020-07-27 12:41:23 +02:00
|
|
|
this.services.LiveTransactions = new LiveTransactionsService(this.network)
|
2020-07-16 23:23:57 +02:00
|
|
|
|
|
|
|
|
// methods to forward to make it nice and easy to use
|
|
|
|
|
this.getBlockCount = this.services.Blockchain.getBlockCount;
|
2020-07-18 14:36:37 +02:00
|
|
|
this.getBlock = this.services.Blockchain.getBlock;
|
|
|
|
|
this.getBlockChainInfo = this.services.Blockchain.getBlockChainInfo;
|
|
|
|
|
this.getBestBlockHash = this.services.Blockchain.getBestBlockHash;
|
2020-07-27 11:44:26 +02:00
|
|
|
this.getRawTransaction = this.services.Blockchain.getRawTransaction;
|
2020-07-27 12:00:42 +02:00
|
|
|
this.getBlockHeader = this.services.Blockchain.getBlockHeader;
|
2021-02-17 16:51:06 +01:00
|
|
|
this.getTransaction = this.services.Blockchain.getTransaction;
|
2020-07-16 23:23:57 +02:00
|
|
|
|
2020-07-27 12:41:23 +02:00
|
|
|
this.getLiveTransaction = this.services.LiveTransactions.getLiveTransaction;
|
|
|
|
|
this.sendTransaction = this.services.LiveTransactions.sendTransaction;
|
|
|
|
|
this.isUnspent = this.services.LiveTransactions.isUnspent;
|
|
|
|
|
this.getUnspentOutput = this.services.LiveTransactions.getUnspentOutput;
|
2021-02-15 12:15:07 +01:00
|
|
|
this.subscribeToAddress = this.network.subscribeToAddress
|
2021-04-03 20:34:20 +02:00
|
|
|
this.parseAddress = this.network.parseAddress
|
2020-07-27 11:42:25 +02:00
|
|
|
|
2020-07-16 23:23:57 +02:00
|
|
|
this.connect = this.network.connect;
|
|
|
|
|
this.connectHub = this.network.connectHub;
|
|
|
|
|
this.connectIndexer = this.network.connectIndexer;
|
|
|
|
|
this.sendTransaction = this.network.sendTransaction;
|
|
|
|
|
this.search = this.network.search
|
2021-02-15 10:46:56 +01:00
|
|
|
this.stop = this.network.stop
|
2020-07-16 23:23:57 +02:00
|
|
|
|
|
|
|
|
// enums
|
|
|
|
|
this.Job = this.network.Job
|
|
|
|
|
this.IncludeOutputAmounts = this.network.IncludeOutputAmounts
|
|
|
|
|
this.IncludeOffsetInBlock = this.network.IncludeOffsetInBlock;
|
|
|
|
|
this.IncludeInputs = this.network.IncludeInputs;
|
|
|
|
|
this.IncludeTxid = this.network.IncludeTxid;
|
|
|
|
|
this.IncludeFullTxData = this.network.IncludeFullTxData;
|
|
|
|
|
this.IncludeOutputs = this.network.IncludeOutputs;
|
|
|
|
|
this.IncludeOutputScripts = this.network.IncludeOutputScripts;
|
|
|
|
|
this.IncludeOutputAddresses = this.network.IncludeOutputAddresses;
|
2021-02-17 16:50:58 +01:00
|
|
|
this.IncludeOutputScriptHash = this.network.IncludeOutputScriptHash;
|
2021-03-18 12:32:59 +01:00
|
|
|
this.IncludeTxFees = this.network.IncludeTxFees;
|
2021-02-14 23:36:59 +01:00
|
|
|
this.InfoLevel = this.network.InfoLevel;
|
|
|
|
|
this.WarningLevel = this.network.WarningLevel;
|
|
|
|
|
this.QuietLevel = this.network.QuietLevel;
|
|
|
|
|
this.SilentLevel = this.network.SilentLevel;
|
2020-07-16 23:23:57 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = Flowee
|