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)