kinecosystem / kin-node

DEPRECATED! Please use Kinetic: https://developer.kin.org/docs/kinetic
https://developer.kin.org/docs/kinetic
MIT License
16 stars 14 forks source link

BadNonce error #5

Closed doc-l closed 3 years ago

doc-l commented 3 years ago

Hello,

I was doing six unbatched payments in parallel (I know they can be batched, but there is more logic happening than just the payment in the parallelisation step so it's not super trivial to update), and on one particular instance I got this error:

{
    "errorType": "BadNonce",
    "errorMessage": "",
    "name": "BadNonce",
    "stack": [
        "BadNonce",
        "    at Object.errorsFromXdr (/var/task/node_modules/@kinecosystem/kin-sdk-v2/dist/errors.js:22:30)",
        "    at /var/task/node_modules/@kinecosystem/kin-sdk-v2/dist/client/internal.js:187:58",
        "    at Object.onReceiveStatus (/var/task/node_modules/grpc/src/client_interceptors.js:1212:9)",
        "    at InterceptingListener._callNext (/var/task/node_modules/grpc/src/client_interceptors.js:568:42)",
        "    at InterceptingListener.onReceiveStatus (/var/task/node_modules/grpc/src/client_interceptors.js:618:8)",
        "    at callback (/var/task/node_modules/grpc/src/client_interceptors.js:847:24)"
    ]
}

When I replayed it, it worked for all of them. So there was nothing particularly wrong with the code.

Any idea what this could be?

This is the relevant code:

        const client = new Client(Environment.Prod);
        const txHash = await client.submitPayment({
            sender: PrivateKey.fromString(process.env.HOT_WALLET_SECRET),
            destination: PublicKey.fromString(request.wallet),
            memo: request.appId,
            type: TransactionType.Earn,
            quarks: kinToQuarks(request.kin.toString()),
        });
doc-l commented 3 years ago

Closing issue - this is because of stellar not being able to handle parallel transactions and using only 1 channel etc.

If you're reading this: use 1 payment batch instead of parallel payments :)