HTTP 400 Bad Request: transaction <txid>: should have been authorized by <my-address> but was actually authorized by <address>

Hi all,

I’m trying to submit an atomic transfer using the pythonSDK on the testnet composed of 2 ASA transfers laid out here.

The first transfer is from my account to an application. I’m signing it with my own key. The second one is an asa transfer from the application to my account and uses an logic signature. Then I try to send the atomic transfer.

from algosdk.v2client import algod
from algosdk import mnemonic
from algosdk.future.transaction import *
from config import *

my_account = 'SJQOZU6RYTAEUN4SGZWWR4DTAPO4ELGC6CM4AX2S4TA5KFBJXLPQGAMWT4' #TESTNET

algod_client = algod.AlgodClient(algod_token, algod_address)
params = algod_client.suggested_params()

badge_account = 'MJXF5ZZAIZKHEHQD324UEWXID3TQMPOF7P52PXSCEJBH66TKNATAEVMIHU'

devcoin_id = 3797
badge_id = 10623

# Transaction 1
txn_1 = AssetTransferTxn(
    sender=my_account,
    sp=params,
    receiver=badge_account,
    amt=5,
    index=devcoin_id)


# Transaction 2
txn_2 = AssetTransferTxn(
    sender=badge_account,
    sp=params,
    receiver=my_account,
    amt=1,
    index=badge_id)

# get group ID and assign it to transactions
gid = transaction.calculate_group_id([txn_1, txn_2])
txn_1.group = gid
txn_2.group = gid


# sign transactions 1
sk = mnemonic.to_private_key(passphrase)
stxn_1 = txn_1.sign(sk)

# ToDo: logic sign txn
bytecode = open('atb.lsig', 'rb').read()
lsig = transaction.LogicSig(bytecode)
lstxn_2 = LogicSigTransaction(txn_2, lsig)

# assemble transaction group
signed_group = [stxn_1, lstxn_2]

# send transaction group
tx_id = algod_client.send_transactions(signed_group)

# wait for confirmation
wait_for_confirmation(algod_client, tx_id)

When I run my script I get the following error thrown by algod_client.send_transactions():

algosdk.error.AlgodHTTPError: TransactionPool.Remember: transaction JBSJA7HRRWS4UIND6RCSN6ITMXICLW646K2CUX6DZYGADMZM5BVA: should have been authorized by SJQOZU6RYTAEUN4SGZWWR4DTAPO4ELGC6CM4AX2S4TA5KFBJXLPQGAMWT4 but was actually authorized by UA7ZE3IZHU7EL6KIOPEXCCF5YOME63X6JCWIG22N7SCE2J3PMLEYXUXCPY

SJQOZ… is my testnet account, but I have no idea where UA7ZE… is coming from.

My guess is that this might be related to the lsig but not sure… Any ideas?

Are you sure the passphrase is for the correct account, namely SJQOZU6RYTAEUN4SGZWWR4DTAPO4ELGC6CM4AX2S4TA5KFBJXLPQGAMWT4?

You can run

my_address = mnemonic.to_public_key(passphrase)
print("My address: {}".format(my_address))
1 Like