0

I'm trying to overwrite the current trustline flags, but I have issues with that. I keep getting setTrustLineFlagsMalformed, but I don't know why.

Am I using this function wrong?

tx.append_set_trust_line_flags_op(
    trustor=trustor.public_key,
    asset=asset,
    set_flags=TrustLineFlags.AUTHORIZED_TO_MAINTAIN_LIABILITIES_FLAG,
)

MCVE: Minimal complete verifiable example

from stellar_sdk import (
    Asset,
    TransactionBuilder,
    Keypair,
    Network,
    Server,
    TrustLineFlags,
)


def play_with_trust(trustor: Keypair, asset: Asset):
    source_account = server.load_account(trustor.public_key)
    tx = TransactionBuilder(
        source_account=source_account,
        network_passphrase=Network.TESTNET_NETWORK_PASSPHRASE,
        base_fee=100,
    )
    # tx = tx.append_change_trust_op(
    #             asset=asset
    #         )
    tx.append_set_trust_line_flags_op(
        trustor=trustor.public_key,
        asset=asset,
        set_flags=TrustLineFlags.AUTHORIZED_TO_MAINTAIN_LIABILITIES_FLAG,
    )
    tx = tx.set_timeout(300)
    tx_envelope = tx.build()
    tx_envelope.sign(trustor)
    return server.submit_transaction(tx_envelope)


if __name__ == "__main__":
    is_initial = False
    server = Server(horizon_url="https://horizon-testnet.stellar.org")
    secrets = [
        "SCFRDE3BMOF67LC254SLC4NMBYCDA4MRVGLAKVARC24TGGF4LJCZJKZF",
        "SDD6AFQ5JIP7EXZNFZSLEY5AEIOPNVI35WVNDVC22AWW7RAIW4RQZPH4",
        "SACID3EGZHQLZWHYOK6L2RJNMOQHTJIUG6NOLCRMTXTC5CA7DEYBWQA3",
        "SB6MJ6M3BPJZUGFP2QCODUIKWQWF6AIN4Z6L3J6PWL3QGDW4L6YR3QIU",
    ]
    trustor = Keypair.from_secret(secrets[0])
    destination = Keypair.from_secret(secrets[1])
    issuing_keypair = Keypair.from_secret(secrets[2])
    distributor_keypair = Keypair.from_secret(secrets[3])
    print(f"trustor: http://testnet.stellarchain.io/address/{trustor.public_key}")
    asset = Asset("BSS", issuing_keypair.public_key)

    result = play_with_trust(trustor, asset)
    print(result)

1 Answer 1

0

I found the issue in the docs (sadly the link seems not to work ... search for "setTrustlineFlags"):

This can happen for a number of reasons: the asset specified by AssetCode and AssetIssuer is invalid; the asset issuer isn’t the source account; the Trustor is the source account; the native asset is specified; or the flags being set/cleared conflict or are otherwise invalid

So four potential reasons:

  1. the asset specified by AssetCode and AssetIssuer is invalid
  2. the asset issuer isn’t the source account => This was an issue
  3. Trustor is the source account => This was an issue
  4. the flags being set/cleared conflict or are otherwise invalid

The "source account" refers to the parameter of the TransactionBuilder. You can specify a source account for append_set_trust_line_flags_op as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.