mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-02-22 14:22:45 +01:00
Add a tool to watch for broadcasts of rotation transactions.
This commit is contained in:
parent
3857b0ae05
commit
de9d5e95ab
1 changed files with 32 additions and 0 deletions
|
@ -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();
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue