Commit Graph

44 Commits

Author SHA1 Message Date
Dmitry Holodov
f9a63ff7c3 min and max offer amount checks (#445)
Co-authored-by: noot <36753753+noot@users.noreply.github.com>
2023-04-30 17:36:31 -05:00
noot
906a5c69a3 fix: fix swap status channel setting on restart (#444) 2023-04-28 17:29:39 -04:00
noot
5d49051f39 fix: a few more contract checks (#398)
Co-authored-by: Dmitry Holodov <dimalinux@protonmail.com>
2023-04-23 11:33:58 -04:00
noot
f344d09fc6 add AUTHORS file and update copyright in license header (#389) 2023-04-18 12:25:30 -04:00
noot
c0c87e8ecb contract updates and cleanup (#382)
Co-authored-by: Dmitry Holodov <dimalinux@protonmail.com>
2023-04-17 13:49:53 -04:00
Dmitry Holodov
15b8378c76 ERC20 balance support (#380)
* Added --token flag to swapcli's balances request allowing the user to query their token balance
* --eth-asset flag on swapcli make changed to --token
* Added TokenInfo RPC API method to retrieve an ERC20 token's metadata
* Added an end-to-end ERC20 unit test to the daemon package
* Fixed ERC20 token approval amount to SwapCreator contract to use the minimum value required (instead of approving the entire user's balance for transfer by the contract)
* Fixed a race condition between concurrent contract calls to approve/new_swap in ERC20 token swaps
* Removed hard coded assumptions that all tokens have 18 decimals
* Maked the decimal places in our test ERC20 token configurable
* Fixed token exchange rate calculations
* Updated ongoing and past swap queries to correctly support ERC20 tokens
* Initial unit tests in swapcli's main package
2023-04-17 11:59:47 -05:00
Dmitry Holodov
a17f95d414 SwapFactory to SwapCreator rename, upgrade to solc 0.8.19 (#372) 2023-04-09 03:08:17 -05:00
Dmitry Holodov
7fef2d7b76 XMR taker is relayer of last resort for the maker (#366)
Co-authored-by: noot <36753753+noot@users.noreply.github.com>
2023-04-05 20:16:41 -05:00
noot
b26228805c add license header to files; update readme disclaimer (#368) 2023-04-04 13:12:12 -04:00
Dmitry Holodov
528715b602 swapd daemon setup/start decoupled from CLI parsing (#354) 2023-03-25 19:18:51 -05:00
Dmitry Holodov
0e80eee4dc integrated relayer into swapd (#342) 2023-03-17 14:22:16 -05:00
noot
848051b852 remove NotifyXMRLocked message, have xmrtaker check for lock independently (#341) 2023-03-11 16:13:47 -05:00
Dmitry Holodov
51d89a4d18 added more required tags to serialized structs (#330) 2023-02-28 22:41:03 -06:00
Dmitry Holodov
1d7c00a8ed dedicated monero address type (#327)
Adds custom type for monero addresses with better validations.
2023-02-25 11:18:16 -06:00
noot
112ed74cfb fix: update xmrmaker refund path wallet to use address from xmrtaker swap keys (#304)
Co-authored-by: Dmitry Holodov <dimalinux@protonmail.com>
2023-02-20 16:33:49 -05:00
Dmitry Holodov
943e95cc11 JSON updates (#305)
* ensures  all p2p message types have JSON tags
* when available, marshaling uses our project types
* "common" package was decoupled from the "message" package
* protocol version bumped
2023-02-16 01:15:58 -06:00
Dmitry Holodov
64530dc256 fix: update derivation of shared swap view key to be the same for all paths (#302)
Co-authored-by: noot <elizabethjbinks@gmail.com>
2023-02-12 12:27:25 +00:00
Dmitry Holodov
82a3f884d4 reduce monero wallet contention (#285)
Сreates a new monero-wallet-rpc instance for temporary swap wallets, eliminating the need for monero wallet locks.
2023-01-29 14:10:23 -06:00
Dmitry Holodov
b78cf06870 check ethereum chain ID (#278)
validates that the expected chain ID for the given environment matches the chain ID returned by the ethereum endpoint
2023-01-14 14:20:02 -06:00
Dmitry Holodov
2905d1b1f9 Fixed Point Math (#269)
Updates our code to use the fixed point match library apd.Decimal.
2023-01-10 16:03:22 -06:00
noot
3ef8ae9427 refactor net package to separate generic and swap-specific functionality (#268) 2023-01-08 09:59:34 -05:00
noot
21c2f2a585 implement auto-recover for xmrtaker (#238) 2022-11-24 07:09:14 -05:00
noot
cac8928e22 implement auto-recover for xmrmaker (#235) 2022-11-22 07:14:44 -05:00
noot
04cd5b4809 store swap recovery information in database, remove "infofile" (#227) 2022-11-19 10:52:15 -05:00
noot
591046e787 handle decimals of ERC20 tokens properly (#231) 2022-11-18 18:45:10 -05:00
Dmitry Holodov
bfefd3bb45 rework backend wallet interfaces (#224)
Refactored the Monero and Ethereum wallet/node sub-interfaces into a has-a relationship with the backend.
2022-11-14 18:19:20 -06:00
noot
be9888f05b implement event watcher for contract events; remove unneeded network messages (#219) 2022-11-13 14:19:37 +01:00
noot
36518eae87 persist swap info to disk (#213) 2022-11-07 14:42:35 -05:00
Dmitry Holodov
cdcd4db15d monero transaction checks (#207)
* Bob now waits for his XMR transfer to the A+B wallet to have 10 confirmations before notifying Alice that the XMR is locked.
* Alice now rejects the locked Monero if there is more than one block left before she can spend the funds (1 block freedom is in case of network latency on Alice's side). This eliminates Bob's ability to double spend and allows Alice to sweep funds to her primary wallet from the A+B wallet in a reasonable time frame.
* Sweeping received XMR to the primary wallet is now the default behavior.
* A+B swap wallets are created with a restore height set for quick wallet creation in production where the blockchain is big.
* Fixes SleepWithContext moving it into the common package and having it return an error when the sleep is interrupted by the context being canceled.
* Fixed timeout and context handling in integration tests
* Added new GetChainHeight method that queries monerod instead of monero-wallet-rpc
2022-10-31 00:26:25 -05:00
noot
0bdb6f6f2a add relayer support for claim contract function (#204) 2022-10-26 23:39:20 -04:00
Dmitry Holodov
130ed147aa removed --ethereum-chain-id flag (#201)
Removes the --ethereum-chain-id flag and updates the code to dynamically determines the chain ID using the ethereum endpoint.
2022-10-09 20:43:56 -05:00
noot
5ed5b9271b implement ERC20 integration tests (#197) 2022-10-08 11:43:58 -04:00
Dmitry Holodov
ecd91f624c monero-wallet-rpc now embedded (#192)
* Embeds monero-wallet-rpc instead of having the user start it separately.
* Location of all the files standardized and documented in docs/default-file-locations.md.
* Ethereum and Monero wallets will be created if they do not exist.
* New RPC API  personal_balances added including swapcli support.
2022-10-07 22:18:46 -05:00
noot
87357180f5 remove hardhat dependency from ethereum/ dir (#196) 2022-10-03 18:13:38 -04:00
doonte
067b12f584 add direct ERC-20 swap support (#158)
Co-authored-by: noot <elizabethjbinks@gmail.com>
Co-authored-by: noot <36753753+noot@users.noreply.github.com>
2022-09-05 14:12:22 -04:00
Dmitry Holodov
b2c8641087 rename module (#156) 2022-08-19 20:31:50 -04:00
Dmitry Holodov
49a4ff12f3 Full API Monero RPC client (#154)
Switches from our partial Monero RPC client implementation to a full-API client to help with testing, reliability, debugging and future features. Other changes:
* GenerateBlocks written for better results when called by multiple parties simultaneously
* monero.Client interface renamed to monero.WalletClient to be orthogonal with monero.DaemonClient interface
* monero.NewClient(...) renamed to monero.NewWalletClient(...) to be orthogonal with monero.NewDaemonClient(...)
* monero.CreateMoneroWallet(...) simplified to monero.CreateWallet(...) (package prefix already states wallet type)
* monero/clent.go, monero/daemon.go renamed to monero/wallet_client.go, monero/daemon_client.go
* monero/rpc.go removed with code consolidated into monero/wallet_client.go and monero/daemon_client.go
2022-08-18 23:58:14 -05:00
Dmitry Holodov
cbecd6a891 fix various concurrency issues (#147)
* Fixes lock issues on the XMR Maker's offer list (new package protocol/xmrmaker/offers)
* Fixes lock issues on the swapState maps
* Fixes go routine sync issues in TestError_ShouldOnlyTakeOfferOnce that were sometimes breaking TestSuccess_ConcurrentSwaps
* Ensures that the id field of "types.Offer" is initialized when created
2022-08-10 08:12:12 -05:00
Dmitry Holodov
b729588dd5 update to current version of ganache (#138)
Updates the repo to install the latest version of ganache (ganache-cli is obsolete). 

One of the things that changed in the newer version of Ganache, is gas fee estimation uses the timestamp from the last mined block instead of the local computer's current timestamp. This mirrors what Geth does, so the Ganache change is helpful, but it caused a few problems that this PR fixes.

If we want to do dynamic fee estimation for a transaction that can not happen before time T0 or T1, we need to wait until there is one mined block after T0 or T1 to create our transaction. Otherwise the transaction will be reverted during fee estimation, returning an error when creating the transaction, and we'll never send the transaction out to the network.

Ganache, by default, only mines blocks when you create a transaction. In order to have a mined block after T0 or T1 to calculate transaction fees, we stopped using instamine, and now mine a block every second. This PR chose the minimum block interval for speedier tests.

Co-authored-by: noot <36753753+noot@users.noreply.github.com>
2022-08-06 22:30:45 -05:00
Dmitry Holodov
e0e627f847 fix double locks (#139) 2022-07-06 18:10:05 -04:00
Dmitry Holodov
adfb0fa602 Test cleanup (#135)
* version independent monerod path with localhost-only binding

* fixed lint target and install script

* created 3rd ETH key constant to avoid race condition in tests

* updated run-integration-tests.sh with the same changes made to run-unit-tests.sh

* new design for paritioning out 2 unique keys to test packages

* restored accidentally deleted tests/alice.key

* removed websocket connection leaks from tests

* made file paths unique between tests with better file cleanup

* fix for the websocket connection leak commit

* reverted increase of GenerateBlocks (didn't mean to commit that)

* fixed maker/taker key that I had reversed

* fixed incorrect zero-balance check

* fixed comment on ClaimOrRefund

* added back sample script for installing go in /usr/local/go

* etchclient creation cleanup using t.Cleanup()

* minor cleanup to ganache_test_keys code

* initial dynamic monero-wallet-rpc implementation for tests

* converted monero tests to use dynamic monero-wallet-rpc services

* unit tests all using dynamic monero-wallet-rpc services

* fixed 2 tests that failed after moving to dynamic monero-wallet-rpc services

* fixed low balance issues in TestSwapState_NotifyClaimed

Co-authored-by: noot <36753753+noot@users.noreply.github.com>
2022-06-29 13:36:03 -04:00
noot
cca0b6c771 allow for multiple ongoing swaps (#128) 2022-06-13 20:50:10 -04:00
noot
11e3b27c2e ui: metamask integration, swapd: implement external sender for front-end integration (#126) 2022-06-07 18:06:24 -04:00
noot
0eb4f73dcc refactor: create protocol backend, rename protocol packages to xmrmaker/xmrtaker (#123) 2022-06-02 22:08:20 -04:00