diff --git a/.DS_Store b/.DS_Store
deleted file mode 100644
index 6d78f93..0000000
Binary files a/.DS_Store and /dev/null differ
diff --git a/Cryptocurrency-crypto-bot.sql b/Cryptocurrency-crypto-bot.sql
index 6d01edb..9600721 100644
--- a/Cryptocurrency-crypto-bot.sql
+++ b/Cryptocurrency-crypto-bot.sql
@@ -45,7 +45,7 @@ CREATE TABLE `deposits` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`address` varchar(60) NOT NULL,
`amount` decimal(32,8) NOT NULL,
- `txid` varchar(64) NOT NULL,
+ `txid` varchar(125) NOT NULL,
`confirmations` int(11) NOT NULL,
`credited` tinyint(1) unsigned NOT NULL,
`datetime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
diff --git a/README.md b/README.md
index 5b16faf..f66f865 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,8 @@
# Cryptocurrency-crypto-bot is an open-source Node.js wallet bot for Discord.
+## This version has adjustments to work with BlackCoin / NovaCoin forks.
+#### Currently in use with DiminutiveVaultCoin (DIMI) and InfiniLooP (IL8P)
+
### Preview pictures
@@ -75,3 +78,7 @@ walletnotify=/path/to/your/bot/folder/transaction.sh %s
## Projects using the bot - Feel free to contact me to get added
- Limitless (VIP) - Discord: https://discord.gg/wtz6QYX - Website: http://vip.limitlessvip.co.za/
+- BARE Coin (BARE) - Discord: https://discord.gg/xmQbzNH - Website: https://bare.network/
+- Coin Pool Services - Discord: https://discord.gg/eWB5z2E - Website: https://coinpoolservices.com/
+- Beyondcoin (BYND) - Discord: https://discord.gg/j3BUcJU - Website: https://beyondcoin.io
+- Shroud Protocol (SHROUD) - Discord: https://discord.gg/7U8chR4 - Website: https://shroudx.org
diff --git a/config.js b/config.js
index e0d81cb..53abbb6 100755
--- a/config.js
+++ b/config.js
@@ -14,6 +14,7 @@ module.exports = {
"moderatorIDs": [ "XXX" ], // This discrod user IDs are able to use moderator commands and bypass cooldowns
"vipGroupName": "Dev Team", // Users of this group are able to use vip commands and bypass cooldowns
"respondChannelIDs": [ "XXX" ], // Discord server channel IDs the bot does listen to
+ "allowAllChannels": false, // If enabled the bot will be able to reply in all channels making it essentially a public bot
"commandIgnor": ["battle","cversion","destroy","gift","kill","lock","me","rez","top","use","me","cstart","cstop","cstart","jackpot","summary","shop","activate","mention","claim"], // commands to ignor because of other bots
"stakePoolChannelID": "XXX", // If staking is configured use this channel to broadcast stake pool payouts
"allowDM": true, // Allow or disable direct messages for commands to the bot with true or false
diff --git a/functions/check.js b/functions/check.js
index 6ce9ac9..434adec 100755
--- a/functions/check.js
+++ b/functions/check.js
@@ -13,6 +13,7 @@ try{
const Big = require('big.js'); // https://github.com/MikeMcl/big.js -> http://mikemcl.github.io/big.js/
const rp = require('request-promise');
+const { bot } = require('../config');
/* ------------------------------------------------------------------------------ */
// // // // // // // // // // // // // // // // // // // // // // // // // // // //
@@ -116,14 +117,17 @@ module.exports = {
},
/* ------------------------------------------------------------------------------ */
- // Check if the channel is a valid channel to repond to
+ // Check if the channel is a valid channel to respond to or if open to all channels
/* ------------------------------------------------------------------------------ */
-
check_respond_channel: function(channelID){
- var respondChannelIDs = {};
- for (var i = 0 ; i < config.bot.respondChannelIDs.length ; ++i)
- respondChannelIDs[config.bot.respondChannelIDs[i]] = true;
- return respondChannelIDs[channelID];
+ if (config.bot.allowAllChannels == true) {
+ return;
+ } else if(config.bot.allowAllChannels == false) {
+ var respondChannelIDs = {};
+ for (var i = 0 ; i < config.bot.respondChannelIDs.length ; ++i)
+ respondChannelIDs[config.bot.respondChannelIDs[i]] = true;
+ return respondChannelIDs[channelID];
+ }
},
/* ------------------------------------------------------------------------------ */
diff --git a/functions/command.js b/functions/command.js
index 5e72178..e83cc73 100755
--- a/functions/command.js
+++ b/functions/command.js
@@ -287,8 +287,9 @@ module.exports = {
}
// Calculate how much of the stake balance belongs to the users stake balance // Rest balance belongs to wallet as its not market as stake from the users
var down = 0;
- var totalStakeForStakers = Big(totalUserStakeBalance).div(walletBalance);
- totalStakeForStakers = Big(totalStakeForStakers).times(totalStakeSum).round(8, down);
+ // All stakes minus bot owner fee will be distributed between stake pool participants.
+ // Original calculations produce inconsistent amounts for BlackCoin/NovaCoin forks
+ totalStakeForStakers = Big(totalStakeSum).minus(totalStakeSumMinusOwnerPercentage).round(8, down);
// Debug log
if(config.staking.debug){
log.log_write_console(config.messages.log.stakecredit5+' '+totalUserStakeBalance);
@@ -791,7 +792,7 @@ module.exports = {
var deposit_category = latestDeposits[i].category;
var deposit_amount = Big(latestDeposits[i].amount).toString();
var deposit_confirmations = latestDeposits[i].confirmations;
- var deposit_txid = latestDeposits[i].txid;
+ var deposit_txid = latestDeposits[i].txid + ' ' + deposit_address;
var deposit_generated = latestDeposits[i].generated; // Check if its a stake so not use it
if(deposit_category === 'receive' && !deposit_generated && deposit_confirmations < config.wallet.minConfirmationsDeposit){
var creditDeposit = await transaction.transaction_add_update_deposits_on_db(deposit_address,Big(deposit_amount).toString(),deposit_confirmations,deposit_txid);
@@ -859,25 +860,52 @@ module.exports = {
log.log_write_console('no stake');
var transaction_amount = 0;
var transaction_stake = 0;
+
// Update transaction on db
var updateTransaction = await transaction.transaction_update_stake_transaction(transaction_txid,Big(transaction_amount).toString(),transaction_stake);
if(updateTransaction){
countTransactionsToCheck++;
}
+
+ // Below changes implemented for BlackCoin/NovaCoin forks to allow stake amount (mint) to be grabbed from "getblock" rpc call by, in first place grabbing a "blockhash" from output of transaction
+ // in question through "gettransaction" rpc call.
+
}else{
// If stake
- var transaction_amount = Big(getTransaction.amount).toString();
- var transaction_fee = getTransaction.fee;
- var transaction_stake_amount = Big(transaction_amount).plus(transaction_fee);
- var transaction_stake = 1;
- //log.log_write_console('AMOUNT: '+transaction_amount+' - FEE: '+transaction_fee+' STAKE AMOUNT: '+Big(transaction_stake_amount).toString());
- // Update transaction on db
- var updateTransaction = await transaction.transaction_update_stake_transaction(transaction_txid,Big(transaction_stake_amount).toString(),transaction_stake);
- if(updateTransaction){
- countTransactionsToCheck++;
- }
- }
- }
+ var block = getTransaction.blockhash;
+ var blockhash = String(block);
+ log.log_write_console(blockhash);
+
+ if(blockhash == String(undefined)){
+ log.log_write_console('bogus stake');
+ var transaction_amount = 0;
+ var transaction_stake = 0;
+ // Update transaction on db
+ var updateTransaction = await transaction.transaction_update_stake_transaction(transaction_txid,Big(transaction_amount).toString(),transaction_stake);
+ if(updateTransaction){
+ countTransactionsToCheck++;
+ }
+ }else{
+ var getBlock = await wallet.wallet_get_block(blockhash);
+
+ var getMint = getBlock.mint;
+ var mint = String(getMint);
+ log.log_write_console(getMint);
+
+ var transaction_amount = Big(getBlock.mint).toString();
+
+ var transaction_fee = getTransaction.fee;
+ var transaction_stake_amount = Big(transaction_amount);
+ var transaction_stake = 1;
+ //log.log_write_console('AMOUNT: '+transaction_amount+' - FEE: '+transaction_fee+' STAKE AMOUNT: '+Big(transaction_stake_amount).toString());
+ // Update transaction on db
+ var updateTransaction = await transaction.transaction_update_stake_transaction(transaction_txid,Big(transaction_stake_amount).toString(),transaction_stake);
+ if(updateTransaction){
+ countTransactionsToCheck++;
+ }
+ }
+ }
+ }
if(i == transactionsToCheck.length-1 && manuallyFired == 1)
chat.chat_reply(msg,'embed',userName,messageType,config.colors.special,false,config.messages.getstakes.manually,[[config.messages.getstakes.transactions,countTransactionsToCheck,false]],false,false,false,false,false);
if(i == transactionsToCheck.length-1 && manuallyFired == 0)
@@ -2262,4 +2290,4 @@ module.exports = {
}
}
-};
\ No newline at end of file
+};
diff --git a/functions/wallet.js b/functions/wallet.js
index 1b0a89f..ad42fa7 100755
--- a/functions/wallet.js
+++ b/functions/wallet.js
@@ -139,6 +139,29 @@ module.exports = {
});
});
},
+
+ /* ------------------------------------------------------------------------------ */
+ // Get block
+ /* ------------------------------------------------------------------------------ */
+
+ wallet_get_block: function(blockhash){
+ return new Promise((resolve, reject)=>{
+ coinClient.getBlock(blockhash, function(error, result) {
+ if(error){
+ var errorMessage = "wallet_get_block: Wallet query problem. (getBlock)";
+ if(config.bot.errorLogging){
+ log.log_write_file(errorMessage);
+ log.log_write_file(error);
+ }
+ log.log_write_console(errorMessage);
+ log.log_write_console(error);
+ resolve(false);
+ }else{
+ resolve(result);
+ }
+ });
+ });
+ },
/* ------------------------------------------------------------------------------ */
// Get balance
@@ -186,4 +209,4 @@ module.exports = {
});
}
-};
\ No newline at end of file
+};
diff --git a/index.js b/index.js
index fc3f0f4..fef236c 100755
--- a/index.js
+++ b/index.js
@@ -119,8 +119,11 @@ if(messageContent.startsWith(config.bot.commandPrefix)){
}
// If its not a dm message check if its a valid channel for commands
- if(!check.check_respond_channel(channelID) && messageType !== 'dm')
- return;
+ if(config.bot.allowAllChannels == "true")
+ return;
+ else if(config.bot.allowAllChannels == false)
+ if(!check.check_respond_channel(channelID) && messageType !== 'dm')
+ return;
// Check if admin mode is enabled and only allow commands from admins
if(config.bot.adminMode && userRole != 3){