Closed parkerburchett closed 3 years ago
What version of the lib are you using? since you had to change the imports, I'm guessing it's 1.0.0. We fixed a lot of bugs in 1.1.0. Can you confirm that this issue is present on 1.1.0?
I'm now using version 1.1 with this code
from xrpl.clients import JsonRpcClient
from xrpl.models import IssuedCurrencyAmount, Payment, TrustSet
from xrpl.transaction import safe_sign_and_submit_transaction
from xrpl.wallet import Wallet, generate_faucet_wallet
non_standard_currency_code = "0158415500000000C1F76FF6ECB0BAC600000000"
CLIENT = JsonRpcClient("https://s.altnet.rippletest.net:51234/")
# create wallets
ISSUING_WALLET = generate_faucet_wallet(CLIENT,debug=True)
RECEIVING_WALLET = generate_faucet_wallet(CLIENT,debug=True)
# create a trust line from receiver to issuer.
safe_sign_and_submit_transaction(
TrustSet(
account=RECEIVING_WALLET.classic_address,
limit_amount=IssuedCurrencyAmount(
issuer=ISSUING_WALLET.classic_address,
currency=non_standard_currency_code,
value="1000000",
),
),
RECEIVING_WALLET,
CLIENT,
)
# now, issue some non standard currency code from issuer to receiver
response = safe_sign_and_submit_transaction(
Payment(
account=ISSUING_WALLET.classic_address,
amount=IssuedCurrencyAmount(
issuer=ISSUING_WALLET.classic_address,
currency=non_standard_currency_code,
value="100",
),
destination=RECEIVING_WALLET.classic_address,
),
ISSUING_WALLET,
CLIENT,
)
print(response.result)
I get the same error.
my_venv\lib\site-packages\xrpl\core\binarycodec\types\currency.py", line 80, in __init__
iso = code_bytes.decode("ascii")
UnicodeDecodeError: 'ascii' codec can't decode byte 0xec in position 0: ordinal not in range(128)
I stepped through the code and the error is in safe_sign_and_submit_transaction
indeed. the linked PR fixes this and we'll likely release a patch 1.1.1 version with that change in a few days
v1.1.1 is now published. have fun @parkerburchett !
I found this code from @ledhed2222 at this issue https://github.com/XRPLF/xrpl-py/issues/259.
This works as is.
And gives this output:
However when I replace the currency code with the example nonstandard currency code at https://xrpl.org/currency-formats.html#currency-codes
I get this error:
I tried non_standard_currency_code = u"0158415500000000C1F76FF6ECB0BAC600000000"
and non_standard_currency_code = "0158415500000000C1F76FF6ECB0BAC600000000".encode('utf-8')
Neither fixed it.
Does anyone know how to create a TrustSet and Payment with a nonstandard currency code?