Error from executing the Build --tx request: ... 1546 funding\nFailed to sign tx : Missing Private Key'

I have been experimenting with python code automatically running CLI gen and creating .env files automatically from that.
So somehow my code has put the wrong values in the .env files
So now I have an error when I run CLI Build --tx

I recently cleared out the spynode folder and then I did a full sync --nostop for about 90 minutes
rm -r ./tmp/client/standalone/spynode

So I believe my spynode data matches the values I have in my .env files that I source.

I am trying to fix it to keep using my existing Wallet since it is a lot of work to create and fund a new wallet address.

But I am not clear about what exactly the error message is saying.

Q: “Missing Private Key”: What Private Key does it mean? The Private key CLIENT_WALLET_KEY matching the Wallet address?
I did echo $CLIENT_WALLET_KEY in my script and it displayed the value OK
command_subcontract = "source covid19greenlight_cli.env && echo $CLIENT_WALLET_KEY && echo $CLIENT_CONTRACT_ADDRESS && go run ./cmd/smartcontract/main.go build …
It did correctly echo
5KAnqCCm4qQgcY3vGhPLs9MFeF3fTX6hpD7iw3Jdj38JBxJfnSL
1BwbyPah82C8vpPEVP8VL9y8F55AJ5jee9

I think 5KAnqCCm4qQgcY3vGhPLs9MFeF3fTX6hpD7iw3Jdj38JBxJfnSL is the matching private key for Wallet address 1GCLTtsckvGm7p6xwvHDdwsykYsfhEpZTT but I lost my notes for that particular
run of CLI gen so I am not sure.

prior sync log:
2020/06/04 08:16:47.162902 [Main] wallet.go:155 Info - Loaded unspent output 0.00083635 : 296e28c0931c33288a3d5afda347f56d760fd863b954e384a85273e0f3a83d17:2
2020/06/04 08:16:47.163736 [Main] wallet.go:155 Info - Loaded unspent output 0.00004031 : 5dbcea4e1a68c4654407bcf51437fa9877db5cc91693904a07fbad668b4428ca:2
2020/06/04 08:16:47.163832 [Main] wallet.go:161 Info - Loaded wallet with 4 outputs, 2 unspent, and balance of 0.00087666
2020/06/04 08:16:47.163919 [Main] wallet.go:164 Info - Wallet address : 1GCLTtsckvGm7p6xwvHDdwsykYsfhEpZTT <====== From where did sync logic find this Wallet address ???
2020/06/04 08:16:47.163980 [Main] node.go:114 Info - Contract address : 1BwbyPah82C8vpPEVP8VL9y8F55AJ5jee9 <==== Good
2020/06/04 08:16:47.177757 [SpyNode] peers.go:94 Verbose - Loaded 57 peers

How does sync know the Wallet address even though that is never put in any of the .env files??? Except I copied it into FEE_ADDRESS, so is sync looking at FEE_ADDRESS?? I did not think so.

Did it somehow sync to a Wallet address for which the CLIENT_WALLET_KEY does not match?

I am asking for more clues about where to fix the problem.

Otherwise I will have to CLI gen for a new Wallet address and then Fund it with 10 cents.

Thanks.

The address can be derived from the private key. So for the client wallet you just specify the private key and it derives the address to use. It sounds like your UTXOs don’t match your wallet key. They are stored in the base path of the wallet. So if ./tmp/client/standalone/spynode is your spynode data then ./tmp/client/outputs.json is where the outputs are. you need to delete that file and spynode, then resync so it will be correct.