Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Claimable Balances error when trying to claim the value #245

Closed
CaioTeixeira95 opened this issue Oct 1, 2021 · 3 comments · Fixed by #248
Closed

Claimable Balances error when trying to claim the value #245

CaioTeixeira95 opened this issue Oct 1, 2021 · 3 comments · Fixed by #248
Assignees
Labels
bug Something isn't working

Comments

@CaioTeixeira95
Copy link

Hello everyone!

What version are you using?

SDK Version 4.1.1

What did you do?

I tried to claim a balance for the native asset on the Demo wallet.

First I ran the following script:

import time

from stellar_sdk.exceptions import NotFoundError, BadRequestError, BadResponseError
from stellar_sdk import (
    Keypair,
    Network,
    Server,
    TransactionBuilder,
    Asset,
    Claimant,
    ClaimPredicate,
    CreateClaimableBalance,
)


server = Server("https://horizon-testnet.stellar.org")

sender = Keypair.from_secret("SDZX46FKI6PRND3X6NP4U7W3P4U4GMOXLRXK6SVO2TPYH2K2AICCMDYK")
receiver = Keypair.from_public_key(
    "GAFMXOTSXIDUK64WAOJLWKRA7ELTC53COAQ2GOS3GQY2GV27JC3R7KQP"
)

# NOTE: Proper error checks are omitted for brevity; always validate things!

try:
    aAccount = server.load_account(sender.public_key)
except NotFoundError:
    raise Exception(f"Failed to load {sender.public_key}")

# Create a claimable balance with our two above-described conditions.
soon = int(time.time() + 60)
bCanClaim = ClaimPredicate.predicate_before_relative_time(60)
aCanClaim = ClaimPredicate.predicate_not(
    ClaimPredicate.predicate_before_absolute_time(soon)
)

# Create the operation and submit it in a transaction.
claimableBalanceEntry = CreateClaimableBalance(
    asset=Asset.native(),
    amount="100",
    claimants=[
        Claimant(destination=receiver.public_key, predicate=bCanClaim),
        Claimant(destination=sender.public_key, predicate=aCanClaim),
    ],
)

tx = (
    TransactionBuilder(
        source_account=aAccount,
        network_passphrase=Network.TESTNET_NETWORK_PASSPHRASE,
        base_fee=server.fetch_base_fee(),
    )
    .append_operation(claimableBalanceEntry)
    .set_timeout(180)
    .build()
)
tx.sign(sender)

try:
    txResponse = server.submit_transaction(tx)
    print("Claimable balance created!")
except (BadRequestError, BadResponseError) as err:
    print(f"Tx submission failed: {err}")

After this, I went to the Demo Wallet and logged in with my secret key, then I clicked to claim the balance.

What did you expect to see?

I expect to claim the balance and receive it to my account.

What did you see instead?

I received the following error:

instruction: Claiming asset native:undefined

instruction: Not a trusted asset, need to add a trustline

instruction: Adding native:undefined trustline

instruction: Loading account to get a sequence number for add trustline transaction

instruction: Building add trustline transaction

error: Add trustline transaction failed

Issuer cannot be null

error: Issuer cannot be null

Screen Shot 2021-10-01 at 14 40 17

@CaioTeixeira95 CaioTeixeira95 added the bug Something isn't working label Oct 1, 2021
@shanzzam
Copy link
Contributor

Will triage this week 10/18

@quietbits quietbits self-assigned this Oct 19, 2021
@shanzzam
Copy link
Contributor

Thanks for the well-written issue @CaioTeixeira95! It was easy to replicate and find the issue. Will be fixing during this sprint.

@quietbits quietbits linked a pull request Oct 22, 2021 that will close this issue
@quietbits
Copy link
Contributor

@CaioTeixeira95 the fix is live, please let us know if there is still an issue with it. Thanks again for reporting! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants