Search in sources :

Example 6 with UtxoOutputPo

use of io.nuls.db.entity.UtxoOutputPo in project nuls by nuls-io.

the class TransactionResource method list.

@GET
@Path("/locked")
@Produces(MediaType.APPLICATION_JSON)
public RpcResult list(@QueryParam("address") String address, @QueryParam("pageNumber") int pageNumber, @QueryParam("pageSize") int pageSize) {
    if (!Address.validAddress(address)) {
        return RpcResult.getFailed(ErrorCode.PARAMETER_ERROR);
    }
    if (pageNumber < 0 || pageSize < 0) {
        return RpcResult.getFailed(ErrorCode.PARAMETER_ERROR);
    }
    if (pageNumber == 0) {
        pageNumber = 1;
    }
    if (pageSize == 0) {
        pageSize = 10;
    }
    // todo        ledgerService.getLockUtxo
    List<UtxoOutputPo> poList = outputDataService.getLockUtxo(address, TimeService.currentTimeMillis(), pageNumber, pageSize);
    List<OutputDto> dtoList = new ArrayList<>();
    for (UtxoOutputPo po : poList) {
        dtoList.add(new OutputDto(po));
    }
    RpcResult result = RpcResult.getSuccess();
    result.setData(dtoList);
    return result;
}
Also used : OutputDto(io.nuls.rpc.entity.OutputDto) ArrayList(java.util.ArrayList) RpcResult(io.nuls.rpc.entity.RpcResult) UtxoOutputPo(io.nuls.db.entity.UtxoOutputPo)

Example 7 with UtxoOutputPo

use of io.nuls.db.entity.UtxoOutputPo in project nuls by nuls-io.

the class UtxoTransferTool method transferCoinData.

private static void transferCoinData(Transaction tx, List<UtxoInputPo> inputPoList, List<UtxoOutputPo> outputPoList) {
    if (tx instanceof AbstractCoinTransaction) {
        AbstractCoinTransaction coinTx = (AbstractCoinTransaction) tx;
        UtxoData utxoData = new UtxoData();
        Set<String> addressSet = new HashSet<>();
        for (UtxoInputPo inputPo : inputPoList) {
            utxoData.getInputs().add(toInput(inputPo));
            addressSet.add(inputPo.getFromOutPut().getAddress());
        }
        for (int i = 0; i < outputPoList.size(); i++) {
            UtxoOutputPo outputPo = outputPoList.get(i);
            utxoData.getOutputs().add(toOutput(outputPo));
        }
        coinTx.setCoinData(utxoData);
    }
}
Also used : AbstractCoinTransaction(io.nuls.ledger.entity.tx.AbstractCoinTransaction) UtxoData(io.nuls.ledger.entity.UtxoData) UtxoInputPo(io.nuls.db.entity.UtxoInputPo) UtxoOutputPo(io.nuls.db.entity.UtxoOutputPo) HashSet(java.util.HashSet)

Aggregations

UtxoOutputPo (io.nuls.db.entity.UtxoOutputPo)7 UtxoInputPo (io.nuls.db.entity.UtxoInputPo)2 RpcResult (io.nuls.rpc.entity.RpcResult)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 NulsDigestData (io.nuls.core.chain.entity.NulsDigestData)1 NulsException (io.nuls.core.exception.NulsException)1 NulsRuntimeException (io.nuls.core.exception.NulsRuntimeException)1 UtxoOutputDataService (io.nuls.db.dao.UtxoOutputDataService)1 TxAccountRelationPo (io.nuls.db.entity.TxAccountRelationPo)1 DbSession (io.nuls.db.transactional.annotation.DbSession)1 UtxoData (io.nuls.ledger.entity.UtxoData)1 UtxoOutput (io.nuls.ledger.entity.UtxoOutput)1 AbstractCoinTransaction (io.nuls.ledger.entity.tx.AbstractCoinTransaction)1 LedgerCacheService (io.nuls.ledger.service.impl.LedgerCacheService)1 OutputDto (io.nuls.rpc.entity.OutputDto)1 ArrayList (java.util.ArrayList)1