The goal is if the teal program executes as true, then it will closeRemainderTo the address that invokes the program. However, when I run it, I get the error: transaction cannot close account to its sender
.
Here is the teal program - this returns PASS
.
// Push arg_0 to stack
arg_0
// Pop arg_0 from stack and push sha256 hashed result to stack
sha256
// Push pre-computed b64 encoded sha256 of my-Super-Secret-32-bytes-of-Data
byte b64 Q0oWzpC/ICJPtdpY1hPLIZm0E2Ew3ozIGGNbWLg38aQ=
// Pop the top two items from the stack, compare, then push result to stack
==
Then I send it with closeRemainderTo set to the address of the sender:
let txn = {
"from": recoveredAccount.addr,
"to": "R3NORFFJ3RXGEER2EUXJH5F35EGOBZYOGP6FNX3KCQ3HJ23VTETQJCM6SA",
"fee": params.fee,
"amount": 0,
"firstRound": params.lastRound,
"lastRound": endRound,
"genesisID": params.genesisID,
"genesisHash": params.genesishashb64,
"closeRemainderTo": recoveredAccount.addr
};
// create logic signed transaction.
// Had this been an escrow the lsig would not contain the
// signature but would be submitted the same way
let rawSignedTxn = algosdk.signTransaction(txn, recoveredAccount.sk);
//Submit the lsig signed transaction
let tx = (await algodclient.sendRawTransaction(rawSignedTxn.blob));
Then the error I get back is:
text: 'transaction cannot close account to its sender 3QESO5Z7CXEA4YRSFV6OC4EMTAOA2SC7CQNCDLHT4XLR4PAJ4EGVMPTPQE',
Is there something I need to add to the program to closeRemainderTo?
Thanks!