Beispiel #1
0
        public void ToString_ValueString_AsPerCurrentCulture()
        {
            var pointTwo = new Denomination(.2m);

            using (CultureReseter.Set("en-US"))
            {
                Assert.That(pointTwo.ToString(), Is.EqualTo("0.2"), "US decimals with a dot");
            }

            using (CultureReseter.Set("da-DK"))
            {
                Assert.That(pointTwo.ToString(), Is.EqualTo("0,2"), "DK decimals with a comma");
            }
        }
Beispiel #2
0
        public void ToString_CanReceiveCustomFormatsAndProviders()
        {
            var pointTwo = new Denomination(.2m);
            var snailDecimalSeparator = (NumberFormatInfo)CultureInfo.InvariantCulture.NumberFormat.Clone();

            snailDecimalSeparator.NumberDecimalSeparator = "@";

            Assert.That(pointTwo.ToString(".000", snailDecimalSeparator), Is.EqualTo("@200"));
        }
Beispiel #3
0
        // Gets the singular form of the denomination passed in.
        // Example: Dollars returns "Dollar"
        public string SingularDenominationName(Denomination denomination)
        {
            // Gets the info for the enum.
            var memberInfo = typeof(Denomination).GetMember(denomination.ToString());

            // Gets the attributes for the enum.
            var attrs = memberInfo[0].GetCustomAttributes(typeof(DescriptionAttribute), false);

            // Gets the "Description" attribute for the enum.
            return(((DescriptionAttribute)attrs[0]).Description);
        }
Beispiel #4
0
        public CcjRound(RPCClient rpc, UtxoReferee utxoReferee, CcjRoundConfig config)
        {
            try
            {
                Interlocked.Increment(ref RoundCount);
                RoundId = Interlocked.Read(ref RoundCount);

                RpcClient   = Guard.NotNull(nameof(rpc), rpc);
                UtxoReferee = Guard.NotNull(nameof(utxoReferee), utxoReferee);
                Guard.NotNull(nameof(config), config);

                Denomination                  = config.Denomination;
                ConfirmationTarget            = (int)config.ConfirmationTarget;
                CoordinatorFeePercent         = (decimal)config.CoordinatorFeePercent;
                AnonymitySet                  = (int)config.AnonymitySet;
                InputRegistrationTimeout      = TimeSpan.FromSeconds((long)config.InputRegistrationTimeout);
                ConnectionConfirmationTimeout = TimeSpan.FromSeconds((long)config.ConnectionConfirmationTimeout);
                OutputRegistrationTimeout     = TimeSpan.FromSeconds((long)config.OutputRegistrationTimeout);
                SigningTimeout                = TimeSpan.FromSeconds((long)config.SigningTimeout);

                PhaseLock  = new object();
                Phase      = CcjRoundPhase.InputRegistration;
                StatusLock = new object();
                Status     = CcjRoundStatus.NotStarted;

                RoundHash            = null;
                _unsignedCoinJoinHex = null;

                UnsignedCoinJoin = null;
                SignedCoinJoin   = null;

                Alices = new List <Alice>();
                Bobs   = new List <Bob>();

                Logger.LogInfo <CcjRound>($"New round ({RoundId}) is created.\n\t" +
                                          $"{nameof(Denomination)}: {Denomination.ToString(false, true)} BTC.\n\t" +
                                          $"{nameof(ConfirmationTarget)}: {ConfirmationTarget}.\n\t" +
                                          $"{nameof(CoordinatorFeePercent)}: {CoordinatorFeePercent}.\n\t" +
                                          $"{nameof(AnonymitySet)}: {AnonymitySet}.");
            }
            catch (Exception ex)
            {
                Logger.LogError <CcjRound>($"Round ({RoundId}) creation failed.");
                Logger.LogError <CcjRound>(ex);
                throw;
            }
        }