-
Notifications
You must be signed in to change notification settings - Fork 4
API Documentation
- request_server_info
- request_ledger_closed
- request_ledger
- request_account_info
- request_tx
- request_account_tums
- request_account_relations
- request_account_offer
- request_account_tx
- request_order_book
- request_brokerage
- pay
- set_relation
- create_offer
- cancel_offer
Returns the current server status.
(MUST) Config - struct Config is including server address and local sign flag.
let addr: &str = "ws://192.x.x.123:5060";
let flag: bool = true;
Ok(ServerInfoResponse) - The current server status.
Example
extern crate jlib;
use jlib::misc::config::*;
use jlib::api::query::server_info::*;
fn main() {
let config = Config::new(TEST1, true);
ServerInfo::new().request_server_info(config.clone(), |x| match x {
Ok(response) => {
println!("build_version : {:?}", response.build_version);
}
Err(_) => {
}
});
}
Returns the current ledger hash and index.
(MUST) Config - struct Config is including server address and local sign flag.
let addr: &str = "ws://192.x.x.123:5060";
let flag: bool = true;
Ok(LedgerClosedResponse) - The current ledger hash and index.
Err(LedgerClosedSideKick) - LedgerClosed Error info.
Example
extern crate jlib;
use jlib::misc::config::*;
use jlib::api::query::ledger_closed::*;
use jlib::message::query::ledger_closed::{LedgerClosedResponse, LedgerClosedSideKick};
fn main() {
let config = Config::new(TEST1, true);
println!("config : {:?}", config);
let _c = LedgerClosed::new().request_ledger_closed(config.clone(), |x| match x {
Ok(response) => {
let res: LedgerClosedResponse = response;
println!("----------------------------------------------------------------------------------");
println!("最新账本信息 : ");
println!("-- 账本Hash : {}", &res.ledger_hash);
println!("-- 账本Index: {}", &res.ledger_index);
println!("----------------------------------------------------------------------------------");
}
Err(e) => {
let err: LedgerClosedSideKick = e;
println!("{:?}", err);
}
});
}
Returns specific ledger info.
(Must) Config - struct Config is including server address and local sign flag.
(Option) ledger_index - Option<u64>, specific ledger index.
(Option) ledger_hash - Option<String>, specific ledger hash.
(Must) transactions - bool, return previous ledger transactions list.
let addr: &str = "ws://192.x.x.123:5060";
let flag: bool = true;
let ledger_index: Option<u64> = Some(9999);
let ledger_hash: Option<String> = None;
let transactions: bool = false;
Ok(RequestLedgerResponse) - The specific ledger info.
Err(SpecLedgerSideKick) - The specific ledger Error info.
Example
extern crate jlib;
use jlib::misc::config::*;
use jlib::api::query::spec_ledger::*;
use jlib::message::query::spec_ledger::{RequestLedgerResponse, SpecLedgerSideKick};
fn main() {
let config = Config::new(TEST1, true);
let ledger_index = 88670;
let ledger_hash = None;
let return_prev_tx_list = false;
SpecLedger::new().request_ledger(config.clone(), Some(ledger_index), ledger_hash, return_prev_tx_list, |x| match x {
Ok(response) => {
let res: RequestLedgerResponse = response;
println!("账本具体信息: \n{:?}", &res);
},
Err(e) => {
let err: SpecLedgerSideKick = e;
println!("err: {:?}", err);
}
});
}
Returns specific account info.
(Must) Config - struct Config is including server address and local sign flag.
(Must) account - String, the specific account.
let addr: &str = "ws://192.x.x.123:5060";
let flag: bool = true;
let account: String = "j....".to_string();
Ok(RequestAccountInfoResponse) - The specific account info.
Err(AccounInfoSideKick) - The specific account Error info.
Example
extern crate jlib;
use jlib::misc::config::*;
use jlib::api::query::account_info::*;
use jlib::message::query::account_info::{RequestAccountInfoResponse, AccounInfoSideKick};
fn main() {
let config = Config::new(TEST1, true);
let account = "j...Z".to_string();
AccountInfo::new().request_account_info(config.clone(), account, |x| match x {
Ok(response) => {
let res: RequestAccountInfoResponse = response;
println!("账号信息: \n{:?}", &res);
},
Err(e) => {
let err: AccounInfoSideKick = e;
println!("{:?}", err);
}
});
}
Returns specific tx info.
(Must) Config - struct Config is including server address and local sign flag.
(Must) tx_hash - String, the specific tx hash.
let addr: &str = "ws://192.x.x.123:5060";
let flag: bool = true;
let tx_hash: String = "4552D9C58078855888A966F4FEE4FA46C413211A96C3174A7980651106C4E2DA".to_string();
Ok(RequestTxResponse) - The specific tx info.
Err(SpecTxSideKick) - The specific tx Error info.
Example
extern crate jlib;
use jlib::misc::config::*;
use jlib::api::query::spec_tx::*;
use jlib::message::query::spec_tx::{RequestTxResponse, SpecTxSideKick};
fn main() {
let config = Config::new(TEST1, true);
let tx_hash = "4552D9C58078855888A966F4FEE4FA46C413211A96C3174A7980651106C4E2DA".to_string();
SpecTx::new().request_tx(config.clone(), tx_hash, |x| match x {
Ok(response) => {
let res: RequestTxResponse = response;
println!("交易具体信息: \n{:?}", &res);
},
Err(e) => {
let err: SpecTxSideKick = e;
println!("err: {:?}", err);
}
});
}
Returns specific account available received currency and sent currency.
(Must) Config - struct Config is including server address and local sign flag.
(Must) account - String, the specific account.
let addr: &str = "ws://192.x.x.123:5060";
let flag: bool = true;
let account: String = "j....".to_string();
Ok(RequestAccountTumsResponse) - The specific account available currencies info.
Err(AccounTumSideKick) - The specific account Error info.
Example
extern crate jlib;
use jlib::misc::config::*;
use jlib::api::query::account_tums::*;
use jlib::message::query::account_tums::{RequestAccountTumsResponse, AccounTumSideKick};
fn main() {
let config = Config::new(TEST1, true);
let account = "j...Z".to_string();
AccountTums::new().request_account_tums(config.clone(), account, |x| match x {
Ok(response) => {
let res: RequestAccountTumsResponse = response;
println!("可接收和发送的货币: \n{:?}", &res);
},
Err(e) => {
let err: AccounTumSideKick = e;
println!("err: {:?}", err);
}
});
}
Returns specific account's relations.
(Must) Config - struct Config is including server address and local sign flag.
(Must) account - String, the specific account.
(MUST) rtype - String, including (trust)/(authorize)/(freeze).
let addr: &str = "ws://192.x.x.123:5060";
let flag: bool = true;
let account: String = "j....".to_string();
let rtype: String = "trust".to_string();
Ok(RequestAccountRelationsResponse) - The specific account's relations info.
Err(RelationsSideKick) - The specific account Error info.
Example
extern crate jlib;
use jlib::misc::config::*;
use jlib::api::query::relations::*;
use jlib::message::query::relations::{RequestAccountRelationsResponse, RelationsSideKick};
fn main() {
let config = Config::new(TEST1, true);
let account = "j...Z".to_string();
let rtype = Some("trust".to_string());
Relations::new().request_account_relations(config.clone(), account, rtype, |x| match x {
Ok(response) => {
let res: RequestAccountRelationsResponse = response;
println!("账号关系: {:?}", &res);
},
Err(e) => {
let err: RelationsSideKick= e;
println!("err: {:?}", err);
}
});
}
Returns specific account's offers.
(Must) Config - struct Config is including server address and local sign flag.
(Must) account - String, the specific account.
let addr: &str = "ws://192.x.x.123:5060";
let flag: bool = true;
let account: String = "j....".to_string();
Ok(RequestAccountOfferResponse) - The specific account's offers.
Err(AccountOffersSideKick) - The specific account Error info.
Example
extern crate jlib;
use jlib::misc::config::*;
use jlib::api::query::account_offer::*;
use jlib::message::query::offer::{RequestAccountOfferResponse, AccountOffersSideKick};
fn main() {
let config = Config::new(TEST1, true);
let account = "jB7rxgh43ncbTX4WeMoeadiGMfmfqY2xLZ".to_string();
AccountOffer::new().request_account_offer(config.clone(), account, |x| match x {
Ok(response) => {
let res: RequestAccountOfferResponse = response;
println!("账号挂单: {:?}", &res);
},
Err(e) => {
let err: AccountOffersSideKick = e;
println!("err: {:?}", err);
}
});
}
Returns specific account's all transactions.
(Must) Config - struct Config is including server address and local sign flag.
(Must) account - String, the specific account.
let addr: &str = "ws://192.x.x.123:5060";
let flag: bool = true;
let account: String = "j....".to_string();
Ok(RequestAccountTxResponse) - The specific account's offers.
Err(AccounTxSideKick) - The specific account Error info.
Example
extern crate jlib;
use jlib::misc::config::*;
use jlib::api::query::account_tx::*;
//Ok && Err
use jlib::message::query::account_tx::{RequestAccountTxResponse, AccounTxSideKick};
fn main() {
let config = Config::new(TEST1, true);
let account = "j...Z".to_string();
AccountTx::new().request_account_tx(config.clone(), account, Some(1), |x| match x {
Ok(response) => {
let res: RequestAccountTxResponse = response;
println!("账号交易列表: \n{:?}", &res);
},
Err(e) => {
let err: AccounTxSideKick = e;
println!("交易 Error : \n{:?}", err);
}
});
}
Returns specific order books.
(Must) Config - struct Config is including server address and local sign flag.
(Must) taker_gets - OrderBookItem, taker gets.
(Must) taker_pays - OrderBookItem, taker pays.
let addr: &str = "ws://192.x.x.123:5060";
let flag: bool = true;
let gets = OrderBookItem::with_params("SWT".to_string(), "".to_string());
let pays = OrderBookItem::with_params("CNY".to_string(), "j...S".to_string());
pub struct OrderBookItem {
pub currency: String,
pub issuer: String,
}
Ok(RequestOrderBookResponse) - The specific order books.
Err(OrderBookSideKick) - The specific order books Error info.
Example
extern crate jlib;
use jlib::misc::config::*;
use jlib::api::query::order_book::*;
use jlib::message::query::order_book::{RequestOrderBookResponse, OrderBookItem, OrderBookSideKick};
fn main() {
let config = Config::new(TEST1, true);
let gets = OrderBookItem::with_params("SWT".to_string(), "".to_string());
let pays = OrderBookItem::with_params("CNY".to_string(), "j...S".to_string());
OrderBook::new().request_order_book(config.clone(), gets, pays, |x| match x {
Ok(response) => {
let res: RequestOrderBookResponse = response;
println!("挂单列表: {:?}", &res);
},
Err(e) => {
let err: OrderBookSideKick = e;
println!("err: {:?}", err);
}
});
}
Returns brokerage info.
(Must) Config - struct Config is including server address and local sign flag.
(Must) issuer - String, the specific issuer.
(Must) app_type - u64, app source.
(Must) currency - String, the specific currency.
let addr: &str = "ws://192.x.x.123:5060";
let flag: bool = true;
let issuer: String = "j....".to_string();
let app_type: u64 = 1;
let currency: String = "TES".to_string();
Ok(RequestBrokerageResponse) - The specific brokerage info.
Err(BrokerageSideKick) - The specific brokerage Error info.
Example
extern crate jlib;
use jlib::misc::config::*;
use jlib::api::query::brokerage::*;
use jlib::message::query::brokerage::{RequestBrokerageResponse, BrokerageSideKick};
fn main() {
let config = Config::new(TEST1, true);
let issuer: String = "j....".to_string();
let app_type: u64 = 1;
let currency: String = "TES".to_string();
Brokerage::new().request_brokerage(config.clone(), issuer, app_type, currency, |x| match x {
Ok(response) => {
let res: RequestBrokerageResponse = response;
println!("佣金设置信息: {:?}", &res);
},
Err(e) => {
let err: BrokerageSideKick = e;
println!("err: {:?}", err);
}
});
}
Send certain currency to another account id.
(Must) Config - struct Config is including server address and local sign flag.
(Must) from - String, source account id.
(Must) secret - String, source account's secret.
(Must) to - String, target account id.
(Must) amount - Amount
(Option) memo - Option, memo.
let config = Config::new(TEST1, true);
let amount: Amount = Amount::new("SWT".to_string(), "0.5".to_string(), "".to_string());
let from: String = "j...Z".to_string();
let secret:String= "s...d".to_string();
let to : String = "j...c".to_string();
let memo: Option<String> = Some("TTTTTTTTTTTTTTTTTTTTTis memo".to_string());
pub struct Amount {
pub value: String,
pub currency: Option<String>,
pub issuer: Option<String>,
}
Ok(TransactionTxResponse) - The payment transaction info.
Err(PaymentSideKick) - The payment trasaction Error info.
Example
extern crate jlib;
use jlib::misc::config::*;
use jlib::message::transaction::transaction::{TransactionTxResponse, PaymentSideKick};
use jlib::api::transaction::pay::*;
use jlib::message::common::amount::Amount;
fn main() {
let config = Config::new(TEST1, true);
let from: String = "j...Z".to_string();
let secret:String= "s...d".to_string();
let to : String = "j...c".to_string();
let memo: Option<String> = Some("TTTTTTTTTTTTTTTTTTTTTis memo".to_string());
let amount: Amount = Amount::new("SWT".to_string(), "0.5".to_string(), "".to_string());
Payment::with_params(config.clone(), from, secret).payment( to, amount, memo,
|x| match x {
Ok(response) => {
let res: TransactionTxResponse = response;
println!("支付信息: {:?}", &res);
},
Err(e) => {
let err: PaymentSideKick = e;
println!("err: {:?}", err);
}
});
}
set account's relation.
(Must) Config - struct Config is including server address and local sign flag.
(Must) account - String, source account id.
(Must) secret - String, source account's secret.
(Must) rtype - u64, relation type.
(Must) target - String, target account id (only if type is authorize and freeze!).
(Must) amount - Amount
let addr: &str = "ws://192.x.x.123:5060";
let flag: bool = true;
let from: String = "j...Z".to_string();
let secret:String= "s...d".to_string();
let relation_type = AUTHORIZE;
let to : String = "j...c".to_string();
let amount: Amount = Amount::new("CCA".to_string(), "0.01".to_string(), "j...u".to_string());
pub struct Amount {
pub value: String,
pub currency: Option<String>,
pub issuer: Option<String>,
}
Ok(RelationTxResponse) - The specific relation info.
Err(RelationSideKick) - The specific relation Error info.
Example
extern crate jlib;
use jlib::misc::config::*;
use jlib::message::transaction::relation::{RelationTxResponse, RelationSideKick};
use jlib::api::transaction::relate::*;
use jlib::message::common::amount::Amount;
use jlib::RelationType::AUTHORIZE;
fn main() {
let config = Config::new(TEST1, true);
let from: String = "jB7rxgh43ncbTX4WeMoeadiGMfmfqY2xLZ".to_string();
let secret:String= "sn37nYrQ6KPJvTFmaBYokS3FjXUWd".to_string();
let relation_type = AUTHORIZE;
let to : String = "jDUjqoDZLhzx4DCf6pvSivjkjgtRESY62c".to_string();
let amount: Amount = Amount::new("CCA".to_string(), "0.01".to_string(), "js7M6x28mYDiZVJJtfJ84ydrv2PthY9W9u".to_string());
Relate::with_params(config.clone(), from, secret)
.set_relation(relation_type, to, amount,
|x| match x {
Ok(response) => {
let res: RelationTxResponse = response;
println!("关系设置: {:?}", &res);
},
Err(e) => {
let err: RelationSideKick = e;
println!("err: {:?}", err);
}
});
}
create offer.
(Must) Config - struct Config is including server address and local sign flag.
(Must) account - String, source account id.
(Must) secret - String, source account's secret.
(Must) taker_gets - Amount
(Must) taker_pays - Amount
let addr: &str = "ws://192.x.x.123:5060";
let flag: bool = true;
let taker_gets: Amount = Amount::new("CNY".to_string(), "0.01".to_string(), "j..h".to_string());
let taker_pays: Amount = Amount::new("SWT".to_string(), "1".to_string(), "".to_string());
let account: String = "j..h".to_string();
let secret:String= "s..i".to_string();
pub struct Amount {
pub value: String,
pub currency: Option<String>,
pub issuer: Option<String>,
}
Ok(OfferCreateTxResponse) - succuess info.
Err(OfferCreateSideKick) - error info.
Example
extern crate jlib;
use jlib::misc::config::*;
use jlib::message::common::amount::Amount;
use jlib::api::transaction::create_offer::*;
use jlib::message::transaction::offer_create::{OfferCreateTxResponse, OfferCreateSideKick};
fn main() {
let config = Config::new(TEST1, true);
//Sell
let taker_gets: Amount = Amount::new("CNY".to_string(), "0.01".to_string(), "j...h".to_string());
let taker_pays: Amount = Amount::new("SWT".to_string(), "1".to_string(), "".to_string());
let account: String = "j..h".to_string();
let secret:String= "s...i".to_string();
CreateOffer::with_params(config.clone(), account, secret).create_offer( taker_gets, taker_pays,
|x| match x {
Ok(response) => {
let res: OfferCreateTxResponse = response;
let fee = res.tx_json.fee.parse::<f32>().unwrap() / 1000000f32;
println!("[交易费: {}]", fee);
},
Err(e) => {
let err: OfferCreateSideKick = e;
println!("err: {:?}", err);
}
});
}
cancel specific offer.
(Must) Config - struct Config is including server address and local sign flag.
(Must) account - String, source account id.
(Must) secret - String, source account's secret.
(Must) offer_sequence - u64
let addr: &str = "ws://192.x.x.123:5060";
let flag: bool = true;
let account: String = "j..h".to_string();
let secret:String= "s..i".to_string();
let offer_sequence: u64 = 688_u64;
Ok(OfferCancelTxResponse) - succuess info.
Err(OfferCancelSideKick) - error info.
Example
extern crate jlib;
use jlib::misc::config::*;
use jlib::api::transaction::cancel_offer::*;
use jlib::message::transaction::offer_cancel::{OfferCancelTxResponse, OfferCancelSideKick};
fn main() {
let config = Config::new(TEST1, true);
let account: String = "j...Z".to_string();
let secret:String= "s...d".to_string();
let offer_sequence: u64 = 688_u64;
CancelOffer::with_params(config.clone(), account, secret).cancel_offer( offer_sequence,
|x| match x {
Ok(response) => {
let res: OfferCancelTxResponse = response;
println!("取消挂单: {:?}", &res);
},
Err(e) => {
let err: OfferCancelSideKick = e;
println!("err: {:?}", err);
}
});
}