public void CanProcessBtcTransaction()
        {
            var addr = GetBitcoinAddress().ToString();
            var newTransaction = new NewTransaction {
                Ticker = "XBT",
                AmountSatoshi = 100000,
                From = addr,
                To = addr,
                Change = addr,
                FeePerKB = 12345,
            };

            var client = CreateAuthenticatedClient();
            var created = client.CreateTransaction(newTransaction);
            Assert.NotNull(created);
            Assert.NotNull(created.Raw);
            Assert.AreEqual(addr, created.InputsToSign.First().SigningAddress);

            var rawTx = new RawTransaction{ Raw = GetHexSignedTransaction(created)};
            var result = client.BroadcastTransaction(rawTx);

            Assert.True(result.IsSuccess);
        }
예제 #2
0
        /// <summary>
        /// Create a Transaction using the provided parameters
        /// </summary>
        /// <param name="tx">The raw-signed transaction</param>
        /// <returns>The transaction to sign</returns>
        /// <exception cref="MetacoClientException"></exception>
        /// <remarks>
        /// Requires Authentication
        /// </remarks>
        /// <see cref="http://docs.metaco.apiary.io/#reference/transactions/raw-transaction/get-a-raw-transaction">Online Documentation</see>
        public TransactionToSign CreateTransaction(NewTransaction tx)
        {
            if (tx == null)
                throw new ArgumentNullException("tx");

            var parms = new List<string>();

            if (tx.AmountAsset  > 0)
            {
                parms.Add("amount_asset=" + tx.AmountAsset );
            }
            if (tx.AmountSatoshi > 0)
            {
                parms.Add("amount_satoshi=" + tx.AmountSatoshi);
            }
            if (!string.IsNullOrEmpty(tx.Change))
            {
                parms.Add("change=" + tx.Change);
            }
            if (!string.IsNullOrEmpty(tx.From))
            {
                parms.Add("from=" + tx.From);
            }
            if (!string.IsNullOrEmpty(tx.To))
            {
                parms.Add("to=" +  tx.To);
            }
            if (!string.IsNullOrEmpty(tx.Ticker))
            {
                parms.Add("ticker=" + tx.Ticker);
            }
            if (tx.FeePerKB > 0)
            {
                parms.Add("feePerKB=" + tx.FeePerKB);
            }

            return _httpClient.Get<TransactionToSign>("transactions/raw?" + string.Join("&", parms));
        }