Skip to content

Calling submitTransaction messes up subsequent horizon calls on versions > 14.3.0 #1295

@corymsmith

Description

@corymsmith

Describe the bug
After submitting a transaction the http client uses the wrong url to fetch stats.

Calling feeStats() returns this error and is calling /transactions/fee_stats

{
  response: {
    type: 'https://stellar.org/horizon-errors/bad_request',
    title: 'Bad Request',
    status: 400,
    detail: 'The request you sent was invalid in some way.',
    extras: {
      invalid_field: 'tx_id',
      reason: 'Transaction hash must be a hex-encoded, lowercase SHA-256 hash'
    }
  }
}

What version are you on?
14.3.1 and 14.3.2

To Reproduce
This script reproduces the behaviour:

const Stellar = require('@stellar/stellar-sdk');

async function createTransaction() {
  const amount = 10;
  const to = 'GDHFCOVVCWBLLJ5HFEKAPDXYMP5UIME6YVWZSTOTF3QETSCBCGNWVSGN';
  const keypair = Stellar.Keypair.fromSecret('TEST_SECRET_KEY');
  const client = new Stellar.Horizon.Server('https://horizon-testnet.stellar.org');
  const fee = (await client.feeStats()).max_fee.p70;
  const account = await client.loadAccount(keypair.publicKey());

  let stellarTx = new Stellar.TransactionBuilder(account, {
    fee,
    networkPassphrase: Stellar.Networks.TESTNET
  }).addOperation(Stellar.Operation.payment({
    asset: Stellar.Asset.native(),
    destination: to,
    amount: amount.toString()
  })).setTimeout(30).build();
  stellarTx.sign(keypair);

  // Submit the transaction to the network
  await client.submitTransaction(stellarTx);

  // Fetch fees again
  // This errors, I logged out url.toString() inside sendNormalRequest and its calling `https://horizon-testnet.stellar.org/transactions/fee_stats` instead of `https://horizon-testnet.stellar.org/fee_stats`
  const feeStats = await client.feeStats();
  console.log(feeStats);
}

createTransaction();

Expected behavior
Should call the correct endpoint.

Additional context
I tested on v14.3.0 and it works, breaks on 14.3.2 and 14.3.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions