I'm pretty new to Rust and this was mainly a POC for a GUI. Would a change like this be interesting? This may also serve as a first step towards a full JSON RPC for teleport (https://github.com/bitcoin-teleport/teleport-transactions/issues/46). I'd be willing to look further into that in the future.
Changes
refactored all main functions in lib.rs to return a JSON serializable result
moved print lines to cli.rs, use the results from lib
improve error messages, handle more errors
ignored wallet & watchtower files
commited Cargo.lock
Todo
[ ] refactor the rest of the functions
[ ] handle all possible errors in lib.rs (and down the call stack, replace .unwrap()s)
Tests
All tests are passing, except for test_standard_coinswap. It runs until the end but is marked as failed. Not sure what's wrong there.
[2022-07-05T13:57:46Z INFO teleport::taker_protocol] ===> Sending HashPreimage to localhost:16102
[2022-07-05T13:57:46Z INFO teleport::taker_protocol] <=== Received PrivateKeyHandover from localhost:16102
[2022-07-05T13:57:46Z INFO teleport::taker_protocol] ===> Sending PrivateKeyHandover to localhost:16102
[2022-07-05T13:57:46Z INFO teleport::taker_protocol] Successfully Completed Coinswap
[2022-07-05T13:57:52Z INFO teleport::watchtower_protocol] watchtower ended with err Protocol("kill flag is true")
test test_standard_coinswap ... FAILED
Hi, I'm working on a desktop (taker) GUI at https://github.com/pwltr/coinportal. It's built with Tauri which uses a foreign function interface-like abstraction to allow the Frontend to invoke Rust functions directly. For that to work I need Rust to return JSON serializable responses from the functions I want to call.
I'm pretty new to Rust and this was mainly a POC for a GUI. Would a change like this be interesting? This may also serve as a first step towards a full JSON RPC for teleport (https://github.com/bitcoin-teleport/teleport-transactions/issues/46). I'd be willing to look further into that in the future.
Changes
lib.rs
to return a JSON serializable resultcli.rs
, use the results from libTodo
.unwrap()
s)Tests
All tests are passing, except for
test_standard_coinswap
. It runs until the end but is marked as failed. Not sure what's wrong there.