Closed ser closed 9 years ago
Ah, I'm guessing you were using the textfile for the config values and they were not getting parsed correctly. I don't remember now whether ConfigObject was supposed to do this for us but this wouldn't have happened if I had bothered to add unit tests for it.
It should be fixed with: https://github.com/pik/pypayd/commit/aca85f19342ad5035872442d6222de18c3a292bd
If it's not - let me know.
Nearly works, two more problems in config
1)
configobj.ConfigObjError: Parsing failed with several errors.
First error at line 39.
line 39 is:
STATE = {"last_order_updates": {"order_id":None, "timestamp": None}}
2)
configobj.DuplicateError: Duplicate keyword name at line 40.
and indeed, DB = None
is two times there.
And more.
I am not sure if I am doing it properly, but I copy config.py do pypayd.conf, adding [Default]
on the top and running pypayd:
$ pypayd --server --testnet wallet --from-file payment_wallet.txt --decrypt-pw PlePle
Loading config settings...
Error handling config file field DEFAULT_KEYPATH, 0/0/1
Error handling config file field DEFAULT_TICKER, insight
Error handling config file field DEFAULT_CURRENCY, EUR
Error handling config file field DEFAULT_WALLET_FILE, wallet.txt
Error handling config file field DEFAULT_WALLET_PASSWORD, foobar
Error handling config file field DEFAULT_DB, pypayd.db
Error handling config file field DEFAULT_TESTNET_DB, paypayd_testnet.db
Error handling config file field RPC_HOST, 127.0.0.1
Error handling config file field BLOCKCHAIN_CONNECT, http://localhost:3001
Error handling config file field BLOCKCHAIN_SERVICE, insight
Error handling config file field LEAF_POLL_LIFE, ORDER_LIFE*2
Error handling config file field MAX_LOG_SIZE, 16*1024*1024
Error handling config file field DATA_DIR,
Error handling config file field RPC_USER, user
Error handling config file field RPC_PASSWORD, password
Wallet loaded: tpubD6NzVbkrYhZ4Wd7mrkT4sRtV69mJWukWtMxXQjH7mrHAqRCbg8UDi4vUKo8PfR8iLtF2nzAoASLo7eEBC1kQ3x8mHKSLhd3nUAsusqQhuWq
Keypath: 0/0/1
/home/ser/.local/share/pypayd paypayd_testnet.db
DB loaded: paypayd_testnet.db
Testing Blockchain connection {'error': None, 'type': 'from RPC calls', 'blockChainHeight': 508918, 'startTs': 1437840126281, 'height': 508918, 'syncPercentage': '100.000', 'status': 'finished', 'endTs': 1437840126644}
Payment Handler loaded, starting auto-poller..
API Started on 127.0.0.1:3080
Current block is 509036 polling 1 active addresses
calling insight api for address info moKpo8xQGajDgpBVjnfBomMNWsVB3PnZfR
Current block is 509036 polling 1 active addresses
calling insight api for address info moKpo8xQGajDgpBVjnfBomMNWsVB3PnZfR
Why those above config values are incorrect?
Oh yeah don't copy that ^_^ (e.g. STATE is internal to config), I should probably clarify some of that. Just over-write the things you want to over-write in pypayd.conf. The presedence order is:
config.py
pypayd.conf
commandline args
still problems, the pypayd.conf content is now:
[Default]
DEFAULT_TICKER = 'bitstamp'
DEFAULT_CURRENCY = 'EUR'
DEFAULT_WALLET_FILE = 'payment_wallet.txt'
DEFAULT_WALLET_PASSWORD = "PlePle"
GEN_NEW = True
#delay between requests to the blockchain service for new transactions
POLLING_DELAY = 10
UPDATE_ON_CONFIRM = 2 #can also take a list, such as [6, 20, 100]
and i get:
Error handling config file field DEFAULT_TICKER, bitstamp
Error handling config file field DEFAULT_CURRENCY, EUR
Error handling config file field DEFAULT_WALLET_FILE, payment_wallet.txt
Error handling config file field DEFAULT_WALLET_PASSWORD, PlePle
Yeah sorry about that - can you try again with the commit I just pushed?
Yup, now it is parsed properly, cheers :+1:
But there is another issue, the currency. Am I able to specify an other currency than USD?
API Exception: {'type': 'KeyError', 'message': "'EUR'", 'args': ('EUR',)}
Traceback (most recent call last):
File "/usr/lib/python3.4/site-packages/jsonrpc/manager.py", line 108, in _get_responses
result = method(*request.args, **request.kwargs)
File "/usr/share/pypayd/src/api.py", line 39, in create_order
ret = payment_handler.createOrder(amount, currency, item_number, order_id, gen_new)
File "/usr/share/pypayd/src/payments.py", line 181, in createOrder
btc_price = str(ticker.getPriceInBTC(amount, currency=currency))
File "/usr/share/pypayd/src/priceinfo.py", line 48, in getPriceInBTC
btc_price = D(str(self.getPrice(currency=currency, ticker=ticker)))
File "/usr/share/pypayd/src/priceinfo.py", line 40, in getPrice
btc_price, last_updated = self.tickers[ticker][currency.upper()]()
KeyError: 'EUR'
@ser
It was planned but I never got around to testing the other ones =/
I've made some adjustments so coindesk ticker should work with any currency they support now (i've only tested 'EUR' and 'GBP' so far though). I'll try and find some time later this week to add the missing tests for this and a guide to adding your own priceinfo ticker.
Hi Alex, it's fantastic, I can read your recent commit and see how it is done. I think I will be able to add other currencies by my own if I need it.
Thanks again, now pypayd service is ready for the client deployment, which will be GPL and I hope that it will be a nice complimentary use case for pypayd.
Cheers!
Now it does not work at all. The problem is that many of config.py values are being parsed incorrectly, and we have for example:
I had to change line in src/interfaces/insight.py from:
if config.LOCAL_BLOCKCHAIN:
toif config.LOCAL_BLOCKCHAIN == True:
And it is just beginning, most of values are treated as string, and we have for example:
because
self.server = wsgiserver.CherryPyWSGIServer((config.RPC_HOST, config.RPC_PORT), d)
config.RPC is a string, and cherrypy expects and integer.When I fix few next problem, I am getting finally:
print(response)
which killed my enthusiasm with fixing attempts :(
I am not able to enumerate all errors, but all of them are related to values being strings, not floats or integers. Is it related to new python
Python 3.4.3 (default, Mar 25 2015, 17:13:50)
?How to fix it, as currently pypayd does not work at all :( Please help :)