Java 如何在收到交易后在BitcoinJ中查找发件人比特币地址

Java 如何在收到交易后在BitcoinJ中查找发件人比特币地址,java,bitcoin,bitcoinj,Java,Bitcoin,Bitcoinj,因此,在我的应用程序中,我有以下接收比特币的功能 kit.wallet().addCoinsReceivedEventListener(new WalletCoinsReceivedEventListener() { @Override public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {

因此,在我的应用程序中,我有以下接收比特币的功能

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);
                }
            });
        }
    });
kit.wallet().addCoinsReceivedEventListener(新WalletCoinsReceivedEventListener()){
@凌驾
收到的公共空白(钱包、交易发送、硬币预存余额、硬币新余额){
append(“--->coins reseceived:”+tx.gethassaString()+“\n”);
txtLog.append(“接收:”+tx.getValue(钱包)+“\n”);
Futures.addCallback(tx.getConfidence().getDepthFuture(1),new FutureCallback(){
@凌驾
成功时公开作废(交易信任结果){
txtLog.append(“\nsaccess!received:”+tx.getValue(wallet)+“\n”);
//在此查找发件人地址
}
@凌驾
失效时的公共无效(可丢弃的t){
抛出新的运行时异常(t);
}
});
}
});

这非常有效,一旦交易被确认并添加到我的钱包中,OnSuccess就会正确触发。txtLog只是java框架中的一个文本区域,它为我显示一些文本输出。我现在需要做的是在这一点上找到发送者的地址,我可以用事务对象tx来完成吗?任何帮助都将不胜感激。

找到了解决方案!不幸的是,它使用了折旧法。我只是在适当的位置添加了以下内容

String address = "";
for (TransactionInput txin : tx.getInputs()){
    address = txin.getFromAddress().toString();
}