// Query a transaction with transaction id /// <param name="txid">transaction id</param> /// <return>the request response, Data is a Transaction type</return> public Response QueryTx(string bcname, string txid) { var response = new Response() { Error = new XChainError() { ErrorCode = Errors.Success, ErrorMessage = "Success", } }; var req = new Pb.TxStatus { Header = GetDefaultHeader(), Bcname = bcname, Txid = ByteString.CopyFrom(XConvert.HexStringToByteArray(txid)), }; var tx = client.QueryTx(req); if (tx == null || tx.Header.Error != Pb.XChainErrorEnum.Success) { Console.WriteLine("query tx failed. errcode=" + (int)tx.Header.Error + ", logid=" + req.Header.Logid); return(null); } response.Data = XConvert.PbTxToLocalTx(tx.Tx); return(response); }
private Pb.CommonReply PostTx(string bcname, Transaction tx) { var pbtx = XConvert.LocalTxToPbTx(tx); var reqTx = new Pb.TxStatus { Txid = pbtx.Txid, Tx = pbtx, Bcname = bcname, }; var postRes = client.PostTx(reqTx); if (postRes.Header.Error != Pb.XChainErrorEnum.Success) { Console.WriteLine("post tx failed, txid=" + tx.Txid + " err=" + (int)postRes.Header.Error); return(null); } return(postRes); }