How to get destination address from bitcoinj TransactionOutput?

2

I believe TransactionOutput represents one of the outputs of a transaction.

I have a list of such output objects, and a String that represents my own address. I would like to check that this output reached my address.

How do I get the destination address from the TransactionOutput object?

ripper234

Posted 2011-12-31T18:12:50.597

Reputation: 25 192

Answers

2

TransactionOutput.getScriptPubKey.getToAddress.toString

Unfortunately, this gives an exception when dealing with an oldstyle pay-to-IP script, so you might have to deal with these yourself if you need them (which in your use case you probably won't). An example can be found in the Scala code from the link below (from line 120 on):

https://github.com/stefanwouldgo/Bitcoin-Graph-Explorer/blob/master/src/main/scala/Graph.scala

stefanwouldgo

Posted 2011-12-31T18:12:50.597

Reputation: 579