pik / pypayd

a small daemon for processing bitcoin payments
MIT License
5 stars 4 forks source link

TypeError: unorderable types: list() > int() #5

Closed ser closed 9 years ago

ser commented 9 years ago

Sorry, still some problems. I've produced an invoice, sent money and pypayd is catching an exception here:

https://github.com/pik/pypayd/blob/master/src/payments.py#L131

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.4/threading.py", line 868, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/share/pypayd/src/payments.py", line 63, in _run
    self.pollActiveAddresses()
  File "/usr/share/pypayd/src/payments.py", line 103, in pollActiveAddresses
    self.pollAddress(addr)
  File "/usr/share/pypayd/src/payments.py", line 92, in pollAddress
    self.processTxIn(addr, tx)
  File "/usr/share/pypayd/src/payments.py", line 131, in processTxIn
    if len(orders > 1):
TypeError: unorderable types: list() > int()
ser commented 9 years ago

To motivate you: I made my example use case to the stage, which requires pypayd to confirm the transaction.

https://github.com/ser/topitup

screenshotszaznaczenie_002 zaznaczenie_032 screenshotszaznaczenie_001

pik commented 9 years ago

The parentheses were in the wrong place, should be fixed.

ser commented 9 years ago

Yeah, I was thinking that it might be so simple, but when fixed that line, another came, and I got confused

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.4/threading.py", line 868, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/share/pypayd/src/payments.py", line 63, in _run
    self.pollActiveAddresses()
  File "/usr/share/pypayd/src/payments.py", line 103, in pollActiveAddresses
    self.pollAddress(addr)
  File "/usr/share/pypayd/src/payments.py", line 92, in pollAddress
    self.processTxIn(addr, tx)
  File "/usr/share/pypayd/src/payments.py", line 165, in processTxIn
    bindings = {'receiving_address': receiving_address, 'txid': tx['txid'], 'source_address': sources, 'confirmations': tx.get('confirmations', 0) , 'block_number': (self.current_block -tx.get('confirmations', 0)), 'notes': str(notes), 'special_digits':tx_special_digits, 'order_id': order_id, 'amount': float(amount), "valid": valid }
UnboundLocalError: local variable 'amount' referenced before assignment
pik commented 9 years ago

@ser Apologies for the delay with this - I didn't want to claim to have a fix without having added tests for it; and I hadn't a chance to do that until this weekend.

Hopefully I'll have a little more time this weekend -- I'd actually like to spend some time to build a web-gui front-end for accessing the pypayd API.

ser commented 9 years ago

Thumbs up, Alex :)

ser commented 9 years ago

Can I help you in any way? I am afraid a little bit of touching the code

pik commented 9 years ago

Are you still having this issue? I've added a test case: https://github.com/pik/pypayd/blob/master/tests.py#L275 but there is a chance it's missing your specific error?

ser commented 9 years ago

Hi, I did not notice your commits. Checked out the code, and some new problem.

I send over a request number 0:

{'method': 'create_order', 'params': {'amount': '1', 'qr_code': True}, 'id': 0, 'jsonrpc': '2.0'}

And get the response:

{'jsonrpc': '2.0', 'id': 0, 'result': {'amount': '0.003', 'order_id': '2BvrHdcLDTeQTuVmibDGGuZhjnXi', 'timeleft': 3600, 'receiving_address': 'moKpo8xQGajDgpBVjnfBomMNWsVB3PnZfR', 'qr_image': 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJwAAACcAQAAAACiw//gAAABiklEQVR4nLWXQWolMQxEnz7Zl27Q9z+Wb1A6Qc2iMxDIT6Cx410LJOTSk+Su8O3M67sNHhinqqamq6GGqaon7u+MOHFQEiTsxN7NkylGa2Y89sXUM/c35wNAroyAy/M0pZ9iDupJax67/6KnYmzLOaFnucFfDA27MUkSyyAS3Z8H9KwMWlwjjtSorIYhDW5c3o9JHMuJLazY3tfTJJZkJbei23XHyMTYd5rSdp4fAqUJA/QE9z7zyIpMACk+waelT0Vj46ADzBtbRnYsYJt5LOJEEZFA+330klV0r7kFzdTsMy8USUSWiXXk7oQguHuJfeYTRGIibAVv170M7UYA4yZ1gE8iJCQ5ukHd7c0JS42WhmE6c2IfKdgSyIqV/TwZjwWmYTX0Pp9OEhE5JNaBumMD9+uG3Bt0m6UA04IRZjSP3H+anxAcsBC2D+yOxDZ3x4d4n88XUwjDqKaoXgfubpzI8ec02Z9L/40XugaTXtt8vlBgWNN2YJYOvD8LAipoX+txSm9O/cF/xz+JdUlmIYkd4wAAAABJRU5ErkJggg==', 'exact_amount': False}}

but sending another one:

{'method': 'create_order', 'params': {'amount': '1', 'qr_code': True}, 'id': 1, 'jsonrpc': '2.0'}

results unfortunately with:

{'jsonrpc': '2.0', 'id': 1, 'error': {'message': 'Invalid params', 'data': {'args': ['unorderable types: str() >= int()'], 'message': 'unorderable types: str() >= int()', 'type': 'TypeError'}, 'code': -32602}}
pik commented 9 years ago

@ser Can you make sure you have pulled the latest head and try with db = "new_db" in your config file? Could you also provide some config details? What blockchain service are you using to connect? Do you have a txid for the transaction being sent? I have been unable to reproduce this so far.

ser commented 9 years ago

Hi, I checked two times if I have the newest master branch code. Yes, I have. I removed database file and started from scratch. This is my config:

DEFAULT_TICKER = 'btcavgav'
DEFAULT_CURRENCY = 'EUR'
DEFAULT_WALLET_FILE = 'payment_wallet.txt'
DEFAULT_WALLET_PASSWORD = "password"
GEN_NEW = True
#delay between requests to the blockchain service for new transactions
POLLING_DELAY = 33
UPDATE_ON_CONFIRM = 2 #can also take a list, such as [6, 20, 100]
ORDER_LIFE=3600

I'm using test-insight, but the same happens with blockr

ser commented 9 years ago

Hi Alex, were you able to reproduce the bug?

pik commented 9 years ago

@ser I don't seem to be able to reproduce this just based on the config settings you have provided. Could you try running the following: git fetch origin; git reset --hard remotes/origin/master; python tests.py and let me know if that produces any errors?

You might have to edit the tests to use blockr instead of insight at least the later wasn't working recently for me, which really should be in it's own configuration file and not in-line test-setup.

ser commented 9 years ago

Hi, it seems that in a new environment nearly everything works :) It was probably some old library or something, which was giving me those errors. Thanks!!!