首页 / JAVA / java-恒星支付查询
java-恒星支付查询
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了java-恒星支付查询,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2615字,纯文字阅读大概需要4分钟。
内容图文
![java-恒星支付查询](/upload/InfoBanner/zyjiaocheng/696/571477fe5afd47f08bba3ed800e220b8.jpg)
我无法在官方网站上执行示例付款查询程序.这是我的代码,与示例几乎相同.这是official website.
public class TransCheck {
public static void main(String args[]) {
Server server = new Server("https://horizon-testnet.stellar.org");
KeyPair account = KeyPair.fromAccountId("GARUMRUP37CPOGQQALSXBDQQS6SUDDPKGLGFERH6PIJEHWQY5IAVZQDL");
// Create an API call to query payments involving the account.
// server.payments() Returns PaymentsRequestBuilder instance.
// forAccount() Builds request to GET /accounts/{account}/payments - Account for which to get payments
PaymentsRequestBuilder paymentsRequest = server.payments().forAccount(account);
// If some payments have already been handled, start the results from the
// last seen payment. (See below in `handlePayment` where it gets saved.)
String lastToken = loadLastPagingToken();
if (lastToken != null) {
paymentsRequest.cursor(lastToken);
}
// `stream` will send each recorded payment, one by one, then keep the
// connection open and continue to send you new payments as they occur.
paymentsRequest.stream(new EventListener <OperationResponse>(){
@Override
public void onEvent(OperationResponse payment) {
// Record the paging token so we can start from here next time.
savePagingToken(payment.getPagingToken());
// The payments stream includes both sent and received payments. We only
// want to process received payments here.
if (payment instanceof PaymentOperationResponse) {
if (((PaymentOperationResponse) payment).getTo().equals(account)) {
return;
}
String amount = ((PaymentOperationResponse) payment).getAmount();
Asset asset = ((PaymentOperationResponse) payment).getAsset();
String assetName;
if (asset.equals(new AssetTypeNative())) {
assetName = "lumens";
} else {
StringBuilder assetNameBuilder = new StringBuilder();
assetNameBuilder.append(((AssetTypeCreditAlphaNum) asset).getCode());
assetNameBuilder.append(":");
assetNameBuilder.append(((AssetTypeCreditAlphaNum) asset).getIssuer().getAccountId());
assetName = assetNameBuilder.toString();
}
StringBuilder output = new StringBuilder();
output.append(amount);
output.append(" ");
output.append(assetName);
output.append(" from ");
output.append(((PaymentOperationResponse) payment).getFrom().getAccountId());
System.out.println(output.toString());
}
}
});
}
}
我的代码中有两个错误.首先,方法:loadLastPagingToken()未定义,我无法找到此方法的详细信息.其次,当我想创建一个新的EventListener< OperationResponse>()时,IDE告诉我
The type EventListener is not generic; it cannot be parameterized with arguments
我真的不知道为什么.请你帮助我好吗?谢谢.
解决方法:
这是因为您的导入语句.
尝试
导入org.stellar.sdk.requests.EventListener;
代替
导入java.util.EventListener;
内容总结
以上是互联网集市为您收集整理的java-恒星支付查询全部内容,希望文章能够帮你解决java-恒星支付查询所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。