Add a tool to watch for broadcasts of rotation transactions.

This commit is contained in:
Mike Hearn 2013-08-13 14:08:30 +02:00
parent 3857b0ae05
commit de9d5e95ab

View file

@ -0,0 +1,32 @@
package com.google.bitcoin.tools;
import com.google.bitcoin.core.*;
import com.google.bitcoin.discovery.DnsDiscovery;
import com.google.bitcoin.params.MainNetParams;
import com.google.bitcoin.utils.BriefLogFormatter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class WatchMempool {
private static Logger log = LoggerFactory.getLogger(WatchMempool.class);
public static void main(String[] args) {
BriefLogFormatter.init();
NetworkParameters params = MainNetParams.get();
PeerGroup peerGroup = new PeerGroup(params);
peerGroup.addPeerDiscovery(new DnsDiscovery(params));
peerGroup.addEventListener(new AbstractPeerEventListener() {
@Override
public void onTransaction(Peer peer, Transaction tx) {
try {
if (tx.getOutputs().size() != 1) return;
if (!tx.getOutput(0).getScriptPubKey().isSentToRawPubKey()) return;
log.info("Saw raw pay to pubkey {}", tx);
} catch (ScriptException e) {
e.printStackTrace();
}
}
});
peerGroup.start();
}
}