Commit Graph

1226 Commits

Author SHA1 Message Date
Franck Royer
1a5b9f9fa9
Update tests after rebase 2020-12-15 10:19:45 +11:00
Franck Royer
c4cdd098fd
Use from instead of try_from for Alice state conversion 2020-12-15 10:19:03 +11:00
Franck Royer
caf903acda
wip: Add test for when bob restarts 2020-12-15 10:18:48 +11:00
Franck Royer
905fc6cf35
Save Bob state during swap 2020-12-15 10:18:46 +11:00
Franck Royer
7e0a1ffe84
Remove generator for bob 2020-12-15 10:14:43 +11:00
Franck Royer
c6af5eb9ac
Introduce test where alice restarts before all communications are done 2020-12-15 10:10:43 +11:00
Franck Royer
3580b7ed2c
Add test where Alice restart after encsign is learned 2020-12-15 10:10:42 +11:00
Franck Royer
a22efaa7bc
Remove unneeded peer id argument 2020-12-15 10:10:42 +11:00
Franck Royer
9323f22009
Reorder calls 2020-12-15 10:10:42 +11:00
Franck Royer
a24d1a49b9
Remove unneeded as_ref_calls 2020-12-15 10:10:42 +11:00
Franck Royer
1c7cc7ee46
Scope futures' instanciation 2020-12-15 10:10:42 +11:00
Franck Royer
6226e5789f
Introduce test where alice restart mid-swap 2020-12-15 10:10:42 +11:00
Franck Royer
71a0832ef4
Add zero const to monero::Amount 2020-12-15 10:10:42 +11:00
Franck Royer
64b021daf4
Save Alice states in db 2020-12-15 10:10:40 +11:00
Franck Royer
238f6a989d
Extract spend key as soon as possible 2020-12-15 09:18:23 +11:00
Franck Royer
c095693a5f
Refund swap if resumed from a step that requires further communication 2020-12-15 09:17:12 +11:00
Franck Royer
11cea9ba69
Remove passing alice peer id
The usage of the peer id is incorrect as we do not even check it when
dialing. For now, we can ignore it.
We can then re-introduce it and use it properly at a later stage.
2020-12-15 09:15:38 +11:00
rishflab
d8d6477ee9 Remove and fix comments 2020-12-14 11:56:14 +11:00
rishflab
082f4eb005 Use unused port in refund test 2020-12-11 17:36:28 +11:00
rishflab
7af4b6980a Test Alice refunds after Bob refund
Reworked Alice XmrLocked state transition handler to handle the
scenario when Alice received the encsig but Bob refunds.
Previously Alice was trying to redeem after receiving the encsig
without checking if t1 had elapsed.
2020-12-11 17:05:34 +11:00
rishflab
773390886b Test that Bob refunds if Alice fails to act 2020-12-11 16:59:29 +11:00
rishflab
78c6a1a78f Add Bob refund execution 2020-12-11 16:59:29 +11:00
rishflab
f806ad7231 Assert balances after punish 2020-12-11 16:59:29 +11:00
bors[bot]
9fecf7008e
Merge #61
61: Prepare CLI for mainnet swap r=da-kami a=da-kami



Co-authored-by: Daniel Karzel <daniel@comit.network>
2020-12-11 03:48:01 +00:00
Daniel Karzel
03b8e5f52e Upgrade CLI for mainnet test 2020-12-11 14:46:29 +11:00
Daniel Karzel
aad7a22f81 Utility function for initializing tracing for tests 2020-12-11 13:35:47 +11:00
Franck Royer
c0478d7191
Move expiries to config
So they can be different for mainnet and regtest
2020-12-10 14:43:17 +11:00
Franck Royer
ef6e8fc723
Clean-up unused code 2020-12-10 14:28:54 +11:00
Franck Royer
e71bf7d8e9
Add comment regarding processing in network behaviour 2020-12-10 14:03:45 +11:00
Franck Royer
2c9fb7b1da
Rename var to match type name 2020-12-10 14:03:45 +11:00
Franck Royer
91d28682ed
Remove comments 2020-12-10 14:00:48 +11:00
Franck Royer
53aae5cf5f
Use anyhow macro as intended 2020-12-10 14:00:48 +11:00
Franck Royer
51cc44484b
Remove unneeded pub qualifiers 2020-12-10 14:00:47 +11:00
rishflab
9ba89194b0 Rename swarm driver to event loop 2020-12-10 13:29:53 +11:00
rishflab
f5d3d54b13 Prevent premature Bob t1 timeout
Bob was hitting the t1 timeout and entering cancel
instead of redeem. This was resolved by increasing
the timeouts to 50.
2020-12-10 13:29:53 +11:00
rishflab
27d1334726 Init Alice behaviour with state0
Previously state0 had to be set after creating Alice's behaviour.
With the event loop we no longer has access to the swarm so
set_state0() has to be called indirectly through a channel. This
means it is difficult to guarantee state0 is being set due to the
asynchronous nature of channels. This was solved by initialising
Alice with state0.
2020-12-10 13:29:53 +11:00
rishflab
3d8866f1a0 Convert event loop to use fused futures select
Co-authored-by: Daniel Karzel <daniel@comit.network>
2020-12-10 13:29:53 +11:00
rishflab
58da1df9dc Create SwarmDriverHandle to resolve ownership issues 2020-12-10 11:24:08 +11:00
rishflab
6f7408ecce Drive swarm in seperate async task
Previously the libp2p swarm had to be manually polled within the
protocol execution code to execute actions such as sending a
message. The swarm is now wrapped in SwarmDriver which polls the
swarm in a seperate task
2020-12-10 11:24:05 +11:00
rishflab
f88ed9183b
Merge pull request #54 from comit-network/bob-unhappy-paths
Punish Test
2020-12-09 15:51:16 +11:00
rishflab
bd8e6e36e0 Fix monero blocktime config 2020-12-09 15:10:29 +11:00
Daniel Karzel
1a2857af29 Properly init tracing per test and reverse the filter to be exclusive
Tracing should be initialized by test and the `_guard` kept alive within the test.
Re-using this code in different tests does not really have any additional value.

Instead of specifying what messages we want to include, I went for a filter that excludes noise.
That way we get more useful logging.
2020-12-09 11:48:53 +11:00
rishflab
883a913f30 Remove nonsensical monero * monero multiplication 2020-12-08 16:12:00 +11:00
rishflab
627b1a9f00 Remove unnecessary execution restart 2020-12-07 14:03:50 +11:00
rishflab
8592ef5f79 Address PR feedback
Add context to logging statements. Use amount type for monero in tests. Remove stale
code and comments.
2020-12-07 13:55:13 +11:00
Franck Royer
78674818c2
Upgrade bitcoin-harness 2020-12-07 12:31:25 +11:00
rishflab
b4ac69fa9c Reduce stack size to prevent CI resource issues 2020-12-07 09:44:26 +11:00
rishflab
e4eed7b1a5 Change multiaddr for test runs 2020-12-05 14:06:08 +11:00
rishflab
c91e9652aa Add alice punish test
Use reusable test init functions for happy path test

Extract tracing setup to reusable function

Move test initialization to seperate functions

Increase stack size in CI

Fix monero max finality time

Force Bob swarm polling to send message 2

Run Bob state to xmr_locked in punish test to force the sending of
message2. Previously Bob state was run until btc_locked. Although
this was the right thing to do, message2 was not being sent as the
swarm was not polled in btc_locked. Alice punish test passes.

Add info logging to executor
2020-12-04 17:23:37 +11:00
rishflab
5fef68322a Allow Alice to exit execution at a specified state 2020-12-04 17:16:03 +11:00
rishflab
584cc22024 Allow Bob to exit execution at a specified state 2020-12-04 17:16:03 +11:00
Franck Royer
cfcd1e7170
Clean-up dep versions
- Use bitcoin-harness 0.2
- Use cross-curve-dleq latest master commit
2020-12-04 16:56:08 +11:00
Franck Royer
624716d8a7
Upgrade rust-bitcoin to 0.25 2020-12-04 08:11:55 +11:00
Franck Royer
c3e43f50aa
Update bitcoin-harness to specific revision 2020-12-02 11:32:34 +11:00
Franck Royer
765482b0aa
Implement wait_for_transaction_finality 2020-12-02 10:02:20 +11:00
rishflab
1c401aad31 Fix clippy warnings and formatting 2020-12-01 15:38:24 +11:00
rishflab
b06321a40f WIP: cleanup 2020-12-01 14:46:53 +11:00
rishflab
47c3ddc6f7 Fix happy path test
Poll bob swarm to send encsig after calling send message3. Comment
out unimplmented wait for transaction finality trait. Dial alice.
2020-12-01 14:30:02 +11:00
Franck Royer
2abeba17f9
Save state0 in the swarm to process message0 2020-12-01 10:41:10 +11:00
rishflab
d8218a7bea Remove mspc channel from new executor 2020-11-30 15:16:56 +11:00
Franck Royer
2db9ebd28b make new_swarm public 2020-11-30 15:13:20 +11:00
Franck Royer
9e13034e54 Extract execution details from driving loop 2020-11-30 15:13:20 +11:00
rishflab
24631d464d Add test for recursive executor 2020-11-30 15:13:20 +11:00
rishflab
dca15b6872 Removed unused binary 2020-11-30 15:13:20 +11:00
rishflab
3b005bd15c Resolve rebase issues, restructure code and fix warnings 2020-11-30 15:13:20 +11:00
Franck Royer
437c1cbb80 Started to extract some steps
Tealised that the whole point is for them to be idempotent to be useful
2020-11-27 09:34:36 +11:00
Franck Royer
66866f8fbd Remove rng argument 2020-11-27 09:34:36 +11:00
Franck Royer
6c0df836ca Deal with Btc Punished. 2020-11-27 09:34:36 +11:00
Franck Royer
6437b529eb Punish Bob if t2 is reached 2020-11-27 09:34:36 +11:00
Franck Royer
8ff1824126 Remove abort function 2020-11-27 09:34:36 +11:00
Franck Royer
58ca33dd04 Remove warnings 2020-11-27 09:34:36 +11:00
Franck Royer
c501d84278 Park abort function for now 2020-11-27 09:34:36 +11:00
Franck Royer
4c4a10098c Complete Refund path 2020-11-27 09:34:36 +11:00
Franck Royer
bff83bbe99 Progress on Cancellation path 2020-11-27 09:34:36 +11:00
Franck Royer
8e31a3af6a Add steps from EncSignLearned 2020-11-27 09:34:36 +11:00
Franck Royer
8976a03b3d Implemented Alice transition from BtcLocked to XmrLocked 2020-11-27 09:34:35 +11:00
Franck Royer
75e7fedfed Implemented Alice transition from Negotiated to BtcLocked 2020-11-27 09:34:35 +11:00
Franck Royer
c4cd64d134 Implemented Alice transition from Started to Negotiated 2020-11-27 09:34:35 +11:00
Franck Royer
0fe5131a8a Fix import format 2020-11-27 09:34:35 +11:00
rishflab
ae94b170fd Cleanup
Move state machine executors into seperate files

Remove check for ack message from Alice. Seems like a bad idea to
rely on an acknowledgement message instead of looking at the
blockchain.

Fix warnings
2020-11-27 09:34:35 +11:00
rishflab
ff7daf16f3 WIP: Test simplified swap execution 2020-11-27 09:21:21 +11:00
rishflab
dd07e2f882 Add Alice execution path
Consolidate and simplify swap execution. Generators are no longer
needed. Consolidate recovery and swap data structures. The
recursive calls can be replaced with a loop if returning prior to
completion is desired for testing purposes.

Fill out alice abort path

Move state machine executors into seperate files

Not compiling due to recursion/async issues

Fix async recursion compilation errors

Fix Bob swap execution

Remove check for ack message from Alice. Seems like a bad idea to
rely on an acknowledgement message instead of looking at the
blockchain.

Fix Bob abort

Fix warnings

Xmr lock complete

Add TxCancel submit to XmrLocked

Bob swap completed

Remove alice
2020-11-27 09:21:21 +11:00
Lucas Soriano del Pino
483c819e17 Correctly re-export types from bitcoin and monero modules 2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
f5ff50157e Some more fixes and comments after testing Alice's recovery 2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
bea99185ed Use correct default values for monerod_url*
*`monerod_url` is an incorrect name as it's actually a
`monero_wallet_rpc_url`. This is fixed in another branch.
2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
5930af3587 Move some things around in recover module 2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
33b36c98fa Configure binary tracing level for xmr_btc and monero_harness 2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
5dede0f361 Add more logging to recovery
Also, remove redundant timelock check.
2020-11-12 13:49:07 +11:00
rishflab
11a7963081 Fix bugs 2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
f0d90130ad Add recovery command 2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
09773dd15b Re-introduce history command 2020-11-12 13:49:07 +11:00
rishflab
0f1a77fa21 Fix Alice's btc redeem recovery path 2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
6db40dce2a Implement swap recover function for Bob 2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
28225f8643 Implement swap recover function for Alice
This introduces a lot of duplication between the binary and the
library, but it's okay because this module should only be a temporary
measure until we allow recovery to be handled by the original state
machine.

Also, fix a bug in `xmr_btc::alice::action_generator` caused by the
incorrect assumption that Alice's ability to punish Bob could be
determined before the cancel transaction hits the blockchain.
2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
b989e94322 Remove stale TODO 2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
33a111d879 Move Swap state out of storage 2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
ac2cfd7f65 Print swap history on --history flag 2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
ecbfed9c11 Add Database API to fetch all swaps 2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
f9cfc2abe3 Remove generics from Database 2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
02075c2a1d Support saving multiple swaps
By replacing `LAST_STATE_KEY` with a swap ID passed as an argument to
inserting and reading from the database.
2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
823add218e Remove temporary test tracing guards 2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
a26890001b Fix swap e2e test 2020-11-12 13:49:07 +11:00
Lucas Soriano del Pino
934ddb366a Save state for Alice at specific points in the swap 2020-11-12 13:49:07 +11:00
rishflab
ea08778b2f Save state for Bob at specific points in the swap 2020-11-12 13:49:07 +11:00
Philipp Hoenisch
981fcacc95
Make swap e2e test work with new monerod lib 2020-11-03 16:52:00 +11:00
Philipp Hoenisch
70d64f74ae
Testcontainers upgrade 2020-11-03 16:52:00 +11:00
Philipp Hoenisch
0b9e8c145e
Update xmr-btc lib to use new monero-harness 2020-11-03 16:51:26 +11:00
rishflab
a44303f839 Add monerod to config
Fixed rebase issues
2020-11-03 16:08:46 +11:00
rishflab
7afd316210 Construct tor transport for Bob 2020-11-03 15:13:25 +11:00
rishflab
3b008c38a6 Remove redundant code and stale comments 2020-11-03 15:13:25 +11:00
rishflab
249f273d1b Remove stale comments 2020-11-03 15:13:25 +11:00
rishflab
5971ef1f28 Fix clippy warnings 2020-11-03 15:13:23 +11:00
rishflab
606c48c752 Format swap crate Cargo.toml 2020-11-03 15:13:03 +11:00
rishflab
796d0b3439 Extract transport creation and remove tor conditional compile
The numerous tor conditional compile flags were removed by
extracting transport creation to the main statement. A tor
transport is created if Alice specifies a tor port using the CLI.
2020-11-03 15:12:52 +11:00
rishflab
0ca511bf8a Remove hardcoded configuration
The hardcoded configuration was replaced with CLI
configuration options. CLI based config was chosen
over a config file as it does not access and clutter
the user's file system. By CLI options depend on whether
the program is run in Alice or Bob mode.
2020-11-03 15:08:10 +11:00
Lucas Soriano del Pino
92c7e8e84f Run swap e2e test without tor feature
Not worth automatically testing both `tor` and `not(tor)`, it should
not make a difference.
2020-11-02 10:31:53 +11:00
Lucas Soriano del Pino
792fa351c8 Upgrade bitcoin-harness dependency
From dev-branch to master.
2020-10-30 15:55:10 +11:00
Lucas Soriano del Pino
7fa7641feb Clean up some logs and comments 2020-10-30 15:51:46 +11:00
Tobin C. Harding
4d4acde476 Bubble up an event when Bob receives message 3 response
Before this patch Bob is not sending message 3. This is because we are not
polling Bob's swarm correctly. To fix it we can just mimic the other NB's and
bubble up an event when Bob receives message 3 response from Alice, this way we
can `await` upon this event which triggers polling, making Bob's swarm send the
message.
2020-10-30 14:07:15 +11:00
Lucas Soriano del Pino
a37f43a1ba wip: Provide enough funds to both parties
Also use cosntant backoff retry strategy as opposed to exponential
backoff. This is in case retrying several times quickly causes the
retry intervals to become large enough that the test is very slow
and/or the Bitcoin lock transaction expires.

The current problem occurs on the last message i.e. Bob sending
tx_redeem_encsig to Alice. The action is yielded for Bob to do it, but
Alice appears to never receive it (unconfirmed claim, requires more
logging).
2020-10-30 14:07:15 +11:00
Lucas Soriano del Pino
eb6bbe6180 wip: Fix bug where bob was sending two amount request 2020-10-30 14:05:45 +11:00
Lucas Soriano del Pino
9f32cd988e wip: Use same timelock value for refund and punish 2020-10-30 14:05:45 +11:00
Lucas Soriano del Pino
62c4501926 wip: Add xmr_btc tracing filter 2020-10-30 14:05:45 +11:00
Lucas Soriano del Pino
ae87c10cae wip: fixed message0 2020-10-30 14:05:45 +11:00
Tobin C. Harding
119f2a7c54 Add error logging to request_response 2020-10-30 14:05:45 +11:00
Tobin C. Harding
b8ab4b4eee wip: add env filter 2020-10-30 14:05:45 +11:00
Tobin C. Harding
3e2f0b74a2 Do not trace events meant for other NBs 2020-10-30 14:05:45 +11:00
Tobin C. Harding
c464555f5e Enable trace output 2020-10-30 14:04:27 +11:00
Tobin C. Harding
39f86154ce Use serde_cbor instead of serde_json
We have serde trait implementations that use `serde_cbor` which is a superset of
josn. We cannot use `serder_json` to ser/deser these objects.
2020-10-30 14:04:27 +11:00
Tobin C. Harding
2bd4977fe4 Increase read buffer size
Our messages are quite big, increase the read buffer to 1 megabyte to
accommodate them.
2020-10-30 14:04:27 +11:00
Lucas Soriano del Pino
9384b0cf3c [WIP] Swap app e2e test 2020-10-30 14:04:27 +11:00
Lucas Soriano del Pino
9e30bd5151 Generate addresses as late as possible 2020-10-30 14:04:27 +11:00
Lucas Soriano del Pino
3f43581da7 Implement traits Receive{BitcoinRedeemEncsig, TransferProof}
Unfortunately, I had to put the wrap the swarm in Alice's `Network`
struct in an `Arc<Mutex<T>>` in order to be able to use `backoff` to
control the retry mechanism. This is because the stream of events
cannot be turned into a `SharedFuture` (unlike Bob's).

It would be good to find an alternative solution.
2020-10-30 14:03:27 +11:00
Lucas Soriano del Pino
a4e4c27bee Execute Bob's on-chain protocol after handshake
Co-authored-by: Tobin C. Harding <tobin@coblox.tech>
2020-10-30 14:03:27 +11:00
Lucas Soriano del Pino
4ee82a5a2a Execute Alice's on-chain protocol after handshake
Co-authored-by: Tobin C. Harding <tobin@coblox.tech>
2020-10-30 14:00:39 +11:00
Philipp Hoenisch
b8fd9a734f
Use full path imports for dependencies to reduce cfg hell 2020-10-28 11:18:14 +11:00
Tobin C. Harding
a1351e5461 Do not declare 'port' variable 2020-10-28 10:11:04 +11:00
Tobin C. Harding
464b699426 Fail if user passes in local port for non-tor usage
Local port is only used when running behind tor. Fail if user passes a local
port number when running in non-tor mode.
2020-10-28 09:46:25 +11:00
Tobin C. Harding
42d194f758 Use fully qualified path for bail 2020-10-28 09:21:37 +11:00
Tobin C. Harding
5e35904101 Use an option for the local port
We can wrap the local port in an option and pass None when we are not using Tor.
This reduces code duplication.
2020-10-28 08:41:23 +11:00
Philipp Hoenisch
8811a0a205
Add Tor to main 2020-10-27 15:03:59 +11:00
Lucas Soriano
cf8accf30d
Merge pull request #28 from comit-network/re-work-swap-functions
Re work swap functions
2020-10-27 13:27:52 +11:00
Tobin C. Harding
b22f265cf3 Send back an empty response to Message2
Alice does not respond with anything when receiving message 2 from Bob. We don't
want to leave Bob's request/response protocol waiting so send an empty response
back.
2020-10-27 10:26:54 +11:00
Tobin C. Harding
194a19cf1d Add todos 2020-10-27 10:26:51 +11:00
Tobin C. Harding
6be5d64c1c Remove stale, ugly, type conversion 2020-10-27 10:26:46 +11:00
Lucas Soriano
58aa2b5a2b
Merge pull request #23 from comit-network/remove-re-export
Do not re-export curve25519_dalek
2020-10-27 10:21:58 +11:00
Tobin C. Harding
8f5a989ad1 Use 'amounts' for local varibale name 2020-10-27 10:05:20 +11:00
Tobin C. Harding
b8130d23a6 Only break if Bob has requested amounts already
We don't want Bob to be able to crash us by sending an out of
order message. Only break if Bob has not requested amounts.
2020-10-27 10:02:03 +11:00
Tobin C. Harding
5da84a3d48
Merge pull request #25 from comit-network/unused-assigments
Remove allow(unused_assignments) attribute
2020-10-27 09:55:32 +11:00
Lucas Soriano del Pino
ba4ae09cd1 Remove allow(unused_assignments) attribute
It looks like the compiler can ascertain that `message0` will be
initialised by the time we use it, so it doesn't need to be an
`Option` and it doesn't need to be declared as mutable.
2020-10-26 15:21:32 +11:00
Tobin C. Harding
cbccc282ef Send Message2 from Bob to Alice
In order for Alice to complete the handshake she needs to transition to state 3,
for this she needs message 2 from Bob.

Send `bob::Message2` to Alice and transition to `State3` - completing the
handshake.
2020-10-26 14:30:41 +11:00
Lucas Soriano del Pino
0dd01c3a3b Do not re-export curve25519_dalek
Anything that needs to be re-exported by this crate from
`curve25519_dalek` can be re-exported from the `monero` module. In
fact, the `Scalar` type was already being re-exported.
2020-10-26 13:06:20 +11:00
rishflab
ec71f98252 Revert re-imports to qualified paths 2020-10-26 11:45:27 +11:00
rishflab
fea6b29da9 Test monero amount serialisation 2020-10-26 11:39:54 +11:00
Franck Royer
9ea708b2a5 Remove custom implementation of bitcoin amount serde
This is unnecessary as rust-bitcoin provides it.
2020-10-26 11:36:40 +11:00
rishflab
c781ee949d Move storage into application crate 2020-10-26 10:32:54 +11:00
Philipp Hoenisch
17b32fed90
Moving tor into swap 2020-10-23 12:47:52 +11:00
Tobin C. Harding
97363cb05c Fix build after merge 2020-10-22 14:43:58 +11:00
Tobin C. Harding
19f065575d Do a bunch of cleanups 2020-10-22 14:30:10 +11:00
Tobin C. Harding
6e34f9c978 Use const TIMEOUT instead of an argument 2020-10-22 14:12:49 +11:00
Tobin C. Harding
cc61079826 Use VerifiedAmounts 2020-10-22 13:55:50 +11:00
Tobin C. Harding
eed5e8e9a4 Move monero serde code to lib 2020-10-22 13:54:13 +11:00
Tobin C. Harding
30298bdf1f Do some more cleanups 2020-10-22 13:48:30 +11:00
Tobin C. Harding
2059158dad Bump to libp2p v29 2020-10-22 13:39:18 +11:00
Tobin C. Harding
ad006fae6a Do a bunch of cleanups 2020-10-22 13:35:55 +11:00
Tobin C. Harding
0f17ec076c Add message1 2020-10-22 13:23:12 +11:00
Tobin C. Harding
ad0d8d5713 Emit message0 out of NB (both parties) 2020-10-22 11:04:49 +11:00
Tobin C. Harding
bb94643943 Remove data from message until Message0 impl serde 2020-10-22 09:58:22 +11:00
Tobin C. Harding
e7504de76c Add state0 -> state1 messages 2020-10-21 15:02:52 +11:00
Tobin C. Harding
08ec776daa Move monero/bitcoin modules to files 2020-10-21 13:13:01 +11:00
Tobin C. Harding
aaf1363c05 Refine peer tracker and amounts protocol
We model the getting of amounts as a network behaviour even though conceptually
it is a protocol. Refine/refactor the code a bit to make this more obvious.

- Use `Amounts` instead of `Messenger`

We only ever connect to a single peer, update peer tracker to reflect this. This
is a single patch because the handling of the two network behaviours is a
intertwined.

- Only track one peer connection
- Track the peer id and the multiaddr of the counterparty
- Emit an event for connection established on Alice's side as well as Bob's side
2020-10-21 10:11:24 +11:00
Tobin C. Harding
47eaa44f76 Remove unneeded From<Never> impl 2020-10-21 10:11:24 +11:00
Tobin C. Harding
40e97ffdc3 Add todo to check amounts calculation 2020-10-21 10:11:24 +11:00
Tobin C. Harding
1251681cfd Calculate amounts from BTC 2020-10-16 12:42:47 +11:00
Tobin C. Harding
3492c46e71 Verify amounts with user 2020-10-16 10:49:19 +11:00
Tobin C. Harding
05766d3146 Add swap/
Add a binary crate `swap` that implements two nodes (Alice and Bob). With this
applied we can start up a node for each role and do:

- Bob: Requests current amounts using BTC is input
- Alice: Responds with amounts
- Bob: (mock) get user input to Ok the amounts

... continue with swap (TODO)
2020-10-16 10:05:06 +11:00