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

org.tbk.electrum.bitcoinj.model.SimpleBitcoinjUtxos Maven / Gradle / Ivy

The newest version!
package org.tbk.electrum.bitcoinj.model;

import com.google.common.collect.ImmutableList;
import lombok.Builder;
import lombok.Singular;
import lombok.Value;
import org.bitcoinj.core.Coin;

import java.util.Collections;
import java.util.List;

@Value
@Builder
public class SimpleBitcoinjUtxos implements BitcoinjUtxos {

    public static BitcoinjUtxos empty() {
        return SimpleBitcoinjUtxos.builder()
                .utxos(Collections.emptyList())
                .build();
    }

    @Singular("addUtxo")
    List utxos;

    @Override
    public List getUtxos() {
        return ImmutableList.copyOf(utxos);
    }

    @Override
    public boolean isEmpty() {
        return utxos.isEmpty();
    }

    @Override
    public Coin getValue() {
        return utxos.stream()
                .map(BitcoinjUtxo::getValue)
                .reduce(Coin.ZERO, Coin::add);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy