vindimy / altcointip

Reddit ALTcointip bot gives users ability to tip each other using various cryptocurrency coins, such as Bitcoins, Litecoins, Peercoins, Namecoins, and others.
http://www.reddit.com/r/ALTcointip/wiki/index
GNU General Public License v2.0
106 stars 143 forks source link

Issue when adding a custom coin #42

Closed josephdyland closed 7 years ago

josephdyland commented 9 years ago

I am working on adding LiteDoge coin altcointip bot to Reddit.

My coins.yml looks like;

 Litedoge
ldoge:
    enabled: true
    unit: ldoge
    name: Litedoge
    symbol: 'LDOGE'
    config_file: '~/.litedoge/litedoge.conf'
    config_rpcserver: '127.0.0.1'
    minconf:
        givetip: 10
        withdraw: 144
    txmin:
        givetip: 0.00000001
        withdraw: 0.05
    txfee: 0.01
    walletpassphrase: 'removed'
    explorer:
        address: 'http://www.presstab.pw/phpexplorer/LDOGE/address.php'
        transaction: 'http://www.presstab.pw/phpexplorer/LDOGE/tx.php'
    regex:
        address: '(P[1-9a-z]{20,40})'
        units: '(ldoge|ldogecoin|ldogecoins)'

I ran python _add_coin.py ldoge

INFO:cointipbot:CointipBot::init_logging(): -------------------- logging initialized --------------------
DEBUG:cointipbot:CointipBot::connect_db(): connecting to database...
INFO:cointipbot:CointipBot::connect_db(): connected to database ldogetipbot as root
INFO:cointipbot:< CointipBot::__init__(): DONE, batch-limit = 1000, sleep-seconds = 60
DEBUG:cointipbot:CtbCoin::__init__(): connecting to Litedoge...
DEBUG:bitcoin:Read 5 parameters from ~/.litedoge/litedoge.conf
DEBUG:bitcoin:Making HTTP connection to 127.0.0.1:53333
INFO:cointipbot:CtbCoin::__init__():: connected to Litedoge
INFO:cointipbot:Setting tx fee of 0.010000
DEBUG:bitcoin:Starting "settxfee" JSON-RPC request
DEBUG:bitcoin:Got 36 byte response from server in 1 ms
DEBUG:cointipbot:> add_coin(ldoge)
DEBUG:bitcoin:Starting "walletpassphrase" JSON-RPC request
DEBUG:bitcoin:Got 36 byte response from server in 128 ms
DEBUG:bitcoin:Starting "getnewaddress" JSON-RPC request
DEBUG:bitcoin:Got 68 byte response from server in 2 ms
DEBUG:bitcoin:Starting "walletlock" JSON-RPC request
DEBUG:bitcoin:Got 36 byte response from server in 1 ms
INFO:cointipbot:add_coin(): got new address dcfqDvYeYEzdFTnnjmDoaJiZcFKBbcCWRG for thedoctor___
/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py:450: Warning: Data truncated for column 'coin' at row 1
  cursor.execute(statement, parameters)
DEBUG:cointipbot:< add_coin(ldoge) DONE

when I run sh _start.sh it fails to start with Error 500

    INFO:cointipbot:< init_regex() DONE (96 expressions)
DEBUG:cointipbot:> CtbUser::__init__(thedoctor___)
DEBUG:cointipbot:< CtbUser::__init__(thedoctor___) DONE
DEBUG:cointipbot:> CtbUser::is_registered(thedoctor___)
DEBUG:cointipbot:< CtbUser::is_registered(thedoctor___) DONE (yes)
DEBUG:cointipbot:> CtbUser::balance(thedoctor___)
INFO:cointipbot:CtbUser::balance(thedoctor___): getting ldoge givetip balance
DEBUG:cointipbot:CtbCoin::getbalance(thedoctor___, 10)
DEBUG:bitcoin:Starting "getbalance" JSON-RPC request
ERROR:bitcoin:500 (Internal Server Error) response from bitcoind
ERROR:cointipbot:CtbCoin.getbalance(): error getting Litedoge (minconf=10) balance for thedoctor___: 500 (Internal Server Error) response from bitcoind
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "cointipbot.py", line 533, in __init__
    self.self_checks()
  File "cointipbot.py", line 142, in self_checks
    ctb_balance = b.get_balance(coin=c, kind='givetip')
  File "ctb/ctb_user.py", line 91, in get_balance
    balance = self.ctb.coins[coin].getbalance(_user=self.name, _minconf=self.ctb.conf.coins[coin].minconf[kind])
  File "ctb/ctb_coin.py", line 70, in getbalance
    balance = self.conn.getbalance(user, minconf)
  File "ctb/pifkoin/bitcoind.py", line 69, in __call__
    return server._rpc_call(self.method, *args)
  File "ctb/pifkoin/bitcoind.py", line 216, in _rpc_call
    raise BitcoindException('%d (%s) response from bitcoind' % (response.status, response.reason))
ctb.pifkoin.bitcoind.BitcoindException: 500 (Internal Server Error) response from bitcoind

I think I am close to getting this up and running but cannot seem to track down the problem.

vindimy commented 9 years ago

One of the issues I see is that the 'unit' field was designed to be 3-letter-long and in your case it's 5 letters (unit: ldoge). The SQL table definition is such that anything longer than 3 letters will be cut short (so you see Warning: Data truncated for column 'coin' at row 1 cursor.execute(statement, parameters)). As a result, maybe the code ends up sending an invalid request to coin daemon and receives a bad response.

josephdyland commented 9 years ago

Thank you for the quick response! I created a new table and imported the altcointip.sql source. changed the symbol and unit to LDG and Modified /src/conf/db.yml to point to the new table. Then ran python _addcoin LDG. I think I just get the same error with out the data truncated warning.

DEBUG:cointipbot:> CtbUser::__init__(thedoctor___)
DEBUG:cointipbot:< CtbUser::__init__(thedoctor___) DONE
DEBUG:cointipbot:> CtbUser::is_registered(thedoctor___)
DEBUG:cointipbot:< CtbUser::is_registered(thedoctor___) DONE (no)
DEBUG:cointipbot:> CtbUser::register(thedoctor___)
DEBUG:bitcoin:Starting "walletpassphrase" JSON-RPC request
DEBUG:bitcoin:Got 36 byte response from server in 131 ms
DEBUG:bitcoin:Starting "getnewaddress" JSON-RPC request
DEBUG:bitcoin:Got 68 byte response from server in 2 ms
DEBUG:bitcoin:Starting "walletlock" JSON-RPC request
DEBUG:bitcoin:Got 36 byte response from server in 1 ms
INFO:cointipbot:CtbUser::register(thedoctor___): got LDG address dGnSwTCyBa4YKvWuvzmEKg5TWb1m24PfGG
DEBUG:cointipbot:< CtbUser::register(thedoctor___) DONE
DEBUG:cointipbot:> CtbUser::balance(thedoctor___)
INFO:cointipbot:CtbUser::balance(thedoctor___): getting LDG givetip balance
DEBUG:cointipbot:CtbCoin::getbalance(thedoctor___, 10)
DEBUG:bitcoin:Starting "getbalance" JSON-RPC request
ERROR:bitcoin:500 (Internal Server Error) response from bitcoind
ERROR:cointipbot:CtbCoin.getbalance(): error getting Litedoge (minconf=10) balance for thedoctor___: 500 (Internal Server Error) response from bitcoind
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "cointipbot.py", line 533, in __init__
    self.self_checks()
  File "cointipbot.py", line 142, in self_checks
    ctb_balance = b.get_balance(coin=c, kind='givetip')
  File "ctb/ctb_user.py", line 91, in get_balance
    balance = self.ctb.coins[coin].getbalance(_user=self.name, _minconf=self.ctb.conf.coins[coin].minconf[kind])
  File "ctb/ctb_coin.py", line 70, in getbalance
    balance = self.conn.getbalance(user, minconf)
  File "ctb/pifkoin/bitcoind.py", line 69, in __call__
    return server._rpc_call(self.method, *args)
  File "ctb/pifkoin/bitcoind.py", line 216, in _rpc_call
    raise BitcoindException('%d (%s) response from bitcoind' % (response.status, response.reason))
ctb.pifkoin.bitcoind.BitcoindException: 500 (Internal Server Error) response from bitcoind
josephdyland commented 9 years ago

I resolved this issue, by turning enableaccounts=1 in the wallets .conf.

I now have the bot connected to reddit and monitoring the subreddit. Users can register and get a address, They can also send coins to address and +info returns the proper amount.

My issue now is Tipping, I have tried dozens of differnt combinations and I keep getting a reddit message back asking to verify Syntax.

This is from the logs when it processes the tip.

INFO:cointipbot:CointipBot::check_inbox(): no match
DEBUG:cointipbot:> CtbUser::__init__(thedoctor___)
DEBUG:cointipbot:< CtbUser::__init__(thedoctor___) DONE
DEBUG:cointipbot:CointipBot::check_inbox(): Sorry thedoctor\_\_\_, I didn't understand your comment. Please verify syntax and try again.

*****
DEBUG:cointipbot:> eval_comment()
DEBUG:cointipbot:eval_comment(): match found
DEBUG:cointipbot:> reddit_get_parent_author()
DEBUG:cointipbot:< reddit_get_parent_author(ct0ai57) -> josephdyland
DEBUG:cointipbot:eval_comment(): creating action givetip: to_user=josephdyland, to_addr=None, amount=None, coin=None, fiat=None
DEBUG:cointipbot:> CtbAction::__init__({'fiat_val': None, 'fiat': None, 'msg_id': None, 'subr': Subreddit(subreddit_name='litedoge'), 'keyword': u'all', 'atype': 'givetip', 'self': <ctb.ctb_action.CtbAction object at 0x7fd6ff229610>, 'from_user': None, 'to_addr': None, 'to_user': u'josephdyland', 'ctb': <cointipbot.CointipBot object at 0x7fd700fc9ad0>, 'coin_val': None, 'msg': <praw.objects.Comment object at 0x7fd6ff695790>, 'coin': None})
DEBUG:cointipbot:> CtbUser::__init__(josephdyland)
DEBUG:cointipbot:< CtbUser::__init__(josephdyland) DONE
DEBUG:cointipbot:> CtbUser::__init__(thedoctor___)
DEBUG:cointipbot:< CtbUser::__init__(thedoctor___) DONE
DEBUG:cointipbot:CtbAction::__init__(): <CtbAction: type=givetip, msg.body=+/u/ldogetipbot all, from_user=<CtbUser: name=thedoctor___, giftamnt=None, joindate=None, addr={}, redditobj=thedoctor___, banned=False>, to_user=<CtbUser: name=josephdyland, giftamnt=None, joindate=None, addr={}, redditobj=None, banned=False>, to_addr=None, coin=None, fiat=None, coin_val=None, fiat_val=None, subreddit=litedoge>
WARNING:cointipbot:eval_comment(): CtbAction::__init__(type=%s): keyword is coin-only, but only fiat is set
justinvforvendetta commented 9 years ago

this is interesting. when i played with it a bit, i was able to get tipping to work, and lost withdraw function.