实例介绍
【实例截图】
【核心代码】
using BitCoin.Dtos;
using BlockChain.Dtos;
using BlockChain.xWinForm.Common.Redis;
using BlockChain.xWinForm.Utils;
using System;
using System.Configuration;
using System.Numerics;
using System.Windows.Forms;
namespace BlockChain.xWinForm
{
public partial class Form2 : Form
{
static RedisStackExchangeHelper redis = new RedisStackExchangeHelper();
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.txtAddress.Text = this.txtAddress.Text.ToLower();
this.txtTo.Text = this.txtTo.Text.ToLower();
this.txtFrom.Text = this.txtFrom.Text.ToLower();
TransferP2PInput input = new TransferP2PInput();
input.BizID = "A0002256";
input.Id = System.Guid.NewGuid().ToString();
input.mType = 5;
input.BlockchainType = (int)BlockchainType.ETH;
input.SourceAddress = this.txtFrom.Text.Trim().ToLower();
input.PrivateKey = this.txtFromPrvKey.Text.Trim().ToLower();
//input.PrivatePassword = this.txtFromPwd.Text.Trim();
input.TargetAddress = this.txtTo.Text.Trim().ToLower(); ;
input.Amount = long.Parse(this.txtAmount.Text);
input.TradeFee = 50;
input.TradeNumber = "A123456789";
input.TradeMemo = "我是备注";
input.Timestamp = DateUtil.GetTimeStamp(DateTime.Now);
this.txtAddress.Text = this.txtAddress.Text.Trim().ToLower();
redis.Publish<TransferP2PInput>("API_BC_Translate", input);
}
private void button2_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(txtQueryTransaction.Text))
{
MessageBox.Show("请输入信息");
return;
}
this.txtAddress.Text = this.txtAddress.Text.Trim();
ConfirmationsInput input = new ConfirmationsInput();
input.BizID = "确认数Id00001";
input.mType = 12;
input.TxHash = this.txtQueryTransaction.Text.Trim();
input.Id = "cf0769b8-bc40-4121-bf26-6db98a346ad9";
input.ConfirmType = ConfirmType.Immediately;
input.BlockchainType = (int)BlockchainType.ETH;
redis.Publish<ConfirmationsInput>("API_BC_GetTxConfirmCount", input);
}
private void button3_Click(object sender, EventArgs e)
{
QueryBalanceInput input = new QueryBalanceInput();
input.mType = 6;
input.BizID = System.Guid.NewGuid().ToString();
input.Address = this.txtAddress.Text.Trim();
input.BlockchainType = (int)BlockchainType.ETH;
redis.Publish<QueryBalanceInput>("API_BC_Getbalance", input);
}
private void label2_Click(object sender, EventArgs e)
{
}
private void Form2_Load(object sender, EventArgs e)
{
this.lblAmount.Text = (new Random().Next(2, 18) / 17m ).ToString("f2");
this.txtAmount.Text = "100";
//this.txtAmount.Text = (new Random().Next(2, 30) / 17m * 10000000000000000).ToString("f2");
this.txtFrom.Text = ConfigurationSettings.AppSettings["txtFrom"].ToString();
this.txtFromPrvKey.Text = ConfigurationSettings.AppSettings["txtFromPrvKey"].ToString();
//this.txtFromPwd.Text = ConfigurationSettings.AppSettings["txtFromPwd"].ToString();
this.txtTo.Text = ConfigurationSettings.AppSettings["txtTo"].ToString();
this.txtAddress.Text = this.txtAddress.Text.Trim();
this.txtBsKey.Text = "BS00001";
this.txtBsValue.Text = "VVVV123456789VVV";
}
private void button4_Click(object sender, EventArgs e)
{
this.txtAddress.Text = this.txtAddress.Text.Trim();
TradeTicket buy = new TradeTicket() { OrderType = 1, Amount = decimal.Parse(this.txtBidAmount.Text), Price = decimal.Parse(this.txtBidPrice.Text), BuySplit = (chkBidSplitOrder.Checked)?"1":"0", SellSplit = "1", mType = "1", OrderId = System.Guid.NewGuid().ToString(), Timestamp = DateUtil.GetTimeStamp(DateTime.Now), Id = System.Guid.NewGuid().ToString(), TradeObjNum = 1 };
redis.Publish<TradeTicket>("API_MatchOrder", buy);
}
private void button5_Click(object sender, EventArgs e)
{
this.txtAddress.Text = this.txtAddress.Text.Trim();
TradeTicket sell1 = new TradeTicket() { OrderType = 2, Amount = decimal.Parse(this.txtBidAmount.Text), Price = decimal.Parse(this.txtBidPrice.Text), BuySplit = "1", SellSplit = (chkBidSplitOrder.Checked) ? "1" : "0", mType = "1", OrderId = System.Guid.NewGuid().ToString(), Timestamp = DateUtil.GetTimeStamp(DateTime.Now), Id = System.Guid.NewGuid().ToString(), TradeObjNum = 1 };
redis.Publish<TradeTicket>("API_MatchOrder", sell1);
}
private void button6_Click(object sender, EventArgs e)
{
this.txtAddress.Text = this.txtAddress.Text.Trim();
AddMonitorInput ticket = new AddMonitorInput() { mType = 3, BlockchainType = 2, Address =this.txtAddress.Text.Trim().ToLower(), BizID = System.Guid.NewGuid().ToString() };
redis.Publish<AddMonitorInput>("API_BC_AddMonitor", ticket);
}
private void button7_Click(object sender, EventArgs e)
{
this.txtAddress.Text = this.txtAddress.Text.Trim();
CancelMonitorInput ticket = new CancelMonitorInput() { mType=4, BlockchainType=2, Address = this.txtAddress.Text.Trim().ToLower(), BizID=System.Guid.NewGuid().ToString() };
redis.Publish<CancelMonitorInput>("API_BC_DelMonitor", ticket);
}
private void groupBox1_Enter(object sender, EventArgs e)
{
}
private void button8_Click(object sender, EventArgs e)
{
this.txtAddress.Text = this.txtAddress.Text.Trim();
QueryMonitorInput ticket = new QueryMonitorInput() { mType = 7, BlockchainType = 2, BizID = System.Guid.NewGuid().ToString() };
redis.Publish<QueryMonitorInput>("API_BC_GetMonitorAddress", ticket);
}
private void button9_Click(object sender, EventArgs e)
{
WriteStringInput input = new WriteStringInput();
input.BStringKey = this.txtBsKey.Text;
input.BStringValue = this.txtBsValue.Text;
input.BizID = "b00001";
input.mType = 8;
input.BlockchainType = 2;
redis.Publish<WriteStringInput>("API_BC_SaveString", input);
}
private void button10_Click(object sender, EventArgs e)
{
ReadStringInput input = new ReadStringInput();
input.BStringKey = this.txtBsKey.Text;
input.BizID = "b00001";
input.mType = 9;
input.BlockchainType = 2;
redis.Publish<ReadStringInput>("API_BC_ReadString", input);
}
public class WriteStringInput : CmdInput
{
public string BStringKey { set; get; }
public string BStringValue { set; get; }
}
public class ReadStringInput : CmdInput
{
public string BStringKey { set; get; }
}
private void button11_Click(object sender, EventArgs e)
{
NewAddressInput input = new NewAddressInput();
input.BizID = "b00001";
input.mType = 11;
input.BlockchainType = 2;
input.Password = "123456";
redis.Publish<NewAddressInput>("API_BC_Create", input);
}
private void button12_Click(object sender, EventArgs e)
{
CreateERC20MonitorInput input = new CreateERC20MonitorInput();
input.Address = this.txtTokenAddress.Text.Trim();
input.ContractAddress = this.txtContractAddress.Text.Trim();
input.BizID = "b00001";
input.mType = 17;
input.BlockchainType = 2;
redis.Publish<CreateERC20MonitorInput>("API_BC_Eth_Token_AddMonitor", input);
}
private void button14_Click(object sender, EventArgs e)
{
CancelTokenMonitorInput input = new CancelTokenMonitorInput();
input.Address = this.txtTokenAddress.Text.Trim();
input.ContractAddress = this.txtContractAddress.Text.Trim();
input.BizID = "b00001";
input.mType = 18;
input.BlockchainType = 2;
redis.Publish<CancelTokenMonitorInput>("API_BC_Eth_Token_DelMonitor", input);
}
private void button13_Click(object sender, EventArgs e)
{
QueryTokenMonitorInput input = new QueryTokenMonitorInput();
input.BizID = "b00001";
input.mType = 19;
input.BlockchainType = 2;
redis.Publish<QueryTokenMonitorInput>("API_BC_Eth_Token_GetMonitorList", input);
}
private void button15_Click(object sender, EventArgs e)
{
TokenBalanceInput input = new TokenBalanceInput();
input.BizID = "b00001";
input.mType = 15;
input.BlockchainType = 2;
input.ContractAddress = this.txtContractAddress.Text.Trim();
input.Address = this.txtTokenAddress.Text.Trim();
redis.Publish<TokenBalanceInput>("API_BC_Eth_Token_Getbalance", input);
}
private void button16_Click(object sender, EventArgs e)
{
this.txtAddress.Text = this.txtAddress.Text.ToLower();
this.txtTo.Text = this.txtTo.Text.ToLower();
this.txtFrom.Text = this.txtFrom.Text.ToLower();
TransferTokenInput input = new TransferTokenInput();
input.BizID = "A0002256";
input.Id = System.Guid.NewGuid().ToString();
input.mType = 14;
input.BlockchainType = (int)BlockchainType.ETH;
input.ContractAddress = this.txtTransferTokenAddress.Text.Trim().ToLower();
input.SourceAddress = this.txtFrom.Text.Trim().ToLower();
input.PrivateKey = this.txtFromPrvKey.Text.Trim().ToLower();
input.TargetAddress = this.txtTo.Text.Trim().ToLower(); ;
input.Amount = long.Parse(this.txtAmount.Text);
//input.TradeFee = 50;
input.TradeNumber = "A123456789";
input.TradeMemo = "我是备注";
input.Timestamp = DateUtil.GetTimeStamp(DateTime.Now);
this.txtAddress.Text = this.txtAddress.Text.Trim().ToLower();
redis.Publish<TransferTokenInput>("API_BC_Eth_Token_Transfer", input);
}
}
public class TransferTokenInput : CmdInput
{
public string SourceAddress { set; get; }
public string PrivateKey { set; get; }
public string PrivatePassword { set; get; }
public string TargetAddress { set; get; }
/// <summary>
/// 合约地址
/// </summary>
public string ContractAddress { set; get; }
public BigInteger Amount { set; get; }
//public BigInteger TradeFee { set; get; }
public string TradeNumber { set; get; }
public string TradeMemo { set; get; }
}
public class TokenBalanceInput : CmdInput
{
public string ContractAddress { set; get; }
public string Address { set; get; }
/// <summary>
/// 没有使用
/// </summary>
public string PrivatePassword { set; get; }
}
public class QueryTokenMonitorInput : CmdInput
{
}
public class CancelTokenMonitorInput : CmdInput
{
public string Address { set; get; }
public string ContractAddress { set; get; }
}
public class CreateERC20MonitorInput : CmdInput
{
public string Address { set; get; }
public string ContractAddress { set; get; }
}
public class TradeTicket
{
public string Id { set; get; }
public string mType { set; get; }
public string OrderId { set; get; }
public int OrderType { set; get; }
public int TradeObjNum { set; get; }
public string BuySplit { set; get; }
public string SellSplit { set; get; }
public decimal Price { set; get; }
public decimal Amount { set; get; }
public string Timestamp { set; get; }
}
}
标签: bi
相关软件
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明


网友评论
我要评论