/// <inheritdoc /> public async Task LoadOrCreateDefaultFileAsync() { AssertFilePathSet(); Network = Network.Main; MainNetBackendUriV3 = "http://wasabiukrxmkdgve5kynjztuovbg43uxcbcxn6y2okcrsg7gb6jdmbad.onion/"; TestNetBackendUriV3 = "http://testwnp3fugjln6vh5vpj7mvq3lkqqwjj3c2aafyu7laxz42kgwh2rad.onion/"; MainNetFallbackBackendUri = "https://wasabiwallet.io/"; TestNetFallbackBackendUri = "https://wasabiwallet.co/"; RegTestBackendUriV3 = "http://localhost:37127/"; MainNetBlindingRsaPubKey = "16421152619146079007287475569112871971988560541093277613438316709041030720662622782033859387192362542996510605015506477964793447620206674394713753349543444988246276357919473682408472170521463339860947351211455351029147665615454176157348164935212551240942809518428851690991984017733153078846480521091423447691527000770982623947706172997649440619968085147635776736938871139581019988225202983052255684151711253254086264386774936200194229277914886876824852466823571396538091430866082004097086602287294474304344865162932126041736158327600847754258634325228417149098062181558798532036659383679712667027126535424484318399849"; TestNetBlindingRsaPubKey = "19473594448380717274202325076521698699373476167359253614775896809797414915031772455344343455269320444157176520539924715307970060890094127521516100754263825112231545354422893125394219335109864514907655429499954825469485252969706079992227103439161156022844535556626007277544637236136559868400854764962522288139619969507311597914908752685925185380735570791798593290356424409633800092336087046668579610273133131498947353719917407262847070395909920415822288443947309434039008038907229064999576278651443575362470457496666718250346530518268694562965606704838796709743032825816642704620776596590683042135764246115456630753521"; RegTestBlindingRsaPubKey = "19805113859916587596075691932680544502861190231482837135218424025384831779489269920459188761934430015720070888224509088334152377323792066863417578306968689084791111308220228369762317647065031287517847066636982918712457594977634751868801139928799770519498159408918552825154189662499542806401435306060574685644660620060856030258068774230785018597890946429085154652737881893280417266199217120928088976827238198687973416161592683348464391329470544325577003456519043206654114118700413398703915300437305079248875534495551617486735684899764754790953560278186552096336558799678522940277063802490218431509991711997155692507897"; TorHost = IPAddress.Loopback.ToString(); TorSocks5Port = 9050; if (!File.Exists(FilePath)) { Logger.LogInfo <Config>($"{nameof(Config)} file did not exist. Created at path: `{FilePath}`."); } else { await LoadFileAsync(); } // Just debug convenience. _backendUri = GetCurrentBackendUri(); _blindingRsaPubKey = GetBlindingRsaPubKey(); await ToFileAsync(); }
public async Task LoadFileAsync() { string jsonString = await File.ReadAllTextAsync(FilePath, Encoding.UTF8); var config = JsonConvert.DeserializeObject <Config>(jsonString); Network = config.Network ?? Network; MainNetBackendUriV3 = config.MainNetBackendUriV3 ?? MainNetBackendUriV3; TestNetBackendUriV3 = config.TestNetBackendUriV3 ?? TestNetBackendUriV3; MainNetFallbackBackendUri = config.MainNetFallbackBackendUri ?? MainNetFallbackBackendUri; TestNetFallbackBackendUri = config.TestNetFallbackBackendUri ?? TestNetFallbackBackendUri; RegTestBackendUriV3 = config.RegTestBackendUriV3 ?? RegTestBackendUriV3; MainNetBlindingRsaPubKey = config.MainNetBlindingRsaPubKey ?? MainNetBlindingRsaPubKey; TestNetBlindingRsaPubKey = config.TestNetBlindingRsaPubKey ?? TestNetBlindingRsaPubKey; RegTestBlindingRsaPubKey = config.RegTestBlindingRsaPubKey ?? RegTestBlindingRsaPubKey; TorHost = config.TorHost ?? TorHost; TorSocks5Port = config.TorSocks5Port ?? TorSocks5Port; // Just debug convenience. _backendUri = GetCurrentBackendUri(); _blindingRsaPubKey = GetBlindingRsaPubKey(); }
public CcjClient(WasabiSynchronizer synchronizer, Network network, BlindingRsaPubKey coordinatorPubKey, KeyManager keyManager, Uri ccjHostUri, IPEndPoint torSocks5EndPoint = null) { AccessCache = new ConcurrentDictionary <HdPubKey, DateTimeOffset>(); Network = Guard.NotNull(nameof(network), network); CoordinatorPubKey = Guard.NotNull(nameof(coordinatorPubKey), coordinatorPubKey); KeyManager = Guard.NotNull(nameof(keyManager), keyManager); CcjHostUri = Guard.NotNull(nameof(ccjHostUri), ccjHostUri); Synchronizer = Guard.NotNull(nameof(synchronizer), synchronizer); TorSocks5EndPoint = torSocks5EndPoint; CoordinatorFeepercentToCheck = null; _running = 0; Cancel = new CancellationTokenSource(); _frequentStatusProcessingIfNotMixing = 0; State = new CcjClientState(); MixLock = new AsyncLock(); _statusProcessing = 0; CustomChangeAddresses = new List <BitcoinAddress>(); CustomActiveAddresses = new List <BitcoinAddress>(); CustomChangeAddressesLock = new object(); CustomActiveAddressesLock = new object(); Synchronizer.ResponseArrived += Synchronizer_ResponseArrivedAsync; }
public void CanSerialize() { var key = new BlindingRsaKey(); string jsonKey = key.ToJson(); var key2 = BlindingRsaKey.CreateFromJson(jsonKey); Assert.Equal(key, key2); Assert.Equal(key.PubKey, key2.PubKey); var jsonPubKey = key.PubKey.ToJson(); var pubKey2 = BlindingRsaPubKey.CreateFromJson(jsonPubKey); Assert.Equal(key.PubKey, pubKey2); // generate blinding factor with pubkey // blind message byte[] message = Encoding.UTF8.GetBytes("áéóúősing me please~!@#$%^&*())_+"); var(BlindingFactor, BlindedData) = pubKey2.Blind(message); // sign the blinded message var signature = key.SignBlindedData(BlindedData); // unblind the signature var unblindedSignature = key2.PubKey.UnblindSignature(signature, BlindingFactor); // verify the original data is signed Assert.True(key2.PubKey.Verify(unblindedSignature, message)); }
public CcjClient(Network network, BlindingRsaPubKey blindingPubKey, KeyManager keyManager, Uri ccjHostUri, IPEndPoint torSocks5EndPoint = null) { Network = Guard.NotNull(nameof(network), network); BlindingPubKey = Guard.NotNull(nameof(blindingPubKey), blindingPubKey); KeyManager = Guard.NotNull(nameof(keyManager), keyManager); AliceClient = new AliceClient(ccjHostUri, torSocks5EndPoint); BobClient = new BobClient(ccjHostUri, torSocks5EndPoint); SatoshiClient = new SatoshiClient(ccjHostUri, torSocks5EndPoint); Rounds = new List <CcjClientRound>(); _running = 0; Stop = new CancellationTokenSource(); _frequentStatusProcessingIfNotMixing = 0; CoinsWaitingForMix = new List <MixCoin>(); MixLock = new AsyncLock(); }
public CcjClient(Network network, BlindingRsaPubKey coordinatorPubKey, KeyManager keyManager, Uri ccjHostUri, IPEndPoint torSocks5EndPoint = null) { Network = Guard.NotNull(nameof(network), network); CoordinatorPubKey = Guard.NotNull(nameof(coordinatorPubKey), coordinatorPubKey); KeyManager = Guard.NotNull(nameof(keyManager), keyManager); CcjHostUri = Guard.NotNull(nameof(ccjHostUri), ccjHostUri); TorSocks5EndPoint = torSocks5EndPoint; SatoshiClient = new SatoshiClient(ccjHostUri, torSocks5EndPoint); _running = 0; Cancel = new CancellationTokenSource(); _frequentStatusProcessingIfNotMixing = 0; State = new CcjClientState(); MixLock = new AsyncLock(); CustomChangeAddresses = new List <BitcoinAddress>(); CustomActiveAddresses = new List <BitcoinAddress>(); CustomChangeAddressesLock = new object(); CustomActiveAddressesLock = new object(); }
/// <inheritdoc /> public async Task LoadOrCreateDefaultFileAsync() { AssertFilePathSet(); Network = Network.Main; MainNetBackendUri = "http://4jsmnfcsmbrlm7l7.onion/"; TestNetBackendUri = "http://wtgjmaol3io5ijii.onion/"; RegTestBackendUri = "http://localhost:37127/"; MainNetBlindingRsaPubKey = "16421152619146079007287475569112871971988560541093277613438316709041030720662622782033859387192362542996510605015506477964793447620206674394713753349543444988246276357919473682408472170521463339860947351211455351029147665615454176157348164935212551240942809518428851690991984017733153078846480521091423447691527000770982623947706172997649440619968085147635776736938871139581019988225202983052255684151711253254086264386774936200194229277914886876824852466823571396538091430866082004097086602287294474304344865162932126041736158327600847754258634325228417149098062181558798532036659383679712667027126535424484318399849"; TestNetBlindingRsaPubKey = "19473594448380717274202325076521698699373476167359253614775896809797414915031772455344343455269320444157176520539924715307970060890094127521516100754263825112231545354422893125394219335109864514907655429499954825469485252969706079992227103439161156022844535556626007277544637236136559868400854764962522288139619969507311597914908752685925185380735570791798593290356424409633800092336087046668579610273133131498947353719917407262847070395909920415822288443947309434039008038907229064999576278651443575362470457496666718250346530518268694562965606704838796709743032825816642704620776596590683042135764246115456630753521"; RegTestBlindingRsaPubKey = "22150624048432351435695977813740447889408430038879549048669066759540857545194001686487035241226456922025362879904859086838539432404987971759281429087375036048566838323339034078875508311398019006566184621390613010655498049414411420453947773863327821032649547904953655351771067398194902527635974622680354037013275997209153454388073967935123137747633576410851133282514228950508503034222184195026309976327466634252381374641066331514368416311365206032260350939804067745887217463885470620044453632242044977087525656336957163920422847954554131015783995416461568282600638297091432144315385391445294118275302802043857482568817"; if (!File.Exists(FilePath)) { Logger.LogInfo <Config>($"{nameof(Config)} file did not exist. Created at path: `{FilePath}`."); } else { string jsonString = await File.ReadAllTextAsync(FilePath, Encoding.UTF8); var config = JsonConvert.DeserializeObject <Config>(jsonString); Network = config.Network ?? Network; MainNetBackendUri = config.MainNetBackendUri ?? MainNetBackendUri; TestNetBackendUri = config.TestNetBackendUri ?? TestNetBackendUri; RegTestBackendUri = config.RegTestBackendUri ?? RegTestBackendUri; MainNetBlindingRsaPubKey = config.MainNetBlindingRsaPubKey ?? MainNetBlindingRsaPubKey; TestNetBlindingRsaPubKey = config.TestNetBlindingRsaPubKey ?? TestNetBlindingRsaPubKey; RegTestBlindingRsaPubKey = config.RegTestBlindingRsaPubKey ?? RegTestBlindingRsaPubKey; } _backendUri = GetCurrentBackendUri(); _blindingRsaPubKey = GetBlindingRsaPubKey(); await ToFileAsync(); }
public BlindingRsaPubKey GetBlindingRsaPubKey() { if (_blindingRsaPubKey != null) { return(_blindingRsaPubKey); } if (Network == Network.Main) { _blindingRsaPubKey = new BlindingRsaPubKey(new BigInteger(MainNetBlindingRsaPubKey), Constants.RsaPubKeyExponent); } else if (Network == Network.TestNet) { _blindingRsaPubKey = new BlindingRsaPubKey(new BigInteger(TestNetBlindingRsaPubKey), Constants.RsaPubKeyExponent); } else // RegTest { _blindingRsaPubKey = new BlindingRsaPubKey(new BigInteger(RegTestBlindingRsaPubKey), Constants.RsaPubKeyExponent); } return(_blindingRsaPubKey); }
public Config(string filePath) { _backendUri = null; _blindingRsaPubKey = null; SetFilePath(filePath); }
public Config() { _backendUri = null; _blindingRsaPubKey = null; }
public static void Initialize(Config config) { WalletService = null; ChaumianClient = null; Config = Guard.NotNull(nameof(config), config); string blindingPubKeyFile = Path.Combine(DataDir, $"BlindingPubKey{Network}.json"); if (File.Exists(blindingPubKeyFile)) { string blindingPubKeyJson = ""; blindingPubKeyJson = File.ReadAllText(blindingPubKeyFile); BlindingPubKey = BlindingRsaPubKey.CreateFromJson(blindingPubKeyJson); } else { if (Network == Network.Main) { BlindingPubKey = new BlindingRsaPubKey(new BigInteger("16421152619146079007287475569112871971988560541093277613438316709041030720662622782033859387192362542996510605015506477964793447620206674394713753349543444988246276357919473682408472170521463339860947351211455351029147665615454176157348164935212551240942809518428851690991984017733153078846480521091423447691527000770982623947706172997649440619968085147635776736938871139581019988225202983052255684151711253254086264386774936200194229277914886876824852466823571396538091430866082004097086602287294474304344865162932126041736158327600847754258634325228417149098062181558798532036659383679712667027126535424484318399849"), new BigInteger("65537")); } else { BlindingPubKey = new BlindingRsaPubKey(new BigInteger("19473594448380717274202325076521698699373476167359253614775896809797414915031772455344343455269320444157176520539924715307970060890094127521516100754263825112231545354422893125394219335109864514907655429499954825469485252969706079992227103439161156022844535556626007277544637236136559868400854764962522288139619969507311597914908752685925185380735570791798593290356424409633800092336087046668579610273133131498947353719917407262847070395909920415822288443947309434039008038907229064999576278651443575362470457496666718250346530518268694562965606704838796709743032825816642704620776596590683042135764246115456630753521"), new BigInteger("65537")); } Directory.CreateDirectory(DataDir); File.WriteAllText(blindingPubKeyFile, BlindingPubKey.ToJson()); } var addressManagerFolderPath = Path.Combine(DataDir, "AddressManager"); AddressManagerFilePath = Path.Combine(addressManagerFolderPath, $"AddressManager{Network}.dat"); var blocksFolderPath = Path.Combine(DataDir, $"Blocks{Network}"); var connectionParameters = new NodeConnectionParameters(); AddressManager = null; try { AddressManager = AddressManager.LoadPeerFile(AddressManagerFilePath); Logger.LogInfo <AddressManager>($"Loaded {nameof(AddressManager)} from `{AddressManagerFilePath}`."); } catch (DirectoryNotFoundException ex) { Logger.LogInfo <AddressManager>($"{nameof(AddressManager)} did not exist at `{AddressManagerFilePath}`. Initializing new one."); Logger.LogTrace <AddressManager>(ex); AddressManager = new AddressManager(); } catch (FileNotFoundException ex) { Logger.LogInfo <AddressManager>($"{nameof(AddressManager)} did not exist at `{AddressManagerFilePath}`. Initializing new one."); Logger.LogTrace <AddressManager>(ex); AddressManager = new AddressManager(); } connectionParameters.TemplateBehaviors.Add(new AddressManagerBehavior(AddressManager)); MemPoolService = new MemPoolService(); connectionParameters.TemplateBehaviors.Add(new MemPoolBehavior(MemPoolService)); Nodes = new NodesGroup(Network, connectionParameters, new NodeRequirement { RequiredServices = NodeServices.Network, MinVersion = Constants.ProtocolVersion_WITNESS_VERSION }); var indexFilePath = Path.Combine(DataDir, $"Index{Network}.dat"); IndexDownloader = new IndexDownloader(Network, indexFilePath, Config.GetCurrentBackendUri()); Nodes.Connect(); Logger.LogInfo("Start connecting to nodes..."); IndexDownloader.Synchronize(requestInterval: TimeSpan.FromSeconds(21)); Logger.LogInfo("Start synchronizing filters..."); }