Search in sources :

Example 6 with PrefixedChecksummedBytes

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

the class SendCoinsFragment method initStateFromBitcoinUri.

private void initStateFromBitcoinUri(final Uri bitcoinUri) {
    final String input = bitcoinUri.toString();
    new StringInputParser(input) {

        @Override
        protected void handlePaymentIntent(final PaymentIntent paymentIntent) {
            updateStateFrom(paymentIntent);
        }

        @Override
        protected void handlePrivateKey(final PrefixedChecksummedBytes key) {
            throw new UnsupportedOperationException();
        }

        @Override
        protected void handleDirectTransaction(final Transaction transaction) throws VerificationException {
            throw new UnsupportedOperationException();
        }

        @Override
        protected void error(final int messageResId, final Object... messageArgs) {
            final DialogBuilder dialog = DialogBuilder.dialog(activity, 0, messageResId, messageArgs);
            dialog.singleDismissButton(activityDismissListener);
            dialog.show();
        }
    }.parse();
}
Also used : PrefixedChecksummedBytes(org.bitcoinj.core.PrefixedChecksummedBytes) Transaction(org.bitcoinj.core.Transaction) StringInputParser(de.schildbach.wallet.ui.InputParser.StringInputParser) VerificationException(org.bitcoinj.core.VerificationException) PaymentIntent(de.schildbach.wallet.data.PaymentIntent) DialogBuilder(de.schildbach.wallet.ui.DialogBuilder)

Example 7 with PrefixedChecksummedBytes

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

the class SweepWalletFragment method onActivityResult.

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

                @Override
                protected void handlePrivateKey(final PrefixedChecksummedBytes key) {
                    viewModel.privateKeyToSweep.setValue(key);
                    setState(SweepWalletViewModel.State.DECODE_KEY);
                    maybeDecodeKey();
                }

                @Override
                protected void handlePaymentIntent(final PaymentIntent paymentIntent) {
                    cannotClassify(input);
                }

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

                @Override
                protected void error(final int messageResId, final Object... messageArgs) {
                    viewModel.showDialog.setValue(DialogEvent.dialog(R.string.button_scan, messageResId, messageArgs));
                }
            }.parse();
        }
    }
}
Also used : PrefixedChecksummedBytes(org.bitcoinj.core.PrefixedChecksummedBytes) Transaction(org.bitcoinj.core.Transaction) WalletTransaction(org.bitcoinj.wallet.WalletTransaction) StringInputParser(de.schildbach.wallet.ui.InputParser.StringInputParser) VerificationException(org.bitcoinj.core.VerificationException) PaymentIntent(de.schildbach.wallet.data.PaymentIntent) TransactionOutPoint(org.bitcoinj.core.TransactionOutPoint)

Aggregations

PrefixedChecksummedBytes (org.bitcoinj.core.PrefixedChecksummedBytes)7 Transaction (org.bitcoinj.core.Transaction)6 PaymentIntent (de.schildbach.wallet.data.PaymentIntent)5 StringInputParser (de.schildbach.wallet.ui.InputParser.StringInputParser)5 VerificationException (org.bitcoinj.core.VerificationException)5 WalletTransaction (org.bitcoinj.wallet.WalletTransaction)3 Activity (android.app.Activity)2 Intent (android.content.Intent)2 Bundle (android.os.Bundle)2 ViewModelProvider (androidx.lifecycle.ViewModelProvider)2 Constants (de.schildbach.wallet.Constants)2 ScanActivity (de.schildbach.wallet.ui.scan.ScanActivity)2 Coin (org.bitcoinj.core.Coin)2 DumpedPrivateKey (org.bitcoinj.core.DumpedPrivateKey)2 ECKey (org.bitcoinj.core.ECKey)2 BIP38PrivateKey (org.bitcoinj.crypto.BIP38PrivateKey)2 MonetaryFormat (org.bitcoinj.utils.MonetaryFormat)2 Wallet (org.bitcoinj.wallet.Wallet)2 Context (android.content.Context)1 OnClickListener (android.content.DialogInterface.OnClickListener)1