所以在我的应用程序中,我有以下接收比特币的功能
kit.wallet().addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() {
@Override
public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {
txtLog.append("-----> coins resceived: " + tx.getHashAsString() + "\n");
txtLog.append("received: " + tx.getValue(wallet) + "\n");
Futures.addCallback(tx.getConfidence().getDepthFuture(1), new FutureCallback<TransactionConfidence>() {
@Override
public void onSuccess(TransactionConfidence result) {
txtLog.append("\nSuccess! Recieved: " + tx.getValue(wallet) + "\n");
//Find address of sender here
}
@Override
public void onFailure(Throwable t) {
throw new RuntimeException(t);
}
});
}
});
这很好用,一旦交易被确认并添加到我的钱包中,OnSuccess 就会正确触发。txtLog 只是我的 java 框架中的一个 textArea,它为我显示一些文本输出。我现在需要做的是在这一点上找到发件人的地址,我可以用 Transaction 对象 tx 做到这一点吗?任何帮助,将不胜感激。