Flutter compatible version of godot fast withdrawal client, for testing purposes as a flutter replacement is developed
The fast withdrawal client runs in the background and watches the invoices directory (~/.local/share/FastWithdrawClient/invoices) for fast withdrawal requests created by the launcher.
When the fast withdrawal client finds a new fast withdrawal request it will contact the fast withdrawal server and fill in the invoice file with the payment amount and L2 destination that needs to be paid in order for the mainchain payment to be made by our server.
After the user has paid the amount requested to the L2 address given by the server, they will need to report the txid to the launcher, which will need to add that to the invoice.
When the fast withdrawal client sees the payment txid has been added to the invoice file, it will send this to the fast withdrawal server. The fast withdrawal server will verify this payment and then will pay out mainchain coins to the user.
So the entire process looks like this:
ex:
Future<File> get _localFile async {
final path = await _localPath;
return File('/home/user/.local/share/FastWithdrawalClient/invoices/invoice_1');
}
Future<File> writeInvoice(string amount, string destination) async {
final file = await _localFile;
// Write the invoice file
return file.writeAsString('$amount:$destination');
}
At this point the invoice file for example to request 21 btc sent to 1Lbcfr7sAHTD9CgdQo3HTMTkV8LK4ZnX71 should look like:
21:1Lbcfr7sAHTD9CgdQo3HTMTkV8LK4ZnX71
Once a response is given by the server the L2 destination and amount required to complete the withdrawal will be appended to the next line of the invoice file.
At this point the invoice file should look like:
21:1Lbcfr7sAHTD9CgdQo3HTMTkV8LK4ZnX71
21.01:L2_ADDRESS_FROM_SERVER
5. To complete the withdrawal, the user pastes the txid of the payment into the launcher and clicks a complete button.
The launcher appends this txid to the next line of the invoice file.
At this point the invoice file should look like:
21:1Lbcfr7sAHTD9CgdQo3HTMTkV8LK4ZnX71
21.01:L2_ADDRESS_FROM_SERVER
f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16
Finally, the client will contact the fast withdrawal server which will verify the payment and then send the user the bitcoin on L1
-
Re write the fast withdrawal server to use websockets, grpc or whatever will be the best for flutter/dart to interact with it.
-
Move the fast withdrawal client code into the launcher, re written in dart.
-
Instead of storing invoices in text files, write them to a sqlite or other database. They need to persist somewhere because transactions can take a while and the user might shut down the software before completing the fast withdrawal.