All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bitcoinj.governance.GovernancePayment Maven / Gradle / Ivy

There is a newer version: 21.1.2
Show newest version
package org.bitcoinj.governance;

import org.bitcoinj.core.Address;
import org.bitcoinj.core.Coin;
import org.bitcoinj.script.Script;
import org.bitcoinj.script.ScriptBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *   Governance Object Payment
 *
 */

public class GovernancePayment {

    private static final Logger log = LoggerFactory.getLogger(GovernancePayment.class);

    private boolean fValid;

    public Script script;
    public Coin nAmount;

    public GovernancePayment() {
        this.fValid = false;
        this.script = null;
        this.nAmount = Coin.ZERO;
    }

    public GovernancePayment(Address addrIn, Coin nAmountIn) {
        this.fValid = false;
        this.script = null;
        this.nAmount = Coin.ZERO;
        try {
            script = ScriptBuilder.createOutputScript(addrIn);
            nAmount = Coin.valueOf(nAmountIn.getValue());
            fValid = true;
        } catch (Exception e) {
            log.info("CGovernancePayment Payment not valid: addrIn = {}, nAmountIn = {}, what = {}", addrIn.toString(), nAmountIn, e.getMessage());
        }
    }

    public final boolean isValid() {
        return fValid;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy