private static void Main(string[] args) { Console.WriteLine("Token?"); var token = Console.ReadLine(); var b = new Blockcypher(token, Endpoint.BtcTest3); var fromAddress = new AddressInfo("mtWg6ccLiZWw2Et7E5UqmHsYgrAi5wqiov", // TESTNET "1af97b1f428ac89b7d35323ea7a68aba8cad178a04eddbbf591f65671bae48a2", // HEX "03bb318b00de944086fad67ab78a832eb1bf26916053ecd3b14a3f48f9fbe0821f"); // COMPRESSED var toAddress = new AddressInfo("n2XgDw5DixTyxFKKxFcHuK5KSaUvS2UAoj", // TESTNET "477fcfc70eafd99f235d3050c4b8f4a1a6ae9b8e1a7f5cc1a8abb49e901f0943", // HEX "034f6f8a9e6ce7d665f70fd1875b4d8f8138bcc8f6c75f8a030a6dd194cc2c197b"); // COMPRESSED //Console.WriteLine(b.Send(fromAddress, toAddress, 25000).Result.ToJson()); Console.ReadKey(); }
public string init_folkeregister() { string output = ""; Blockcypher api = new Blockcypher(Constants.apiUserToken, Endpoint.BcyTest); AddressInfo address = api.GenerateAddress().Result; output += $"<br>Address: {address.Address}"; output += $"<br>PrivKey: {address.Private}"; output += $"<br>PubKey: {address.Public}"; Faucet f = api.Faucet(address.Address, new Satoshi(100)).Result; output += $"<br>Transferring 100 satoshi to account"; Thread.Sleep(1000); // TODO Find out how to add some data to the transactions? // TODO Make a viewmodel, create the form to specify data etc. AddressBalance bal = api.GetBalanceForAddress(address.Address).Result; output += $"<br>Balance: {bal.Balance.Value} satoshi"; output += $"<br>Unconfirmed balance: {bal.UnconfirmedBalance} satoshi"; // HttpContext.Session.SetString(Constants.PrivateKeySessionKey, address.Private); // HttpContext.Session.SetString(Constants.AddressSessionKey, address.Address); return(output); }
public IActionResult Verify(string keyword) { Blockcypher api = new Blockcypher(Constants.apiUserToken, Endpoint.BtcTest3); //Sign keyword with private key of IDCoin return(View("Index")); }
public void Send() { var b = new Blockcypher("f4dfb3efeb9d4e5ca036fbfab5d919c9", Endpoint.BtcTest3); var amountInSatoshi = Convert.ToInt64(0.0156813 * 100000000); var transaction = b.Send("mwv4fzSSxa5FTAGekECBbdLDk3tCLBxXJj", "mngqWGRMnsQHzRXPj7mtgb2YzRQkWKX9Ab", "dc2e6bf2fd9dcbb79fc11f86acebb3ed2a85a304840e73e02930f63a3f154dde", "03c0cb46037f7492fd46eaf783935c678d1ba17fc9d047a2dec4e3697fe9ed63a8", new Satoshi(10000)).Result; var tran = b.GetTransaction(transaction.Transactions.Hash).Result; }
public UnsignedTransaction SendTransactionToExchage(dynamic transactionDto, string toAddress, string privateKey, string network, string token) { try { var btcnetwork = GetNetwork(network); Endpoint endpoint = Endpoint.BtcTest3; if (network.ToUpper() == "MAIN") { endpoint = Endpoint.BtcMain; } Blockcypher blockCypherLib = new Blockcypher(token, endpoint); BitcoinSecret secret = new BitcoinSecret(privateKey, btcnetwork); NBitcoin.Transaction tx = NBitcoin.Transaction.Create(btcnetwork); TxIn input = new TxIn { PrevOut = new OutPoint(new uint256(transactionDto.TransactionID), transactionDto.Vout), ScriptSig = secret.GetAddress(ScriptPubKeyType.Legacy).ScriptPubKey }; tx.Inputs.Add(input); TxOut output = new TxOut(); Money fee = Money.Coins(transactionDto.DefaultFees.GetValueOrDefault()); Money totalAmount = Money.Coins(transactionDto.Amount); output.Value = totalAmount - fee; BitcoinAddress toaddress = BitcoinAddress.Create(toAddress, btcnetwork); output.ScriptPubKey = toaddress.ScriptPubKey; tx.Outputs.Add(output); var coins = tx.Inputs.Select(txin => new Coin(txin.PrevOut, new TxOut { ScriptPubKey = txin.ScriptSig })); tx.Sign(secret, coins.ToArray()); var response = blockCypherLib.PushTransaction(tx.ToHex()).Result; return(response); } catch (Exception ex) { throw new Exception(); } }
public IActionResult Status() { // check transaction var api = new Blockcypher(Constants.apiUserToken, Endpoint.BtcTest3); var tr = api.GetTransactions(_session.GetDemoAddress()); var count = tr.Result.Length; var phrase = HttpContext.Session.GetString("Phrase"); // var success = OneTimePassword.Keys.Exists(a => a == phrase); var success = OneTimePassword.Keys.Count > 0; if (success) { OneTimePassword.Keys.Remove(phrase); return(new JsonResult(true)); } else { return(new JsonResult(false)); } }