public MissingMnemonicViewModel() { WordListsList = ListHelper.GetAllEnumValues <BIP0039.WordLists>().ToArray(); MnemonicTypesList = ListHelper.GetAllEnumValues <MnemonicTypes>().ToArray(); InputTypeList = ListHelper.GetEnumDescItems <InputType>().ToArray(); SelectedInputType = InputTypeList.First(); MnService = new MnemonicSevice(Result); IObservable <bool> isFindEnabled = this.WhenAnyValue( x => x.Mnemonic, x => x.AdditionalInfo, x => x.KeyPath, x => x.Result.CurrentState, (mn, extra, path, state) => !string.IsNullOrEmpty(mn) && !string.IsNullOrEmpty(extra) && !string.IsNullOrEmpty(path) && state != State.Working); FindCommand = ReactiveCommand.Create(Find, isFindEnabled); HasExample = true; IObservable <bool> isExampleVisible = this.WhenAnyValue( x => x.Result.CurrentState, (state) => state != State.Working && HasExample); ExampleCommand = ReactiveCommand.Create(Example, isExampleVisible); }
public void GetSeedByteTest() { byte[] actual = MnemonicSevice.GetSeedByte(12, 3); Assert.Equal(47, actual.Length); actual = MnemonicSevice.GetSeedByte(12, 8); Assert.Equal(107, actual.Length); actual = MnemonicSevice.GetSeedByte(24, 33); Assert.Equal(815, actual.Length); }
public void GetSeedByteTest() { var serv = new MnemonicSevice(null); byte[] actual = serv.GetSeedByte(12, 3); Assert.Equal(47, actual.Length); actual = serv.GetSeedByte(12, 8); Assert.Equal(107, actual.Length); actual = serv.GetSeedByte(24, 33); Assert.Equal(815, actual.Length); }
public MissingMnemonicViewModel() { WordListsList = Enum.GetValues(typeof(WordLists)).Cast <WordLists>(); MnService = new MnemonicSevice(Result); IObservable <bool> isFindEnabled = this.WhenAnyValue( x => x.Mnemonic, x => x.Result.CurrentState, (mn, state) => !string.IsNullOrEmpty(mn) && state != Models.State.Working); FindCommand = ReactiveCommand.Create(Find, isFindEnabled); }
public Bip32PathViewModel() { WordListsList = Enum.GetValues(typeof(BIP0039.WordLists)).Cast <BIP0039.WordLists>(); IObservable <bool> isFindEnabled = this.WhenAnyValue( x => x.Mnemonic, x => x.AdditionalInfo, x => x.Result.CurrentState, (mn, input, state) => !string.IsNullOrEmpty(mn) && !string.IsNullOrEmpty(input) && state != State.Working); FindCommand = ReactiveCommand.Create(Find, isFindEnabled); MnemonicTypesList = Enum.GetValues(typeof(MnemonicTypes)).Cast <MnemonicTypes>(); MnService = new MnemonicSevice(Result); }
public void TrySetWordListTest() { var serv = new MnemonicSevice(null); Array wls = Enum.GetValues(typeof(BIP0039.WordLists)); byte[] space = Encoding.UTF8.GetBytes(" "); Assert.Single(space); foreach (BIP0039.WordLists item in wls) { bool b = serv.TrySetWordList(item, out string[] words, out int actualMaxWordLen); Assert.True(b); Assert.Equal(2048, words.Length); string bigSeed = string.Join(" ", words); int expectedMaxWordLen = 0; FastStream stream = new FastStream(37831); for (int i = 0; i < words.Length; i++) { byte[] wordBa = Encoding.UTF8.GetBytes(words[i]); stream.Write(wordBa); if (expectedMaxWordLen < wordBa.Length) { expectedMaxWordLen = wordBa.Length; } if (i != 2047) { stream.Write(space); } } byte[] actual = stream.ToByteArray(); byte[] expected = Encoding.UTF8.GetBytes(bigSeed); Assert.Equal(expected, actual); Assert.Equal(expectedMaxWordLen, actualMaxWordLen); } }