Transaction cannot close account to its sender

Thanks @ryanRfox. I am still a bit confused. :woman_facepalming:

What I am building is https://algoriddle.xyz - It’s a puzzle game on Algorand - I am putting 100 algos in an escrow account and anyone who can solve the puzzle and find the secret key can send it to the account to unlock the escrow account and get the 100 algos.

My goal is for when the program executes and passes (because the sender included the correct passcode in the transaction args), the escrow account automatically sends the account balance to the person who passed in the correct passcode.

How should I go about doing that? This is my current teal program:

arg_0
byte b64 super-secret-hashed-passcode
==

At first I thought I should send CloseRemainderTo to the sender’s address like this:

let txn = {
        "from": recoveredAccount.addr,
        "to": "5BQ3QZSMGJ5SG7MND7XPVNTJW6VOETQHXVX7B2QLEXLBDPA6AURGPHYJAE",
        "fee": params.fee,
        "amount": 0,
        "firstRound": params.lastRound,
        "lastRound": endRound,
        "genesisID": params.genesisID,
        "genesisHash": params.genesishashb64,
        "closeRemainderTo": recoveredAccount.addr
    };

But I get this error when I try to do that:

transaction cannot close account to its sender 3QESO5Z7CXEA4YRSFV6OC4EMTAOA2SC7CQNCDLHT4XLR4PAJ4EGVMPTPQE

So then I thought maybe I just leave off CloseRemainderTo and the escrow account will close out (minus the minimum balance) automatically, but when I send the txn but without CloseRemainderTo:

let txn = {
        "from": recoveredAccount.addr,
        "to": "5BQ3QZSMGJ5SG7MND7XPVNTJW6VOETQHXVX7B2QLEXLBDPA6AURGPHYJAE",
        "fee": params.fee,
        "amount": 0,
        "firstRound": params.lastRound,
        "lastRound": endRound,
        "genesisID": params.genesisID,
        "genesisHash": params.genesishashb64
    };

I get:

TransactionPool.Remember: transaction 3NDA7PIPSG5HLUZCN4R26BGHWAWFDVE7TBA3H7YUZCQYUFMOOVGQ: overspend (account 3QESO5Z7CXEA4YRSFV6OC4EMTAOA2SC7CQNCDLHT4XLR4PAJ4EGVMPTPQE, data {_struct:{} Status:Offline MicroAlgos:{Raw:0} RewardsBase:0 RewardedMicroAlgos:{Raw:0} VoteID:[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] SelectionID:[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] VoteFirstValid:0 VoteLastValid:0 VoteKeyDilution:0 AssetParams:map[] Assets:map[]}, tried to spend {1000})

Any thoughts on how I can go about doing this? Would be really fun to run a puzzle competition to find the passcode to unlock an Algorand escrow account. And I think we are close! Just have to figure out how to do the automatic payout to whoever submits the right solution.