net.bither.bitherj.core.Tx Java Examples

The following examples show how to use net.bither.bitherj.core.Tx. 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: UnSignTxPanel.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
@Override
public void success(Object obj) {
    if (obj != null && obj instanceof Tx) {
        tx = (Tx) obj;
        if (needConfirm) {
            SendBitcoinConfirmPanel confirmPanel = new SendBitcoinConfirmPanel
                    (sendConfirmListener, bitcoinAddress, changeAddress, tx);
            confirmPanel.showPanel();
        } else {
            sendConfirmListener.onConfirm(tx);
        }
    } else {
        new MessageDialog(LocaliserUtils.getString("password_wrong")).showMsg();
    }

}
 
Example #2
Source File: TxHelper.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
public static void addInsAndOuts(TxDBHelper mDb, Tx txItem) throws AddressFormatException, SQLException {
    String txHashStr = Base58.encode(txItem.getTxHash());
    txItem.setOuts(new ArrayList<Out>());
    txItem.setIns(new ArrayList<In>());
    String sql = "select * from ins where tx_hash=? order by in_sn";
    PreparedStatement statement = mDb.getPreparedStatement(sql, new String[]{txHashStr});
    ResultSet c = statement.executeQuery();
    while (c.next()) {
        In inItem = TxHelper.applyCursorIn(c);
        inItem.setTx(txItem);
        txItem.getIns().add(inItem);
    }
    c.close();
    statement.close();

    sql = "select * from outs where tx_hash=? order by out_sn";
    statement = mDb.getPreparedStatement(sql, new String[]{txHashStr});
    c = statement.executeQuery();
    while (c.next()) {
        Out outItem = TxHelper.applyCursorOut(c);
        outItem.setTx(txItem);
        txItem.getOuts().add(outItem);
    }
    c.close();
    statement.close();
}
 
Example #3
Source File: CommitTransactionThread.java    From bither-android with Apache License 2.0 6 votes vote down vote up
public CommitTransactionThread(DialogProgress dp, int addressPosition, Tx tx, boolean isHDM,
                               boolean withPrivateKey, CommitTransactionListener listener)
        throws Exception {
    super(dp, dp.getContext());
    this.addressPosition = addressPosition;
    this.listener = listener;
    if (isHDM) {
        wallet = AddressManager.getInstance().getHdmKeychain().getAddresses().get
                (addressPosition);
    } else if (withPrivateKey) {
        Address a = AddressManager.getInstance().getPrivKeyAddresses().get(addressPosition);
        if (a.hasPrivKey()) {
            wallet = a;
        } else {
            throw new Exception("address not with private key");
        }
    } else {
        wallet = AddressManager.getInstance().getWatchOnlyAddresses().get(addressPosition);
    }
    this.tx = tx;
}
 
Example #4
Source File: AbstractTxProvider.java    From bitherj with Apache License 2.0 6 votes vote down vote up
public Tx getTxDetailByTxHash(byte[] txHash) {
    final Tx[] txItem = {null};
    final boolean[] txExists = {false};
    String txHashStr = Base58.encode(txHash);
    String sql = "select * from txs where tx_hash=?";
    IDb db = this.getReadDb();
    this.execQueryOneRecord(db, sql, new String[]{txHashStr}, new Function<ICursor, Void>() {
        @Nullable

        @Override
        public Void apply(@Nullable ICursor c) {
            txItem[0] = applyCursor(c);
            txExists[0] = true;
            return null;
        }
    });
    if (txExists[0]) {
        addInsAndOuts(db, txItem[0]);
    }
    return txItem[0];
}
 
Example #5
Source File: DialogHdSendConfirm.java    From bither-android with Apache License 2.0 6 votes vote down vote up
public DialogHdSendConfirm(Context context, String toAddress, List<Tx> txs, long fee, SendConfirmListener listener) {
    super(context);
    this.listener = listener;
    this.splitCoin = SplitCoin.BCC;
    setOnDismissListener(this);
    setContentView(R.layout.dialog_send_confirm);
    configureUI(toAddress);
    TextView tvBtc = (TextView) findViewById(R.id.tv_btc);
    TextView tvFee = (TextView) findViewById(R.id.tv_fee);
    long amount = 0;
    for (Tx tx: txs) {
        amount += tx.amountSentToAddress(toAddress);
    }
    tvBtc.setText(UnitUtilWrapper.formatValueWithBold(amount));
    tvFee.setText(UnitUtilWrapper.formatValueWithBold(fee));
}
 
Example #6
Source File: AbstractTxProvider.java    From bitherj with Apache License 2.0 6 votes vote down vote up
public List<String> getInAddresses(Tx tx) {
    final List<String> result = new ArrayList<String>();
    String sql = "select out_address from outs where tx_hash=? and out_sn=?";
    IDb db = this.getReadDb();
    for (In inItem : tx.getIns()) {
        this.execQueryOneRecord(db, sql, new String[]{Base58.encode(inItem.getPrevTxHash())
                , Integer.toString(inItem.getPrevOutSn())}, new Function<ICursor, Void>() {
            @Nullable
            @Override
            public Void apply(@Nullable ICursor c) {
                if (!c.isNull(0)) {
                    result.add(c.getString(0));
                }
                return null;
            }
        });
    }
    return result;
}
 
Example #7
Source File: CurrencyAmountView.java    From bither-android with Apache License 2.0 6 votes vote down vote up
private boolean isValidAmount(final boolean zeroIsValid) {
    final String amount = textView.getText().toString().trim();

    try {
        if (!amount.isEmpty()) {
            final BigInteger nanoCoins = GenericUtils.toNanoCoins(amount, shift);

            // exactly zero
            if (zeroIsValid && nanoCoins.signum() == 0) {
                return true;
            }

            // too small
            if (nanoCoins.longValue() < Tx.MIN_NONDUST_OUTPUT) {
                return false;
            }

            return true;
        }
    } catch (final Exception x) {
    }

    return false;
}
 
Example #8
Source File: TxProvider.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
public boolean isTxDoubleSpendWithConfirmedTx(Tx tx) {
    String sql = "select count(0) cnt from ins a, txs b where a.tx_hash=b.tx_hash and" +
            " b.block_no is not null and a.prev_tx_hash=? and a.prev_out_sn=?";
    ResultSet rs;
    try {
        for (In inItem : tx.getIns()) {
            PreparedStatement statement = this.mDb.getPreparedStatement(sql, new String[]{Base58.encode(inItem.getPrevTxHash()), Integer.toString(inItem.getPrevOutSn())});
            rs = statement.executeQuery();
            if (rs.next()) {
                int columnIndex = rs.findColumn("cnt");
                if (columnIndex != -1 && rs.getInt(columnIndex) > 0) {
                    rs.close();
                    statement.close();
                    return true;
                }
            }
            rs.close();
            statement.close();

        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return false;
}
 
Example #9
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 #10
Source File: TxHelper.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
public static void addInsAndOuts(TxDBHelper mDb, Tx txItem) throws AddressFormatException, SQLException {
    String txHashStr = Base58.encode(txItem.getTxHash());
    txItem.setOuts(new ArrayList<Out>());
    txItem.setIns(new ArrayList<In>());
    String sql = "select * from ins where tx_hash=? order by in_sn";
    PreparedStatement statement = mDb.getPreparedStatement(sql, new String[]{txHashStr});
    ResultSet c = statement.executeQuery();
    while (c.next()) {
        In inItem = TxHelper.applyCursorIn(c);
        inItem.setTx(txItem);
        txItem.getIns().add(inItem);
    }
    c.close();
    statement.close();

    sql = "select * from outs where tx_hash=? order by out_sn";
    statement = mDb.getPreparedStatement(sql, new String[]{txHashStr});
    c = statement.executeQuery();
    while (c.next()) {
        Out outItem = TxHelper.applyCursorOut(c);
        outItem.setTx(txItem);
        txItem.getOuts().add(outItem);
    }
    c.close();
    statement.close();
}
 
Example #11
Source File: ECKeyTest.java    From bitherj with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetPubs() {
    List<byte[]> pubKeyS = Arrays.asList(Utils.hexStringToByteArray("02d8ed584a211a9195f0d580617c60398f82f58dcd5b104249737762656e62d52e"),
            Utils.hexStringToByteArray("026fd10f953a13ac14041460cd01eab3d665d140d1c978a01db4bc669bab9a77db"), Utils.hexStringToByteArray("03b5eceb6f5a9a12b8b7fe23ae6297bfdb46aeab39ab0ee89efd4068d251667ae0"));
    byte[] params = Utils.hexStringToByteArray("522102d8ed584a211a9195f0d580617c60398f82f58dcd5b104249737762656e62d52e21026fd10f953a13ac14041460cd01eab3d665d140d1c978a01db4bc669bab9a77db2103b5eceb6f5a9a12b8b7fe23ae6297bfdb46aeab39ab0ee89efd4068d251667ae053ae");
    Tx tx = new Tx(Utils.hexStringToByteArray("010000000196d607b6c1647a1cccd9db40e918627e4d5e190ba56a5663ccef5e1a8ecada0700000000fdfd0000473044022041b2a5f1965b060bbf484218ac1e3b7ced9ec908078ca4565f9c4eef4f0dfec902206c3f3a1320dac89fd1e58627a1208510328d618365dd033d90ce5230c40884fa01483045022100abd2696052faa6e707e02402b7c654d0ab3be7d1d7f14af541abf99eaf16e1fd02205da8e8e2c4a9795046aa4c380e6f1c005e6619b16f7182df37b54405eb28aedc014c69522102d8ed584a211a9195f0d580617c60398f82f58dcd5b104249737762656e62d52e21026fd10f953a13ac14041460cd01eab3d665d140d1c978a01db4bc669bab9a77db2103b5eceb6f5a9a12b8b7fe23ae6297bfdb46aeab39ab0ee89efd4068d251667ae053aeffffffff0128230000000000001976a914f307ea0809f5c60d42482e57dfdd78ed53df580688ac00000000"));
    List<byte[]> signPubs = tx.getIns().get(0).getP2SHPubKeys();
    for (byte[] signs : signPubs) {
        boolean isPub = false;
        for (byte[] pubs : pubKeyS) {
            isPub = Arrays.equals(signs, pubs);
            if (isPub) {
                break;
            }
        }
        System.out.println("pub:" + Utils.bytesToHexString(signs));
        assertTrue(Utils.bytesToHexString(signs), isPub);
    }

}
 
Example #12
Source File: TxReceiver.java    From bither-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onReceive(Context context, Intent intent) {
    if (intent == null || !Utils.compareString(intent.getAction(), NotificationAndroidImpl.ACTION_ADDRESS_BALANCE)) {
        return;
    }
    if (tickReceiver != null) {
        tickReceiver.setTransactionsReceived();
    }
    String address = intent.getStringExtra(NotificationAndroidImpl.MESSAGE_ADDRESS);
    long amount = intent.getLongExtra(NotificationAndroidImpl.MESSAGE_DELTA_BALANCE, 0);
    int txNotificationType = intent.getIntExtra(NotificationAndroidImpl.MESSAGE_TX_NOTIFICATION_TYPE, 0);
    if (txNotificationType == Tx.TxNotificationType.txReceive.getValue()) {
        boolean isReceived = amount > 0;
        amount = Math.abs(amount);
        notifyCoins(address, amount, isReceived);
    }

}
 
Example #13
Source File: TxProvider.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
public List<String> getInAddresses(Tx tx) {
    List<String> result = new ArrayList<String>();
    String sql = "select out_address from outs where tx_hash=? and out_sn=?";
    ResultSet c;
    try {
        for (In inItem : tx.getIns()) {
            PreparedStatement statement = this.mDb.getPreparedStatement(sql, new String[]{Base58.encode(inItem.getPrevTxHash()), Integer.toString(inItem.getPrevOutSn())});
            c = statement.executeQuery();
            if (c.next()) {
                int column = c.findColumn("out_address");
                if (column != -1) {
                    result.add(c.getString(column));
                }
            }
            c.close();
            statement.close();
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return result;
}
 
Example #14
Source File: QRCodeTxTransport.java    From bitherj with Apache License 2.0 6 votes vote down vote up
public static String oldGetPreSignString(Tx tx, String addressCannotParsed) {
    QRCodeTxTransport qrCodeTransport = oldFromSendRequestWithUnsignedTransaction(tx,
            addressCannotParsed);
    String preSignString = qrCodeTransport.getMyAddress() + QRCodeUtil.OLD_QR_CODE_SPLIT +
            Long.toHexString(qrCodeTransport.getFee()).toLowerCase(Locale.US) + QRCodeUtil
            .OLD_QR_CODE_SPLIT + qrCodeTransport.getToAddress() + QRCodeUtil
            .OLD_QR_CODE_SPLIT + Long.toHexString(qrCodeTransport.getTo()).toLowerCase(Locale
            .US) + QRCodeUtil.OLD_QR_CODE_SPLIT;
    for (int i = 0;
         i < qrCodeTransport.getHashList().size();
         i++) {
        String hash = qrCodeTransport.getHashList().get(i);
        if (i < qrCodeTransport.getHashList().size() - 1) {
            preSignString = preSignString + hash + QRCodeUtil.OLD_QR_CODE_SPLIT;
        } else {
            preSignString = preSignString + hash;
        }
    }

    return preSignString;
}
 
Example #15
Source File: UnSignTxPanel.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
@Override
public void success(Object obj) {
    if (obj != null && obj instanceof Tx) {
        tx = (Tx) obj;
        if (needConfirm) {
            SendBitcoinConfirmPanel confirmPanel = new SendBitcoinConfirmPanel
                    (sendConfirmListener, bitcoinAddress, changeAddress, tx);
            confirmPanel.showPanel();
        } else {
            sendConfirmListener.onConfirm(tx);
        }
    } else {
        new MessageDialog(LocaliserUtils.getString("password_wrong")).showMsg();
    }

}
 
Example #16
Source File: AbstractTxProvider.java    From bitherj with Apache License 2.0 6 votes vote down vote up
public void insertTx(IDb db, Tx txItem) {
    final int[] cnt = {0};
    String existSql = "select count(0) cnt from txs where tx_hash=?";
    this.execQueryOneRecord(db, existSql, new String[]{Base58.encode(txItem.getTxHash())}, new Function<ICursor, Void>() {
        @Nullable
        @Override
        public Void apply(@Nullable ICursor c) {
            int idColumn = c.getColumnIndex("cnt");
            if (idColumn != -1) {
                cnt[0] = c.getInt(idColumn);
            }
            return null;
        }
    });

    if (cnt[0] == 0) {
        this.insertTxToDb(db, txItem);
    }

}
 
Example #17
Source File: GenerateUnsignedTxActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onConfirm(Tx tx) {
    GenerateUnsignedTxActivity.this.tx = tx;
    String addressCannotBtParsed = getString(R.string.address_cannot_be_parsed);
    Intent intent = new Intent(GenerateUnsignedTxActivity.this,
            UnsignedTxQrCodeActivity.class);
    String changeAddress = dialogSelectChangeAddress
            .getChangeAddress().equals(address) ? null :
            dialogSelectChangeAddress.getChangeAddress().getAddress();
    intent.putExtra(BitherSetting.INTENT_REF.QR_CODE_STRING,
            QRCodeTxTransport.getPresignTxString(tx, changeAddress, addressCannotBtParsed, QRCodeTxTransport.NO_HDM_INDEX));
    if (Utils.isEmpty(changeAddress)) {
        intent.putExtra(BitherSetting.INTENT_REF.OLD_QR_CODE_STRING,
                QRCodeTxTransport.oldGetPreSignString(tx, addressCannotBtParsed));
    } else {
        intent.putExtra(BitherSetting.INTENT_REF.QR_CODE_HAS_CHANGE_ADDRESS_STRING
                , true);
    }

    intent.putExtra(BitherSetting.INTENT_REF.TITLE_STRING,
            getString(R.string.unsigned_transaction_qr_code_title));
    startActivityForResult(intent, BitherSetting.INTENT_REF.SIGN_TX_REQUEST_CODE);
    btnSend.setEnabled(true);
}
 
Example #18
Source File: TxNotificationCenter.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
public static void notificatTx(final String address, final Tx tx,
                               final Tx.TxNotificationType txNotificationType, final long deltaBalance) {
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            if (Utils.compareString(address, HDAccount.HDAccountPlaceHolder)) {
                Bither.refreshFrame();
            }
            for (ITxListener txListener : txListenerList) {
                txListener.notificatTx(address, tx, txNotificationType, deltaBalance);
            }
            if (txNotificationType == Tx.TxNotificationType.txReceive) {
                boolean isReceived = deltaBalance > 0;
                long balance = Math.abs(deltaBalance);
                notifyCoins(address, balance, isReceived);
            }
        }
    });


}
 
Example #19
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 #20
Source File: AbstractTxProvider.java    From bitherj with Apache License 2.0 6 votes vote down vote up
@Override
public List<Tx> getTxAndDetailByAddress(String address) {
    final List<Tx> txItemList = new ArrayList<Tx>();
    final HashMap<Sha256Hash, Tx> txDict = new HashMap<Sha256Hash, Tx>();
    String sql = "select b.* from addresses_txs a, txs b" +
            " where a.tx_hash=b.tx_hash and a.address=? order by ifnull(b.block_no,4294967295) desc";
    IDb db = this.getReadDb();
    this.execQueryLoop(db, sql, new String[]{address}, new Function<ICursor, Void>() {
        @Nullable
        @Override
        public Void apply(@Nullable ICursor c) {
            Tx txItem = applyCursor(c);
            txItem.setIns(new ArrayList<In>());
            txItem.setOuts(new ArrayList<Out>());
            txItemList.add(txItem);
            txDict.put(new Sha256Hash(txItem.getTxHash()), txItem);
            return null;
        }
    });
    addInForTxDetail(db, address, txDict);
    addOutForTxDetail(db, address, txDict);

    return txItemList;
}
 
Example #21
Source File: HdmSendActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onConfirm(Tx tx) {
    String addressCannotBtParsed = getString(R.string.address_cannot_be_parsed);
    Intent intent = new Intent(HdmSendActivity.this, UnsignedTxQrCodeActivity.class);
    String changeAddress = dialogSelectChangeAddress.getChangeAddress().equals
            (address) ? null : dialogSelectChangeAddress.getChangeAddress()
            .getAddress();
    intent.putExtra(BitherSetting.INTENT_REF.QR_CODE_STRING,
            QRCodeTxTransport.getPresignTxString(tx, changeAddress,
                    addressCannotBtParsed, signingIndex));
    if (Utils.isEmpty(changeAddress)) {
        intent.putExtra(BitherSetting.INTENT_REF.OLD_QR_CODE_STRING,
                QRCodeTxTransport.oldGetPreSignString(tx, addressCannotBtParsed));
    } else {
        intent.putExtra(BitherSetting.INTENT_REF.QR_CODE_HAS_CHANGE_ADDRESS_STRING,
                true);
    }

    intent.putExtra(BitherSetting.INTENT_REF.TITLE_STRING,
            getString(R.string.unsigned_transaction_qr_code_title));
    startActivityForResult(intent, RequestCode);
    sigs = null;
}
 
Example #22
Source File: TxProvider.java    From bither-android with Apache License 2.0 6 votes vote down vote up
@Override
protected void insertTxToDb(IDb db, Tx tx) {
    AndroidDb mdb = (AndroidDb)db;
    ContentValues cv = new ContentValues();
    if (tx.getBlockNo() != Tx.TX_UNCONFIRMED) {
        cv.put(AbstractDb.TxsColumns.BLOCK_NO, tx.getBlockNo());
    } else {
        cv.putNull(AbstractDb.TxsColumns.BLOCK_NO);
    }
    cv.put(AbstractDb.TxsColumns.TX_HASH, Base58.encode(tx.getTxHash()));
    cv.put(AbstractDb.TxsColumns.SOURCE, tx.getSource());
    cv.put(AbstractDb.TxsColumns.TX_TIME, tx.getTxTime());
    cv.put(AbstractDb.TxsColumns.TX_VER, tx.getTxVer());
    cv.put(AbstractDb.TxsColumns.TX_LOCKTIME, tx.getTxLockTime());
    mdb.getSQLiteDatabase().insert(AbstractDb.Tables.TXS, null, cv);
}
 
Example #23
Source File: AbstractTxProvider.java    From bitherj with Apache License 2.0 6 votes vote down vote up
private void addOutForTxDetail(IDb db, String address, final HashMap<Sha256Hash, Tx> txDict) {
    String sql = "select b.* from addresses_txs a, outs b where a.tx_hash=b.tx_hash and a.address=? "
            + "order by b.tx_hash,b.out_sn";
    this.execQueryLoop(db, sql, new String[]{address}, new Function<ICursor, Void>() {
        @Nullable
        @Override
        public Void apply(@Nullable ICursor c) {
            Out out = applyCursorOut(c);
            Tx tx = txDict.get(new Sha256Hash(out.getTxHash()));
            if (tx != null) {
                tx.getOuts().add(out);
            }
            return null;
        }
    });
}
 
Example #24
Source File: TxProvider.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
public boolean isTxDoubleSpendWithConfirmedTx(Tx tx) {
    String sql = "select count(0) cnt from ins a, txs b where a.tx_hash=b.tx_hash and" +
            " b.block_no is not null and a.prev_tx_hash=? and a.prev_out_sn=?";
    ResultSet rs;
    try {
        for (In inItem : tx.getIns()) {
            PreparedStatement statement = this.mDb.getPreparedStatement(sql, new String[]{Base58.encode(inItem.getPrevTxHash()), Integer.toString(inItem.getPrevOutSn())});
            rs = statement.executeQuery();
            if (rs.next()) {
                int columnIndex = rs.findColumn("cnt");
                if (columnIndex != -1 && rs.getInt(columnIndex) > 0) {
                    rs.close();
                    statement.close();
                    return true;
                }
            }
            rs.close();
            statement.close();

        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return false;
}
 
Example #25
Source File: BlockListFragment.java    From bither-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onLoaderReset(final Loader<Set<Tx>> loader) {
    BlockListFragment.this.transactions.clear(); // be nice
    BlockListFragment.this.transactions = null;

    adapter.notifyDataSetChanged();
}
 
Example #26
Source File: SendActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
public void handleMessage(android.os.Message msg) {
    switch (msg.what) {
        case HandlerMessage.MSG_SUCCESS:
            if (!dp.isShowing()) {
                dp.show();
            }
            if (msg.obj != null && msg.obj instanceof Tx) {
                Tx tx = (Tx) msg.obj;
                //dp.setRChecking();
                RCheckRunnable run = new RCheckRunnable(address, tx);
                run.setHandler(rcheckHandler);
                new Thread(run).start();
            } else {
                DropdownMessage.showDropdownMessage(SendActivity.this,
                        R.string.password_wrong);
            }
            break;
        case HandlerMessage.MSG_PASSWORD_WRONG:
            if (dp.isShowing()) {
                dp.dismiss();
            }
            DropdownMessage.showDropdownMessage(SendActivity.this, R.string.password_wrong);
            break;
        case HandlerMessage.MSG_FAILURE:
            if (dp.isShowing()) {
                dp.dismiss();
            }
            String msgError = getString(R.string.send_failed);
            if (msg.obj instanceof String) {
                msgError = (String) msg.obj;
            }
            DropdownMessage.showDropdownMessage(SendActivity.this, msgError);
            break;
        default:
            break;
    }
}
 
Example #27
Source File: SendBitcoinPanel.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
@Override
public void onCommitTransactionSuccess(Tx tx) {
    closePanel();
    if (Utils.isEmpty(doateAddress)) {
        new MessageDialog(LocaliserUtils.getString("send_success")).showMsg();
    } else {
        new MessageDialog(LocaliserUtils.getString("donate_thanks")).showMsg();
    }
}
 
Example #28
Source File: BCCAssetsDetectHotActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
public void handleMessage(android.os.Message msg) {
    switch (msg.what) {
        case HandlerMessage.MSG_SUCCESS:
            if (!dp.isShowing()) {
                dp.show();
            }
            if (msg.obj != null && msg.obj instanceof List) {
                txs = (List<Tx>) msg.obj;
                RCheckRunnable run = new RCheckRunnable(address, txs);
                run.setHandler(rcheckHandler);
                new Thread(run).start();
            } else {
                DropdownMessage.showDropdownMessage(BCCAssetsDetectHotActivity.this,
                        R.string.password_wrong);
            }
            break;
        case HandlerMessage.MSG_PASSWORD_WRONG:
            if (dp.isShowing()) {
                dp.dismiss();
            }
            DropdownMessage.showDropdownMessage(BCCAssetsDetectHotActivity.this, R.string.password_wrong);
            break;
        case HandlerMessage.MSG_FAILURE:
            if (dp.isShowing()) {
                dp.dismiss();
            }
            String msgError = getString(R.string.send_failed);
            if (msg.obj instanceof String) {
                msgError = (String) msg.obj;
            }
            DropdownMessage.showDropdownMessage(BCCAssetsDetectHotActivity.this, msgError);
            break;
        default:
            break;
    }
}
 
Example #29
Source File: UnSignTxPanel.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
@Override
public void onConfirm(Tx request) {

    String qrCodeString = QRCodeTxTransport.getPresignTxString(request, changeAddress, LocaliserUtils.getString("address_cannot_be_parsed"), QRCodeTxTransport.NO_HDM_INDEX);
    GenerateUnsignedTxPanel generateUnsignedTxPanel = new GenerateUnsignedTxPanel(UnSignTxPanel.this, qrCodeString);
    generateUnsignedTxPanel.showPanel();

}
 
Example #30
Source File: ShowTransactionsForm.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
@Override
public void notificatTx(String address, Tx tx, Tx.TxNotificationType txNotificationType, long deltaBalance) {
    String actionAddress = "";
    if (Bither.getActionAddress() != null) {
        actionAddress = Bither.getActionAddress().getAddress();
    }
    if (Utils.compareString(address, actionAddress)) {
        displayView(DisplayHint.WALLET_TRANSACTIONS_HAVE_CHANGED);
    }

}