Closed Pytness closed 2 years ago
I can't reproduce it:
> pmts = self.wallet.incoming(
tx_id="invalid_tx_id",
unconfirmed=True
)
tests/test_jsonrpcwallet.py:778:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
monero/transaction/__init__.py:313: in __call__
return fetch(self.account_idx, PaymentFilter(**filterparams))
monero/transaction/__init__.py:422: in __init__
self.tx_ids = list(map(_validate_tx_id, tx_ids))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
txid = 'invalid_tx_id'
def _validate_tx_id(txid):
if not bool(re.compile("^[0-9a-f]{64}$").match(txid)):
> raise ValueError(
"Transaction ID must be a 64-character hexadecimal string, not "
"'{}'".format(txid)
)
E ValueError: Transaction ID must be a 64-character hexadecimal string, not 'invalid_tx_id'
Are you using version 1.0? Could you add a test that causes the error you're fixing?
May be important to note that I am using a testnet wallet
rcp server
monero-wallet-rpc --daemon-address node2.sethforprivacy.com:28089 --testnet --wallet-file serverwallet \
--password "" --rpc-bind-port 28088 --disable-rpc-login
test.py
import monero
from monero.wallet import Wallet
from monero.backends.jsonrpc import JSONRPCWallet
print("Using version %s" % monero.__version__)
wallet = Wallet(JSONRPCWallet(port=28088))
account = wallet.accounts[0]
account.incoming(
unconfirmed=True,
confirmed=False,
tx_id="2c846263b369daff443df12bf0b4cc5855bee9c5966daa3926e2091436556b3a",
)
❯ python3 test.py
Using version 1.0
Traceback (most recent call last):
File "test.py", line 10, in <module>
account.incoming(
File "/usr/local/lib/python3.8/dist-packages/monero/transaction/__init__.py", line 313, in __call__
return fetch(self.account_idx, PaymentFilter(**filterparams))
File "/usr/local/lib/python3.8/dist-packages/monero/backends/jsonrpc/wallet.py", line 178, in transfers_in
pmts.extend(_pmts.get("pool", []))
UnboundLocalError: local variable '_pmts' referenced before assignment
@emesik I just realized, you used a proper invalid tx_id
, as a malformed tx_id
.
The test i just posted should show the error, but let me explain a little bit better the problem and my case:
I have a client making a payment to a server's address. The client sends the
tx_id
immediately after making the payment (ignore possible security problems).The server looks for the
tx_id
to notify the user when its found. Server fails to find thetx_id
and crashes
Hi,
It still seems a bit unclear to me. But I'll take a look next week and let you know, as right now I'm about to get away for an extended weekend and have a rest.
Hopefully, you may use your patched version for a while.
Great thanks,
On Thu, Apr 7, 2022 at 2:44 PM Fernando Vega Catalán < @.***> wrote:
@emesik https://github.com/emesik I just realized, you used an proper invalid tx_id as a malformed tx_id. The test i just posted should show the error, but let me explain a little bit better the problem and my case:
I have a client making a payment to a server's address. The client sends the tx_id immediately after making the payment (ignore possible security problems).
The server looks for the tx_id to notify the user when its found. Server fails to find the tx_id and crashes
— Reply to this email directly, view it on GitHub https://github.com/monero-ecosystem/monero-python/issues/110#issuecomment-1091689202, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADDMQ7ODUAOL2VUWRO54QTVD3KCLANCNFSM5SZBIPGA . You are receiving this because you were mentioned.Message ID: @.***>
-- Michał
When retrieving a non existing unconfirmed payment by its tx_id,
wallet.incoming
throws an error instead of returning an empty array.Example: