Java Code Examples for net.bither.bitherj.core.Tx#getOuts()

The following examples show how to use net.bither.bitherj.core.Tx#getOuts() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WalletUtils.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
public static boolean isInternal(@Nonnull final Tx tx) {
    if (tx.isCoinBase()) {
        return false;
    }

    final List<Out> outputs = tx.getOuts();
    if (outputs.size() != 1) {
        return false;
    }

    try {
        final Out output = outputs.get(0);
        final Script scriptPubKey = output.getScriptPubKey();
        if (!scriptPubKey.isSentToRawPubKey()) {
            return false;
        }

        return true;
    } catch (final ScriptException x) {
        return false;
    }
}
 
Example 2
Source File: WalletUtils.java    From bither-android with Apache License 2.0 6 votes vote down vote up
public static boolean isInternal(@Nonnull final Tx tx) {
    if (tx.isCoinBase()) {
        return false;
    }

    final List<Out> outputs = tx.getOuts();
    if (outputs.size() != 1) {
        return false;
    }

    try {
        final Out output = outputs.get(0);
        final Script scriptPubKey = output.getScriptPubKey();
        if (!scriptPubKey.isSentToRawPubKey()) {
            return false;
        }

        return true;
    } catch (final ScriptException x) {
        return false;
    }
}
 
Example 3
Source File: WalletUtils.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
public static boolean isInternal(@Nonnull final Tx tx) {
    if (tx.isCoinBase()) {
        return false;
    }

    final List<Out> outputs = tx.getOuts();
    if (outputs.size() != 1) {
        return false;
    }

    try {
        final Out output = outputs.get(0);
        final Script scriptPubKey = output.getScriptPubKey();
        if (!scriptPubKey.isSentToRawPubKey()) {
            return false;
        }

        return true;
    } catch (final ScriptException x) {
        return false;
    }
}
 
Example 4
Source File: TxProvider.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
private void addTxToDb(Connection conn, Tx txItem) throws SQLException {
    HashSet<String> addressSet = AbstractDb.hdAccountProvider.
            getBelongAccountAddresses(txItem.getOutAddressList());
    for (Out out : txItem.getOuts()) {
        if (addressSet.contains(out.getOutAddress())) {
            out.setHDAccountId(AddressManager.getInstance().getHdAccount().getHdSeedId());
        }
    }
    insertTx(conn, txItem);
    List<AddressTx> addressesTxsRels = new ArrayList<AddressTx>();
    List<AddressTx> temp = insertIn(conn, txItem);
    if (temp != null && temp.size() > 0) {
        addressesTxsRels.addAll(temp);
    }
    temp = insertOut(conn, txItem);
    if (temp != null && temp.size() > 0) {
        addressesTxsRels.addAll(temp);
    }
    PreparedStatement statement;
    for (AddressTx addressTx : addressesTxsRels) {
        String sql = "insert or ignore into addresses_txs(address, tx_hash) values(?,?)";
        statement = conn.prepareStatement(sql);
        statement.setString(1, addressTx.getAddress());
        statement.setString(2, addressTx.getTxHash());
        statement.executeUpdate();
        statement.close();

    }

}
 
Example 5
Source File: TxProvider.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
private void addTxToDb(Connection conn, Tx txItem) throws SQLException {
    HashSet<String> addressSet = AbstractDb.hdAccountProvider.
            getBelongAccountAddresses(txItem.getOutAddressList());
    for (Out out : txItem.getOuts()) {
        if (addressSet.contains(out.getOutAddress())) {
            out.setHDAccountId(AddressManager.getInstance().getHdAccount().getHdSeedId());
        }
    }
    insertTx(conn, txItem);
    List<AddressTx> addressesTxsRels = new ArrayList<AddressTx>();
    List<AddressTx> temp = insertIn(conn, txItem);
    if (temp != null && temp.size() > 0) {
        addressesTxsRels.addAll(temp);
    }
    temp = insertOut(conn, txItem);
    if (temp != null && temp.size() > 0) {
        addressesTxsRels.addAll(temp);
    }
    PreparedStatement statement;
    for (AddressTx addressTx : addressesTxsRels) {
        String sql = "insert or ignore into addresses_txs(address, tx_hash) values(?,?)";
        statement = conn.prepareStatement(sql);
        statement.setString(1, addressTx.getAddress());
        statement.setString(2, addressTx.getTxHash());
        statement.executeUpdate();
        statement.close();

    }

}