From 09fcbd6ee5cfba2e6c30581d99e19c2a6b6a6420 Mon Sep 17 00:00:00 2001 From: unek Date: Sat, 22 Feb 2014 12:48:48 +0100 Subject: [PATCH] proper collection of fees --- app.js | 16 ++++++++++++++++ config/irc.yml | 1 + 2 files changed, 17 insertions(+) diff --git a/app.js b/app.js index e169ff5..77427b5 100644 --- a/app.js +++ b/app.js @@ -231,6 +231,22 @@ client.addListener('message', function(from, channel, message) { client.say(channel, settings.messages.withdraw_success.expand({name: from, address: address, balance: balance, amount: balance - settings.coin.withdrawal_fee, transaction: reply})); client.say(channel, settings.messages.withdraw_success2.expand({name: from, address: address, balance: balance, amount: balance - settings.coin.withdrawal_fee, transaction: reply})); + + // transfer the rest (usually withdrawal fee - txfee) to the master account + coin.getBalance(from.toLowerCase(), function(err, balance) { + if(err) { + winston.error('Something went wrong while transferring fees', err); + return; + } + + var balance = typeof(balance) == 'object' ? balance.result : balance; + coin.move(from.toLowerCase(), settings.rpc.master_account, balance, function(err) { + if(err) { + winston.error('Something went wrong while transferring fees', err); + return; + } + }); + } }); }); } else { diff --git a/config/irc.yml b/config/irc.yml index a844324..a0c88a3 100644 --- a/config/irc.yml +++ b/config/irc.yml @@ -14,6 +14,7 @@ development: port: 22555 user: 'dogecoinrpc' pass: 'pass' + master_account: unek coin: withdrawal_fee: 2 min_withdraw: 5