Error when creating account using horizon_testnet "{'transaction': 'tx_bad_auth'}"

See original GitHub issue

I am using horizon testnet to perform transaction i have used following code to generate key value pair:

kp = Keypair.random()
publickey = kp.address().decode()
seed = kp.seed().decode()
return json.dumps({'publickey': publickey, 'seed': seed})

I have funded the account i,e public key generated from above code using friendbot of stellar and now I am trying to create new account from already funded account it gives me below error

{
  "detail": "The transaction failed when submitted to the stellar network. The `extras.result_codes` field on this response contains further details.  Descriptions of each code can be found at: https://www.stellar.org/developers/learn/concepts/list-of-operations.html",
  "extras": {
    "envelope_xdr": "AAAAAPXdExUVI1FPqyMYimxWeqFopHnAWwhDN14ebnviK9ZSAAAAZAAEFaIAAAACAAAAAAAAAAEAAAAPQnV5ZXIgLSBKb24gRG9lAAAAAAEAAAAAAAAAAQAAAABtHx+VBWTM+ifFJRtBh9p2mKukNkZ157vH+NuLb0nD5AAAAAAAAAAABfXhAAAAAAAAAAAB4ivWUgAAAEBOzQQgMolKmYTvaN22I6lwEbOT+HpguaFoHKBH/TpMQ+hFRUqyhsNE4fsBniQ4ClUHP5a2aRh25YFcDaEGu/gD",
    "result_xdr": "AAAAAAAAAGT/////AAAAAQAAAAAAAAAB////+wAAAAA=",
    "result_codes": {
      "transaction": "tx_failed",
      "operations": [
        "op_no_destination"
      ]
    }
  },
  "title": "Transaction Failed",
  "type": "https://stellar.org/horizon-errors/transaction_failed",
  "status": 400
}

I have used below code for creating new account

from stellar_base.keypair import Keypair
from stellar_base.operation import CreateAccount, Payment
from stellar_base.transaction import Transaction
from stellar_base.transaction_envelope import TransactionEnvelope as Te
from stellar_base.memo import TextMemo
from stellar_base.builder import Builder
from stellar_base.horizon import horizon_testnet
#
horizon = horizon_testnet()
# This is the seed (the StrKey representation of the secret seed that
# generates your private key from your original account that is funding the
# new account in the create account operation. You'll need the seed in order
# to sign off on the transaction. This is the source account.
old_account_seed = "SXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
old_account_keypair = Keypair.from_seed(old_account_seed)

# This is the new account ID (the StrKey representation of your newly
# created public key). This is the destination account.

new_account_addr = "GXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
amount = '1' # Your new account minimum balance (in XLM) to transfer over
# create the CreateAccount operation
op = CreateAccount(
destination=new_account_addr,
starting_balance=amount,
)
# create a memo
memo = TextMemo('Hello, StellarCN!')
item = 'Buyer - Jon Doe'


# Get the current sequence of the source account by contacting Horizon. You
# should also check the response for errors!
# Python 3
sequence = horizon.account(old_account_keypair.address().decode()).get('sequence')

# Python 2
# sequence = horizon.account(old_account_keypair.address()).get('sequence')
# Create a transaction with our single create account operation, with the
# default fee of 100 stroops as of this writing (0.00001 XLM)
tx = Transaction(
source=old_account_keypair.address().decode(),
sequence=sequence,
memo=memo,
operations=[
op,
],
)




# Build a transaction envelope, ready to be signed.
envelope = Te(tx=tx, network_id="TESTNET")
# Sign the transaction envelope with the source keypair
envelope.sign(old_account_keypair)
# Submit the transaction to Horizon
te_xdr = envelope.xdr()
response = horizon.submit(te_xdr)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
manrancommented, Mar 18, 2019

the XDR viewer said you were using the payment operation instead of the create account operation.

from stellar_base.builder import Builder
address='GD252EYVCURVCT5LEMMIU3CWPKQWRJDZYBNQQQZXLYPG467CFPLFFJEK'
dest = 'GBWR6H4VAVSMZ6RHYUSRWQMH3J3JRK5EGZDHLZ53Y74NXC3PJHB6IAWU'
b = Builder(address=address)
b.append_create_account_op(dest,'1')
b.gen_xdr()

This looks good to me. the next step is sign & submit to horizon.

seed = 'SEEEEEEEED'
b.sign(seed)
b.submit()
0reactions
BhumikaBcommented, Mar 18, 2019

In this same way I can also perform transaction using method

DESTADD = 'GXXX'
SOURCE_SEED = 'SXXXXX'
builder = Builder(secret=SOURCE_SEED)
builder.append_payment_op(DESTADD, amount, asset)
builder.add_text_memo(item)
builder.sign()
s = builder.submit()
 print(s['_links'])
and it will  be reflected in public
and i can view it on **https://steexp.com/** explorer of stellar
Read more comments on GitHub >

github_iconTop Results From Across the Web

tx_bad_auth error not listed in List of Operations page #179
I am getting tx_bad_auth on a new account creation that is being funded by another wallet on the same network. The correct network...
Read more >
stellar core - `tx_bad_auth` when submit transaction to TestNet
After I create another account using my account, I can submit a payment transaction with my account. It's strange.
Read more >
tx_bad_seq error when funding the account in stellar private ...
I m able to set up stellar-core and horizon in my private network and it is working fine, I m able to get...
Read more >
Stellar API Reference - Stellar Documentation
This API serves the bridge between apps and Stellar Core. Projects like wallets, decentralized exchanges, and asset issuers use Horizon to submit transactions, ......
Read more >
Account - Go SDK | Stellar Developers
In the Stellar network, users interact using accounts which can be controlled by a corresponding keypair that can authorize transactions. One can create...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found