// Path: opentipbot-json-rpc-client/src/main/java/opentipbot/jsonrpcclient/Bitcoin.java
// public static interface Transaction {
//     public String account();
//     public String address();
//     public String category();
//     public double amount();
//     public double fee();
//     public int confirmations();
//     public String blockHash();
//     public int blockIndex();
//     public Date blockTime();
//     public String txId();
//     public Date time();
//     public Date timeReceived();
//     public String comment();
//     public String commentTo();
//         
//     public RawTransaction raw();
// }


import java.util.Set;
import opentipbot.jsonrpcclient.Bitcoin.Transaction;
import java.util.Collections;
import java.util.HashSet;
/*
 * Copyright (c) 2013, Mikhail Yevchenko. All rights reserved. PROPRIETARY/CONFIDENTIAL.
 */
package opentipbot.jsonrpcclient;


/**
 *
 * @author Gilles Cadignan
 */
public abstract class ConfirmedPaymentListener extends SimpleBitcoinPaymentListener {

    public int minConf;

    public ConfirmedPaymentListener(int minConf) {
        this.minConf = minConf;
    }

    public ConfirmedPaymentListener() {
        this(6);
    }

    protected Set<String> processed = Collections.synchronizedSet(new HashSet<String>());

    protected boolean markProcess(String txId) {
        return processed.add(txId);
    }

    @Override
    public void transaction(Transaction transaction) {
        if (transaction.confirmations() < minConf)
            return;
        if (!markProcess(transaction.txId()))
            return;
        confirmed(transaction);
    }

// Path: opentipbot-json-rpc-client/src/main/java/opentipbot/jsonrpcclient/Bitcoin.java
// public static interface Transaction {
//     public String account();
//     public String address();
//     public String category();
//     public double amount();
//     public double fee();
//     public int confirmations();
//     public String blockHash();
//     public int blockIndex();
//     public Date blockTime();
//     public String txId();
//     public Date time();
//     public Date timeReceived();
//     public String comment();
//     public String commentTo();
//         
//     public RawTransaction raw();
// }


// Path: opentipbot-json-rpc-client/src/main/java/opentipbot/jsonrpcclient/ConfirmedPaymentListener.java
import java.util.Set;
import opentipbot.jsonrpcclient.Bitcoin.Transaction;
import java.util.Collections;
import java.util.HashSet;

/*
 * Copyright (c) 2013, Mikhail Yevchenko. All rights reserved. PROPRIETARY/CONFIDENTIAL.
 */
package opentipbot.jsonrpcclient;


/**
 *
 * @author Gilles Cadignan
 */
public abstract class ConfirmedPaymentListener extends SimpleBitcoinPaymentListener {

    public int minConf;

    public ConfirmedPaymentListener(int minConf) {
        this.minConf = minConf;
    }

    public ConfirmedPaymentListener() {
        this(6);
    }

    protected Set<String> processed = Collections.synchronizedSet(new HashSet<String>());

    protected boolean markProcess(String txId) {
        return processed.add(txId);
    }

    @Override
    public void transaction(Transaction transaction) {
        if (transaction.confirmations() < minConf)
            return;
        if (!markProcess(transaction.txId()))
            return;
        confirmed(transaction);
    }

    public abstract void confirmed(Transaction transaction);