85 Commits

Author SHA1 Message Date
Dmitry Holodov
f7c6a1dd0f maintenance updates (#503) 2023-08-16 19:28:51 -05:00
Dmitry Holodov
7619b9a6af updates for cross-chain bootnodes (#486) 2023-06-19 14:47:27 -05:00
noot
f344d09fc6 add AUTHORS file and update copyright in license header (#389) 2023-04-18 12:25:30 -04: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
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
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
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
Dmitry Holodov
6e146f0dc5 support fallback monero nodes in default configs (#265)
Allows configuring multiple monerod nodes in our default configs. They get tried sequentially and the first one that works gets used.
2022-12-20 15:10:40 -06:00
Dmitry Holodov
ed15ed9c82 libp2p QUIC and NAT traversal features (#251)
Enables additional libp2p NAT traversal features and enables nodes to communicate using UDP/QUIC in addition to TCP. Switches to using libp2p's "routed host". Most commands that previously accepted multiaddress values now accept a Peer IDs instead.
2022-12-19 18:25:24 -06:00
noot
3ee4f619db skip failing test (#263) 2022-12-19 14:41:34 -05:00
Dmitry Holodov
1e83673f23 add package comments (#236)
package comments added to all packages
2022-12-02 00:43:32 -06: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
7e44d6e7b9 add FakeDLEq; add pure go + darwin build commands (#225) 2022-11-14 16:14:10 -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
noot
a51ea4e731 implement database; persist offers to disk and reload on startup (#200) 2022-10-11 15:44:37 -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
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
Dmitry Holodov
5698e25239 RPC and WS endpoints share the same port (#187)
Combine our HTTP RPC and Websocket services into a single HTTP server, eliminating the --ws-port flag to swapd and using --swapd-port flag for swapcli.
2022-09-10 14:54:43 -05: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
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
e9f437b7bb fix incorrect padding in NewPublicKeyFromBigInt (#143) 2022-08-01 20:19:36 -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
0eb4f73dcc refactor: create protocol backend, rename protocol packages to xmrmaker/xmrtaker (#123) 2022-06-02 22:08:20 -04:00
noot
55ae59046c add more unit tests + errors clean up (#114) 2022-05-15 23:36:03 -04:00
noot
2b631d2d36 automated tester improvements and fixes (#111) 2022-05-09 21:30:07 -04:00
noot
968dd75fbd fixes for stagenet, log cleanup, add automated stagenet tester binary (#108) 2022-04-11 18:56:53 -04:00
noot
65d64544d7 implement unhappy path and error case integration tests (#102) 2022-03-21 15:54:41 -04:00
noot
d24eb78434 create separate integration test CI job, implement net_makeOfferAndSubscribe, swap_getOffers, implement happy path integration test (#101) 2022-03-15 22:50:05 -04:00
noot
5d225ac41d add code coverage to unit tests step, add lots of unit tests (#79) 2022-02-05 23:07:29 -05:00
noot
988b514cf1 cleanup codebase (#72)
* remove unused code, move some funcs around

* move monero/crypto to crypto/monero

* cleanup alice swap_state.go, move funcs

* move rpcclient and types package to common
2022-01-16 23:34:29 -05:00
noot
39e6cc0bcd integrate DLEq into protocol (#67)
* update contract to use secp256k1 curve verification

* update go contract bindings script and bindings

* cleanup rust code, move to its own folder

* remove commented out stuff

* go fmt

* add go wrapper around farcaster-dleq

* add unit tests for farcaster-dleq wrapper

* add dleq unit test for keys

* add swap.go claim test, worksgit status

* add swap.go refund tests

* lint

* update SendKeysMessage to include DLEqProof, update alice/bob generateKeys

* add dleq proof verification to alice/bob handlers

* move alice and bob to protocol package

* add common protocol funcs for generating/verifying dleq proof

* lint

* update alice to store secp256k1 pubkey commitments in contract, update alice/bob to use dleq secret when calling contract

* update alice unit tests

* fix bob unit tests

* update network msg size

* add build-dleq makefile step

* cleanup

* attempt to fix test

* skip inconsistent test on CI
2022-01-15 13:41:27 -05:00
noot
bcbb77d8f6 add private key proof to SendKeyMessage, verify on receipt (#62) 2021-12-11 20:54:21 -05:00
noot
d6aba125e4 improve linter and lint code (#58) 2021-12-11 11:26:06 -05:00
noot
78752a9088 implement refund path for Bob on unexpected stream closure, add contract checks (#56) 2021-12-06 23:18:30 -05:00
noot
acee21ce19 add --gas-price, --gas-limit flags, net_setGasPrice RPC (#55) 2021-12-06 22:00:55 -05:00
noot
0c41b794e7 add more unit tests, add integration tests (#53) 2021-12-01 23:54:39 -05:00
noot
d703279d9b update units passed by cli/RPC to be standard unts, not smallest denomination (#50)
* update units for cmd line/RPC to be ether and monero

* fix log

* cleanup

* lint
2021-11-28 16:57:56 -05:00
noot
e2cffc980a implement swapcli (#47)
* add lock to swapState

* cli created w discover, query, and initiate

* add bold logging

* update readme
2021-11-25 23:15:06 -05:00
noot
858df49eab fixes for stagenet + ropsten (#46)
* wait for receipts

* code cleanup
2021-11-25 21:06:24 -05:00
noot
6131c1d36f revert changes from issue #36 (#43)
* update protocol code

* lint, fix tests

* fix tests
2021-11-23 23:55:04 -05:00
noot
f369b9a3bb create mainnet, stagenet, and dev environments (#41)
* add environment type, update monero address to use network prefix

* update tests

* pass env through flag

* update --ethereum-privkey to take a file

* config basepath and chainIDs

* fix tests

* update network protocol IDs

* pass env to net

* go fmt, bump ci go version to 1.17

* make directories when needed

* fix tests
2021-11-23 23:47:41 -05:00
noot
95d72b7b02 add view key checks using open_wallet and close_wallet (#40)
* add view key checks using open_wallet and close_wallet

* fix unit tests, update script

* fix tests
2021-11-22 22:22:39 -05:00