private Models.Messages.BuyInResponse BuyIn(Models.Messages.BuyInRequest request) { var table = this.TableRepo.Find(request.TableId); if (table != null) { NBitcoin.Transaction tx = new NBitcoin.Transaction(); NBitcoin.TransactionBuilder builder = new NBitcoin.TransactionBuilder(); Boolean isValid = true; // builder.Verify(tx); if (isValid) { var utxos = tx.Outputs; var sum = tx.Outputs.Sum(u => u.Value); } else { throw new Exception(); } } else { throw new ArgumentException("Table id not found"); } return(new Models.Messages.BuyInResponse()); }
public bool SendMogs(MogwaiKeys mogwaiKey, string[] toAddresses, decimal amount, decimal txFee, out string txid) { Log.Debug($"send mogs {mogwaiKey.Address}, [{string.Join(",", toAddresses)}] for {amount} with {txFee}."); txid = string.Empty; List <UnspentTx> unspentTxList = GetUnspent(0, 9999999, mogwaiKey.Address); var unspentAmount = unspentTxList.Sum(p => p.Amount); if (unspentAmount < amount * toAddresses.Length + txFee) { Log.Debug($"Address hasn't enough funds {unspentAmount} to burn that amount of mogs {amount * toAddresses.Length + txFee}!"); return(false); } // create transaction NBitcoin.Transaction tx = mogwaiKey.CreateTransaction(unspentTxList, unspentAmount, toAddresses, amount, txFee); Log.Info($"signedRawTx: {tx.ToHex()}"); txid = SendRawTransaction(tx.ToHex()); Log.Info($"sendRawTx[{(txid.Length != 0 ? "SUCCESS" : "FAILED")}]: {txid}"); return(txid.Length != 0); }
internal Boolean ValidateTx(String tx) { NBitcoin.Transaction transaction = new NBitcoin.Transaction(); NBitcoin.TransactionBuilder builder = new NBitcoin.TransactionBuilder(); return(true); }
public void BurnMogs() { var wallet = new MogwaiWallet("1234", "test.dat"); MogwaiKeys mogwaiKeys0 = wallet.MogwaiKeyDict["MWG1HtzRAjZMxQDzeoFoHQbzDygGR13aWG"]; Assert.Equal("MWG1HtzRAjZMxQDzeoFoHQbzDygGR13aWG", mogwaiKeys0.Address); MogwaiKeys mogwaiKeys1 = wallet.MogwaiKeyDict["MNtnWbBjUhRvNnd9YxM2mnxeLPNkxb4Fio"]; Assert.Equal("MNtnWbBjUhRvNnd9YxM2mnxeLPNkxb4Fio", mogwaiKeys1.Address); var blockResponse0 = Blockchain.Instance.GetBalance("MWG1HtzRAjZMxQDzeoFoHQbzDygGR13aWG"); Assert.Equal(8.99999m, blockResponse0); var blockResponse1 = Blockchain.Instance.GetBalance("MNtnWbBjUhRvNnd9YxM2mnxeLPNkxb4Fio"); Assert.Equal(12.12344678m, blockResponse1); System.Collections.Generic.List <WoMWallet.Block.UnspentTx> unspentTxList = Blockchain.Instance.GetUnspent(6, 9999999, mogwaiKeys0.Address); var unspentAmount = unspentTxList.Sum(p => p.Amount); // create transaction NBitcoin.Transaction tx = mogwaiKeys0.CreateTransaction(unspentTxList, unspentAmount, new[] { mogwaiKeys1.Address }, 1.0m, 0.00001m); Assert.Equal("01000000019d0262999e5eacc32c2c6921e730d57a7e51938c2d3e22158979c72a7be318e3010000006a4730440220263c7d3955de95901f70fd66210a7ba095581e6261b3f71c1165d80583fe768b022062cd638398ba735d55dcaa17de225143997307c24e84b1a2be29bc4b7a73c61f012103007f99a5c4754d67c9fed1852ed451bec7371c1b0907b8488ee5aa6593b865c4ffffffff0200e1f505000000001976a914a477c1319360114de9f3ed88381cc4dfa9147f3288ac3000af2f000000001976a914f5440a1dd1ada4c5b4160b8c754f9148eb4a505388ac00000000", tx.ToHex()); //var blockResponse = Blockchain.Instance.SendRawTransaction(tx.ToHex()); //Assert.Equal("", blockResponse); }
public static byte[] GetExtraPayload(this NBitcoin.Transaction transaction) => ((Transaction)transaction).ExtraPayload;
public static Elysium.Transaction?GetElysiumTransaction(this NBitcoin.Transaction transaction) => ((Transaction)transaction).ElysiumTransaction;
public static void SetTransactionType(this NBitcoin.Transaction transaction, TransactionType value) => ((Transaction)transaction).TransactionType = value;
public static void SetExtraPayload(this NBitcoin.Transaction transaction, byte[] value) => ((Transaction)transaction).ExtraPayload = value;
public static void SetElysiumTransaction(this NBitcoin.Transaction transaction, Elysium.Transaction?value) => ((Transaction)transaction).ElysiumTransaction = value;
public static bool IsZerocoinSpend(this NBitcoin.Transaction transaction) => ((Transaction)transaction).IsZerocoinSpend;
public static bool IsZerocoinRemint(this NBitcoin.Transaction transaction) => ((Transaction)transaction).IsZerocoinRemint;
public static TransactionType GetTransactionType(this NBitcoin.Transaction transaction) => ((Transaction)transaction).TransactionType;
public BroadcastTransactionStateChanedEntry(NBitcoin.Transaction transaction, TransactionBroadcastState transactionBroadcastState, string errorMessage) { this.Transaction = transaction ?? throw new ArgumentNullException(nameof(transaction)); this.TransactionBroadcastState = transactionBroadcastState; this.ErrorMessage = (errorMessage == null) ? string.Empty : errorMessage; }
public TransactionBroadcastEntry(NBitcoin.Transaction transaction, TransactionBroadcastState transactionBroadcastState, MempoolError mempoolError) { this.Transaction = transaction ?? throw new ArgumentNullException(nameof(transaction)); this.TransactionBroadcastState = transactionBroadcastState; this.MempoolError = mempoolError; }
public TransactionBroadcastEntry(NBitcoin.Transaction transaction, State state, string errorMessage) { this.Transaction = transaction ?? throw new ArgumentNullException(nameof(transaction)); this.State = state; this.ErrorMessage = errorMessage; }
public decimal EstimateFee(NBitcoin.Transaction transaction) { return(0.00000001m * (transaction.ToHex().Length / 2 + 4)); }