stellar-deprecated / starlight

Layer 2 payment channel protocol for the Stellar network.
Apache License 2.0
41 stars 9 forks source link

sdk/agent: should not error if the reason close fails is because other client successfully submitted the close #461

Open leighmcculloch opened 2 years ago

leighmcculloch commented 2 years ago

In an early close scenario both participants submit the final close transaction. This is done so that neither party is relying on the other party doing the right thing.

The relevant code is here:

The client that lead the charge on the early close agreement gets the response from the other client and submits it: https://github.com/stellar/starlight/blob/919096552e44eec5ec3fd6278922396926239874/sdk/agent/agent.go#L713-L728

The client that is asked to close early submits the transaction immediately after they sign the request: https://github.com/stellar/starlight/blob/919096552e44eec5ec3fd6278922396926239874/sdk/agent/agent.go#L676-L691

This results in an error being passed back up to the application using the agent, which is not ideal.

The agent should inspect the error, and if the error indicates that the fee was insufficient it should take some smarter actions such as:

Related Discord discussion: https://discord.com/channels/897514728459468821/910623239292739585/1017480647373230110