public void TestSign()
        {
            Transaction.Sign(FeeSource, Network);
            var xdr = Transaction.ToEnvelopeXdr();

            Assert.AreEqual(1, xdr.FeeBump.Signatures.Length);
            var rawSig = xdr.FeeBump.Signatures[0];

            Assert.IsTrue(FeeSource.Verify(Transaction.Hash(Network), rawSig.Signature));
        }
Esempio n. 2
0
        public CurrencyAmountResult Transform(string pair, decimal baseCurrencyAmount, decimal currencyPrice, decimal feePercent, FeeSource feeSource = FeeSource.Base)
        {
            var result   = new CurrencyAmountResult();
            var rounding = 10 * _config[pair].VolumeFormat;

            switch (feeSource)
            {
            case FeeSource.Base:
                result.Fee = Math.Round(baseCurrencyAmount * feePercent / 100, 2);
                result.TargetCurrencyAmount = Math.Floor((baseCurrencyAmount - result.Fee) / currencyPrice * rounding) / rounding;
                result.BaseCurrencyRest     = baseCurrencyAmount - (result.TargetCurrencyAmount * currencyPrice + result.Fee);
                break;

            case FeeSource.Target:
                var baseUsd = currencyPrice * baseCurrencyAmount;
                result.Fee = Math.Round(baseUsd * feePercent / 100, _config[pair].PriceFormat);
                result.BaseCurrencyRest     = decimal.Zero;
                result.TargetCurrencyAmount = baseUsd - result.Fee;
                break;
            }

            return(result);
        }