Search in sources :

Example 6 with VerificationException

use of org.bitcoinj.core.VerificationException in project bitcoin-wallet by bitcoin-wallet.

the class SendingAddressesFragment method onActivityResult.

@Override
public void onActivityResult(final int requestCode, final int resultCode, final Intent intent) {
    if (requestCode == REQUEST_CODE_SCAN && resultCode == Activity.RESULT_OK) {
        final String input = intent.getStringExtra(ScanActivity.INTENT_EXTRA_RESULT);
        new StringInputParser(input) {

            @Override
            protected void handlePaymentIntent(final PaymentIntent paymentIntent) {
                // workaround for "IllegalStateException: Can not perform this action after
                // onSaveInstanceState"
                handler.postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        if (paymentIntent.hasAddress()) {
                            final Address address = paymentIntent.getAddress();
                            if (!wallet.isPubKeyHashMine(address.getHash160()))
                                EditAddressBookEntryFragment.edit(getFragmentManager(), address);
                            else
                                dialog(activity, null, R.string.address_book_options_scan_title, R.string.address_book_options_scan_own_address);
                        } else {
                            dialog(activity, null, R.string.address_book_options_scan_title, R.string.address_book_options_scan_invalid);
                        }
                    }
                }, 500);
            }

            @Override
            protected void handleDirectTransaction(final Transaction transaction) throws VerificationException {
                cannotClassify(input);
            }

            @Override
            protected void error(final int messageResId, final Object... messageArgs) {
                dialog(activity, null, R.string.address_book_options_scan_title, messageResId, messageArgs);
            }
        }.parse();
    }
}
Also used : Address(org.bitcoinj.core.Address) Transaction(org.bitcoinj.core.Transaction) StringInputParser(de.schildbach.wallet.ui.InputParser.StringInputParser) VerificationException(org.bitcoinj.core.VerificationException) PaymentIntent(de.schildbach.wallet.data.PaymentIntent)

Aggregations

PaymentIntent (de.schildbach.wallet.data.PaymentIntent)6 StringInputParser (de.schildbach.wallet.ui.InputParser.StringInputParser)6 Transaction (org.bitcoinj.core.Transaction)6 VerificationException (org.bitcoinj.core.VerificationException)6 VersionedChecksummedBytes (org.bitcoinj.core.VersionedChecksummedBytes)4 DialogInterface (android.content.DialogInterface)1 OnClickListener (android.content.DialogInterface.OnClickListener)1 WalletApplication (de.schildbach.wallet.WalletApplication)1 Address (org.bitcoinj.core.Address)1 TransactionOutPoint (org.bitcoinj.core.TransactionOutPoint)1 WalletTransaction (org.bitcoinj.wallet.WalletTransaction)1