Unable to submit transactions to API due to genesis hash error

I’m getting a strange (to me) error regarding the genesis hash value when I try to use the Testnet API from the shell.

I am including the code and output, but sadly I am having to edit it because the system says I can’t post so many links (and urls are contained in the code).

I’m trying to do a send transaction. So, first I obtain the parameter data with this command:

curl -s [URI]://node.testnet.algoexplorerapi.io/v2/transactions/params

The output from the server is in the expected JSON format:

{“consensus-version”:"[URI]://github.com/algorandfoundation/specs/tree/d5ac876d7ede07367dbaa26e149aa42589aac1f7",“fee”:0,“genesis-hash”:“SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=”,“genesis-id”:“testnet-v1.0”,“last-round”:21678678,“min-fee”:1000}

My script parses this and gets the genesis hash and places it in my JSON transaction file:

{“txn”:{“amt”:3000000,“fee”:1000,“fv”:21678678,“gen”:“testnet-v1.0”,“gh”:“SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=”,“lv”:21679353,“note”:“Yipee!”,“rcv”:“NFNI7TEHPW22NDCAL2VRMM6XVUOPOTFDIPO6NPNDL5GFBTWR2VRRRF7QEY”,“snd”:“WJSSO4HPYJJR3XEMSA7FZHU7OVZQXO5RMV6OUH2GQIQEUIXQBHMRPIBPJ4”,“type”:“pay”}}

You can see that it is taking the exact base 64 hash value of the genesis hash and placing it into the transaction. The transaction is then converted to the msgpack format and signed with algokey, no problem there.

I then send the signed transaction in the format indicated by Algorand Explorer on its API page for testnet:

curl -X POST ‘https://node.testnet.algoexplorerapi.io/v2/transactions’ -H ‘accept: application/json’ -H ‘Content-Type: application/x-binary’ --data-binary ‘@/path/to/transaction.stxn’

Here’s the error message:

{“message”:“TransactionPool.Remember: tx.GenesisHash \u003cKNDU6MKHJNJXU6KFG5EUKUCJORKHQQ2CPF3TS6BYIZWW44SDIRSQ\u003e does not match expected \u003cJBR3KGFEWPEE5SAQ6IWU6EEBZMHXD4CZU6WCBXWGF57XBZIJHIRA\u003e”}

What is confusing about this in particular is that it seems that the base 64 hash is being converted to base 32 and then this prefix and suffix of \u003 is being added. In any case, the specs we are given on Algorand.org tell us to include the hash as it is published, in base 64, in our transaction file. It seems I am doing that correctly here.

Can someone explain to me what is happening here? Thanks in advance!

EDIT: I am wondering if something is wrong with the genesis-id value I’m getting back from the API. It says it is “testnet-v.10” but the API address has “v2” in it. Perhaps the API is sending back the wrong genesis-id value?

Duplicate of Genesis Hash Error while using Testnet API