Files
atomic-swap/common/config.go
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

81 lines
3.0 KiB
Go

package common
import (
"os"
"path"
ethcommon "github.com/ethereum/go-ethereum/common"
)
const (
// DefaultMoneroWalletName is the default wallet name in {DATA_DIR}/wallet/
DefaultMoneroWalletName = "swap-wallet"
// DefaultLibp2pKeyFileName is the default libp2p private key file name in {DATA_DIR}
DefaultLibp2pKeyFileName = "net.key"
// DefaultEthKeyFileName is the default ethereum private key file name in {DATA_DIR}
DefaultEthKeyFileName = "eth.key"
)
var homeDir, _ = os.UserHomeDir()
var baseDir = path.Join(homeDir, ".atomicswap")
// Config contains constants that are defaults for various environments
type Config struct {
DataDir string
MoneroDaemonHost string
MoneroDaemonPort uint
ContractAddress ethcommon.Address
Bootnodes []string
}
// MainnetConfig is the mainnet ethereum and monero configuration
var MainnetConfig = Config{
DataDir: path.Join(baseDir, "mainnet"),
MoneroDaemonHost: "127.0.0.1",
MoneroDaemonPort: DefaultMoneroDaemonMainnetPort,
}
// StagenetConfig is the monero stagenet and ethereum Gorli configuration
var StagenetConfig = Config{
DataDir: path.Join(baseDir, "stagenet"),
MoneroDaemonHost: "node.sethforprivacy.com",
MoneroDaemonPort: 38089, // Seth is not using the default stagenet value of 38081 (so don't use our constant)
ContractAddress: ethcommon.HexToAddress("0x5F8Cf66C4c59d398052aA75D46Ce48e7fA09A83E"),
Bootnodes: []string{
"/ip4/134.122.115.208/tcp/9900/p2p/12D3KooWDqCzbjexHEa8Rut7bzxHFpRMZyDRW1L6TGkL1KY24JH5",
"/ip4/143.198.123.27/tcp/9900/p2p/12D3KooWSc4yFkPWBFmPToTMbhChH3FAgGH96DNzSg5fio1pQYoN",
"/ip4/67.207.89.83/tcp/9900/p2p/12D3KooWLbfkLZZvvn8Lxs1KDU3u7gyvBk88ZNtJBbugytBr5RCG",
"/ip4/134.122.115.208/tcp/9900/p2p/12D3KooWDqCzbjexHEa8Rut7bzxHFpRMZyDRW1L6TGkL1KY24JH5",
"/ip4/164.92.103.160/tcp/9900/p2p/12D3KooWAZtRECEv7zN69zU1e7sPrHbMgfqFUn7QTLh1pKGiMuaM",
"/ip4/164.92.103.159/tcp/9900/p2p/12D3KooWSNQF1eNyapxC2zA3jJExgLX7jWhEyw8B3k7zMW5ZRvQz",
"/ip4/164.92.123.10/tcp/9900/p2p/12D3KooWG8z9fXVTB72XL8hQbahpfEjutREL9vbBQ4FzqtDKzTBu",
"/ip4/161.35.110.210/tcp/9900/p2p/12D3KooWS8iKxqsGTiL3Yc1VaAfg99U5km1AE7bWYQiuavXj3Yz6",
},
}
// DevelopmentConfig is the monero and ethereum development environment configuration
var DevelopmentConfig = Config{
DataDir: path.Join(baseDir, "dev"),
MoneroDaemonPort: DefaultMoneroDaemonDevPort,
}
// MoneroWalletPath returns the path to the wallet file, whose default value
// depends on current value of the data dir.
func (c Config) MoneroWalletPath() string {
return path.Join(c.DataDir, "wallet", DefaultMoneroWalletName)
}
// LibP2PKeyFile returns the path to the libp2p key file, whose default value
// depends on current value of the data dir.
func (c Config) LibP2PKeyFile() string {
return path.Join(c.DataDir, DefaultLibp2pKeyFileName)
}
// EthKeyFileName returns the path to the ethereum key file, whose default value
// depends on current value of the data dir.
func (c Config) EthKeyFileName() string {
return path.Join(c.DataDir, DefaultEthKeyFileName)
}