Java 类org.bitcoinj.core.VersionedChecksummedBytes 实例源码

项目:okwallet    文件:SendCoinsFragment.java   
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 VersionedChecksummedBytes 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) {
            dialog(activity, activityDismissListener, 0, messageResId, messageArgs);
        }
    }.parse();
}
项目:android-wallet    文件:WalletConfiguration.java   
public WalletConfiguration(String seed, NetworkParameters network)
{
    this.seed = Base64.decode(seed, Base64.DEFAULT);

    final DeterministicKey key = HDKeyDerivation.createMasterPrivateKey(this.seed);
    this.key = HDKeyDerivation.deriveChildKey(key, 0);

    final Address address = this.key.toAddress(network);
    this.address = address.toString();
    this.networkParameters = network;

    byte[] forAssetsAddress = new byte[21];
    System.arraycopy(address.getHash160(), 0, forAssetsAddress, 1, 20);
    forAssetsAddress[0] = (byte)address.getVersion();

    this.receiveAssetsAddress = new VersionedChecksummedBytes(openAssetsNamespace, forAssetsAddress) { }.toString();
}
项目:okwallet    文件:SweepWalletFragment.java   
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (!Constants.ENABLE_SWEEP_WALLET)
        throw new IllegalStateException("ENABLE_SWEEP_WALLET is disabled");

    setRetainInstance(true);
    setHasOptionsMenu(true);

    backgroundThread = new HandlerThread("backgroundThread", Process.THREAD_PRIORITY_BACKGROUND);
    backgroundThread.start();
    backgroundHandler = new Handler(backgroundThread.getLooper());

    if (savedInstanceState != null) {
        restoreInstanceState(savedInstanceState);
    } else {
        final Intent intent = activity.getIntent();

        if (intent.hasExtra(SweepWalletActivity.INTENT_EXTRA_KEY)) {
            privateKeyToSweep = (VersionedChecksummedBytes) intent
                    .getSerializableExtra(SweepWalletActivity.INTENT_EXTRA_KEY);

            // delay until fragment is resumed
            handler.post(maybeDecodeKeyRunnable);
        }
    }
}
项目:okwallet    文件:SweepWalletFragment.java   
@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 VersionedChecksummedBytes key) {
                    privateKeyToSweep = key;
                    setState(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) {
                    dialog(activity, null, R.string.button_scan, messageResId, messageArgs);
                }
            }.parse();
        }
    }
}
项目:okwallet    文件:WalletActivity.java   
@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) {
                SendCoinsActivity.start(WalletActivity.this, paymentIntent);
            }

            @Override
            protected void handlePrivateKey(final VersionedChecksummedBytes key) {
                if (Constants.ENABLE_SWEEP_WALLET)
                    SweepWalletActivity.start(WalletActivity.this, key);
                else
                    super.handlePrivateKey(key);
            }

            @Override
            protected void handleDirectTransaction(final Transaction tx) throws VerificationException {
                application.processDirectTransaction(tx);
            }

            @Override
            protected void error(final int messageResId, final Object... messageArgs) {
                dialog(WalletActivity.this, null, R.string.button_scan, messageResId, messageArgs);
            }
        }.parse();
    }
}
项目:ombuds-android    文件:SweepWalletFragment.java   
@Override
public void onCreate(final Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);

    setRetainInstance(true);
    setHasOptionsMenu(true);

    backgroundThread = new HandlerThread("backgroundThread", Process.THREAD_PRIORITY_BACKGROUND);
    backgroundThread.start();
    backgroundHandler = new Handler(backgroundThread.getLooper());

    if (savedInstanceState != null)
    {
        restoreInstanceState(savedInstanceState);
    }
    else
    {
        final Intent intent = activity.getIntent();

        if (intent.hasExtra(SweepWalletActivity.INTENT_EXTRA_KEY))
        {
            privateKeyToSweep = (VersionedChecksummedBytes) intent.getSerializableExtra(SweepWalletActivity.INTENT_EXTRA_KEY);

            // delay until fragment is resumed
            handler.post(maybeDecodeKeyRunnable);
        }
    }
}
项目:ombuds-android    文件:SweepWalletFragment.java   
@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 VersionedChecksummedBytes key)
                {
                    privateKeyToSweep = key;
                    setState(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)
                {
                    dialog(activity, null, R.string.button_scan, messageResId, messageArgs);
                }
            }.parse();
        }
    }
}
项目:ombuds-android    文件:SendCoinsFragment.java   
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 VersionedChecksummedBytes 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)
        {
            dialog(activity, activityDismissListener, 0, messageResId, messageArgs);
        }
    }.parse();
}
项目:ombuds-android    文件:WalletActivity.java   
@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)
            {
                SendCoinsActivity.start(WalletActivity.this, paymentIntent);
            }

            @Override
            protected void handlePrivateKey(final VersionedChecksummedBytes key)
            {
                SweepWalletActivity.start(WalletActivity.this, key);
            }

            @Override
            protected void handleDirectTransaction(final Transaction tx) throws VerificationException
            {
                application.processDirectTransaction(tx);
            }

            @Override
            protected void error(final int messageResId, final Object... messageArgs)
            {
                dialog(WalletActivity.this, null, R.string.button_scan, messageResId, messageArgs);
            }
        }.parse();
    }
}
项目:okwallet    文件:SweepWalletActivity.java   
public static void start(final Context context, final VersionedChecksummedBytes key) {
    final Intent intent = new Intent(context, SweepWalletActivity.class);
    intent.putExtra(INTENT_EXTRA_KEY, key);
    context.startActivity(intent);
}
项目:okwallet    文件:InputParser.java   
protected void handlePrivateKey(final VersionedChecksummedBytes key) {
    final Address address = new Address(Constants.NETWORK_PARAMETERS,
            ((DumpedPrivateKey) key).getKey().getPubKeyHash());

    handlePaymentIntent(PaymentIntent.fromAddress(address, null));
}
项目:ombuds-android    文件:SweepWalletActivity.java   
public static void start(final Context context, final VersionedChecksummedBytes key)
{
    final Intent intent = new Intent(context, SweepWalletActivity.class);
    intent.putExtra(INTENT_EXTRA_KEY, key);
    context.startActivity(intent);
}
项目:ombuds-android    文件:InputParser.java   
protected void handlePrivateKey(final VersionedChecksummedBytes key)
{
    final Address address = new Address(Constants.NETWORK_PARAMETERS, ((DumpedPrivateKey) key).getKey().getPubKeyHash());

    handlePaymentIntent(PaymentIntent.fromAddress(address, null));
}