Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion Cryptocurrency-crypto-bot.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
<img src="https://user-images.githubusercontent.com/8712219/69255023-68990180-0bb7-11ea-8e15-755491968a5e.jpg" width="45%"></img> <img src="https://user-images.githubusercontent.com/8712219/69255024-68990180-0bb7-11ea-9ce4-f962a17f6a0a.jpg" width="45%"></img> <img src="https://user-images.githubusercontent.com/8712219/69255026-69319800-0bb7-11ea-9f9e-acd0883a0d1d.jpg" width="45%"></img> <img src="https://user-images.githubusercontent.com/8712219/69255027-69319800-0bb7-11ea-85ad-f93b84c9c475.jpg" width="45%"></img> <img src="https://user-images.githubusercontent.com/8712219/69255028-69ca2e80-0bb7-11ea-81e6-ae11149e539a.jpg" width="45%"></img> <img src="https://user-images.githubusercontent.com/8712219/69255030-69ca2e80-0bb7-11ea-86b4-4965995a4438.jpg" width="45%"></img> <img src="https://user-images.githubusercontent.com/8712219/69255034-6a62c500-0bb7-11ea-8c0e-a9117234cda6.jpg" width="45%"></img> <img src="https://user-images.githubusercontent.com/8712219/69255037-6afb5b80-0bb7-11ea-88b2-3806c594639e.jpg" width="45%"></img> <img src="https://user-images.githubusercontent.com/8712219/69255039-6b93f200-0bb7-11ea-82f7-1dd738795eb1.jpg" width="45%"></img> <img src="https://user-images.githubusercontent.com/8712219/69255040-6c2c8880-0bb7-11ea-95a9-9d4d44401de5.jpg" width="45%"></img> <img src="https://user-images.githubusercontent.com/8712219/69255043-6cc51f00-0bb7-11ea-8818-f2bc151f1fbd.jpg" width="45%"></img>

Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 10 additions & 6 deletions functions/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

/* ------------------------------------------------------------------------------ */
// // // // // // // // // // // // // // // // // // // // // // // // // // // //
Expand Down Expand Up @@ -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];
}
},

/* ------------------------------------------------------------------------------ */
Expand Down
60 changes: 44 additions & 16 deletions functions/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -2262,4 +2290,4 @@ module.exports = {
}
}

};
};
25 changes: 24 additions & 1 deletion functions/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -186,4 +209,4 @@ module.exports = {
});
}

};
};
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down