Estoy tratando de desarrollar una aplicación usando bitcoinj
la biblioteca. Quiero obtener los bitcoin transaction
detalles.
Los detalles, que quiero extraer de un transaction
incluye lo siguiente.
1) Quien me envía el transaction
( Address
y Public Key
del remitente).
2) La cantidad que recibí.
3) Cuándo fue transaction
emitido.
4) Obtener los datos almacenados en la transacción en formato OP_RETURN
.
tal vez esto ayude
private void txHistory()
{
List<Transaction> txx = kit.wallet().getTransactionsByTime();
if (!txx.isEmpty())
{
int i = 1;
for (Transaction tx : txx)
{
System.out.println(i + " ________________________");
System.out.println("Date and Time: " + tx.getUpdateTime().toString());
System.out.println("From Address: " + tx.getOutput(1).getAddressFromP2PKHScript(params));
System.out.println("To Address: " + tx.getOutput(0).getAddressFromP2PKHScript(params));
System.out.println("Amount Sent to me: " + tx.getValueSentToMe(kit.wallet()).toFriendlyString());
System.out.println("Amount Sent from me: " + tx.getValueSentFromMe(kit.wallet()).toFriendlyString());
long fee = (tx.getInputSum().getValue() > 0 ? tx.getInputSum().getValue() - tx.getOutputSum().getValue() : 0);
System.out.println("Fee: " + Coin.valueOf(fee).toFriendlyString());
System.out.println("Transaction Depth: " + tx.getConfidence().getDepthInBlocks());
System.out.println("Transaction Blocks: " + tx.getConfidence().toString());
System.out.println("Tx Hex: " + tx.getHashAsString());
System.out.println("Tx: " + tx.toString());
i++;
}
}
else
{
System.err.println("No Transaction Found");
}
}
muro