algorand / js-algorand-sdk

The official JavaScript SDK for Algorand.
https://algorand.github.io/js-algorand-sdk/
MIT License
284 stars 204 forks source link

Atomic Transfer with LSIG signed transaction fails #385

Open gl-pgege opened 3 years ago

gl-pgege commented 3 years ago

Hi,

I am trying to execute an atomic transfer that involves closing out an escrow account but I keep getting the following error:

"TransactionPool.Remember: transactionGroup: incomplete group: XGHNMDXO6YA6PPCZYTVUBRW7PL4SV2WT2DJTDAN44VYCOIIN5XXQ != ZWRKHURTT4MLBQ5RQBYJIU6Y5MGNYADCBQMCXNAEKJBK56O74LBA ({{} [X54OMVL63PM3OHNCU2DKNWFUK5GKBFMY5CL4PP4PMBWJGAXXRN6Q RIMM47EE2JYZJ4EU72NCX4PCICXUV55TIPBUYYMFK4MMBG5CFBFA]})"

Here is my code, I have performed the same task with other types of transactions. However, I only run into this problem when closing out an escrow account.

    const params = await client.getTransactionParams().do();
    params.fee = 1000;
    params.flatFee = true;

    const escrowProgram = await compileProgram(client, escrowProgramSource);

    const lsig = algodsdk.makeLogicSig(escrowProgram);
    const escrowAddress = lsig.address();

    const appArgs = [
        new Uint8Array(Buffer.from('deposit')),
    ];

    const appWithdrawCheckTxn = algodsdk.makeApplicationNoOpTxn(
        developer, params, APP_ID, appArgs);

    const paymentTxnObject = {
        from: escrowAddress,
        to: GLOBAL_ZERO_ADDRESS,
        amount: CONTRACT_AMOUNT,
        closeRemainderTo: developer,
        suggestedParams: params,
        note: undefined
    }

    const withdrawFromEscrowTxn = algodsdk.makePaymentTxnWithSuggestedParamsFromObject(paymentTxnObject);

    const txns = [appWithdrawCheckTxn, withdrawFromEscrowTxn];
    const transactionGroup = algodsdk.assignGroupID(txns);

    const signedAppWithdrawCheckTxn = transactionGroup[0].signTxn(developerAccount.sk);
    const signedWithdrawFromEscrowTxn = algodsdk.signLogicSigTransactionObject(transactionGroup[1], lsig);

    const signedTxGroup = [];
    signedTxGroup.push(signedAppWithdrawCheckTxn);
    signedTxGroup.push(signedWithdrawFromEscrowTxn.blob);

    const tx = await client.sendRawTransaction(signedTxGroup).do();
Eric-Warehime commented 1 year ago

The change needed here is probably similar to https://github.com/algorand/py-algorand-sdk/issues/218 -- improving the error messaging. Although I'm not sure whether or not the error handling needs to be improved client side or server side since the TransactionPool.Remember... output would be coming from algod.