/// <summary>
        /// Submit a signed transaction
        /// </summary>
        /// <param name="rawTransaction">The raw-signed transaction to be broadcasted</param>
        /// <returns>The broadcasting operation result</returns>
        /// <exception cref="MetacoClientException"></exception>
        /// <remarks>
        /// Requires Authentication
        /// You have to sign each of your inputs of the selected transaction (you will get those details when creating the transaction through Metaco)
        /// Then encode the transaction in hexadecimal and send it here
        /// </remarks>
        /// <see cref="http://docs.metaco.apiary.io/#reference/transactions/transaction-broadcast/broadcast-a-transaction">Online Documentation</see>
        public TransactionBroadcastResult BroadcastTransaction(RawTransaction rawTransaction)
        {
            if (rawTransaction == null)
                throw new ArgumentNullException("rawTransaction");

            return _httpClient.Post<TransactionBroadcastResult, RawTransaction>("transactions", rawTransaction);
        }
        public void CanProcessOrder()
        {
            var addr = GetBitcoinAddress().ToString();
            var newOrder = new NewOrder {
                AmountAsset = 100L,
                Funding = new []{ addr },
                Recipient = addr,
                Ticker = "MTC:USD",
                Type = OrderType.Buy
            };

            var client = CreateAuthenticatedClient();

            var created = client.CreateOrder(newOrder);
            Assert.NotNull(created);
            Assert.AreEqual(100L, created.AmountAsset);

            var orderToSign = WaitForOrderState(client, created.Id, "Signing");
            if (orderToSign == null) {
                throw new Exception("Order " + created.Id + " took to long to go to Signing state");
            }

            /** Signing and submit **/
            var rawTx = new RawTransaction {
                Raw = GetHexSignedTransaction(orderToSign.Transaction)
            };

            client.SubmitSignedOrder(orderToSign.Id, rawTx);

            /** Wait for broadcasting **/
            var unconfirmed = WaitForOrderState(client, created.Id, "Unconfirmed");
            if (unconfirmed == null) {
                throw new Exception("Order " + created.Id + " took to long to go to Unconfirmed state");
            }

            Assert.AreEqual(100, unconfirmed.AmountAsset);

            /** Try to delete broadcasting order **/
            try {
                client.CancelOrder(unconfirmed.Id);
                throw new Exception("A MetacoClientException was expected!");
            } catch (MetacoClientException e) {
                Assert.AreEqual(ErrorType.OrderNotCancellable, e.ErrorType);
            }

            /** Fetch all the orders **/
            var orders = client.GetOrders();

            if (orders.Orders.All(x => x.Id != created.Id))
            {
                throw new Exception("Order " + created.Id + " is not present in orders list");
            }
        }
        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);
        }
        public void CantBroadcastTransaction()
        {
            try {
                var client = CreateAuthenticatedClient();

                var raw = new RawTransaction {Raw = "fakerawtx"};
                client.BroadcastTransaction(raw);
                throw new Exception("An MetacoException was expected!");
            } catch (MetacoClientException e) {
                Assert.AreEqual(ErrorType.InvalidInput, e.ErrorType);
            }
        }
        /// <summary>
        /// Submit a signed order
        /// </summary>
        /// <param name="id">The order identifier.</param>
        /// <param name="rawTransaction">The raw-signed transaction</param>
        /// <returns>The order object </returns>
        /// <exception cref="MetacoClientException"></exception>
        /// <remarks>
        /// Requires Authentication
        /// You have to sign each of your inputs of the selected order (you will get those details by fetching the orders)
        /// Then encode the transaction in hexadecimal and send it here
        /// </remarks>
        /// <see cref="http://docs.metaco.apiary.io/#reference/orders/order-information/submit-a-signed-order">Online Documentation</see>
        public Order SubmitSignedOrder(string id, RawTransaction rawTransaction)
        {
            if (string.IsNullOrEmpty(id))
                throw new ArgumentNullException("id");
            if (rawTransaction == null)
                throw new ArgumentNullException("rawTransaction");

            return _httpClient.Post<Order, RawTransaction>(string.Format("orders/{0}", id), rawTransaction);
        }