当前位置: 首页>>代码示例>>Java>>正文


Java KeyCrypterException类代码示例

本文整理汇总了Java中org.bitcoinj.crypto.KeyCrypterException的典型用法代码示例。如果您正苦于以下问题:Java KeyCrypterException类的具体用法?Java KeyCrypterException怎么用?Java KeyCrypterException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


KeyCrypterException类属于org.bitcoinj.crypto包,在下文中一共展示了KeyCrypterException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onSignResult

import org.bitcoinj.crypto.KeyCrypterException; //导入依赖的package包/类
@Override
public void onSignResult(@Nullable Exception error, ExchangeEntry exchangeEntry) {
    if (error != null) {
        getSupportFragmentManager().popBackStack();
        // Ignore wallet decryption errors
        if (!(error instanceof KeyCrypterException)) {
            DialogBuilder builder = DialogBuilder.warn(this, com.fillerino.wallet.R.string.trade_error);
            builder.setMessage(getString(com.fillerino.wallet.R.string.trade_error_sign_tx_message, error.getMessage()));
            builder.setPositiveButton(com.fillerino.wallet.R.string.button_ok, null)
                    .create().show();
        }
    } else if (exchangeEntry != null) {
        getSupportFragmentManager().popBackStack();
        replaceFragment(TradeStatusFragment.newInstance(exchangeEntry, true), containerRes);
    }
}
 
开发者ID:filipnyquist,项目名称:lbry-android,代码行数:17,代码来源:TradeActivity.java

示例2: onAddCoinTaskFinished

import org.bitcoinj.crypto.KeyCrypterException; //导入依赖的package包/类
@Override
public void onAddCoinTaskFinished(Exception error, WalletAccount newAccount) {
    if (Dialogs.dismissAllowingStateLoss(getFragmentManager(), ADD_COIN_TASK_BUSY_DIALOG_TAG)) return;

    if (error != null) {
        if (error instanceof KeyCrypterException) {
            showPasswordRetryDialog();
        } else {
            ACRA.getErrorReporter().handleSilentException(error);
            Toast.makeText(getActivity(), com.fillerino.wallet.R.string.error_generic, Toast.LENGTH_LONG).show();
        }
    } else {
        destinationAccount = newAccount;
        destinationType = newAccount.getCoinType();
        onHandleNext();
    }
    addCoinAndProceedTask = null;
}
 
开发者ID:filipnyquist,项目名称:lbry-android,代码行数:19,代码来源:TradeSelectFragment.java

示例3: decrypt

import org.bitcoinj.crypto.KeyCrypterException; //导入依赖的package包/类
/**
 * Queue a request to decrypt this wallet. This returns immediately, as the
 * actual work is done on the network thread in order to ensure the thread
 * context is correct. Unhandled errors are reported back to Network.
 *
 * @param password password to decrypt the wallet with
 * @param onSuccess callback on success
 * @param onWalletNotEncrypted callback if the wallet is not encrypted
 * @param onCrypterError callback in case of an error in the key crypter
 * @param timeout timeout on queueing the work request
 * @param timeUnit time unit for the timeout
 */
public void decrypt(String password, Consumer<Object> onSuccess,
        Consumer<Object> onWalletNotEncrypted,
        Consumer<KeyCrypterException> onCrypterError,
        final long timeout, final TimeUnit timeUnit) {
    this.networkExecutor.execute((Runnable) () -> {
        final Wallet wallet = wallet();
        if (!wallet.isEncrypted()) {
            onCrypterError.accept(null);
        } else {
            final KeyCrypter keyCrypter = wallet().getKeyCrypter();

            if (keyCrypter == null) {
                throw new IllegalStateException("Wallet is encrypted but has no key crypter.");
            } else {
                try {
                    wallet().decrypt(keyCrypter.deriveKey(password));
                    encrypted.set(false);
                    onSuccess.accept(null);
                } catch (KeyCrypterException ex) {
                    onCrypterError.accept(ex);
                }
            }
        }
    });
}
 
开发者ID:rnicoll,项目名称:cate,代码行数:38,代码来源:Network.java

示例4: signMessage

import org.bitcoinj.crypto.KeyCrypterException; //导入依赖的package包/类
public static MasternodeSignature signMessage(String strMessage, StringBuilder errorMessage, ECKey key)
{
    //ECKey ecKey = ECKey.fromPublicOnly(key.getBytes());
    try {
        byte dataToHash [] = (Utils.BITCOIN_SIGNED_MESSAGE_HEADER_BYTES+strMessage).getBytes(Charsets.UTF_8);


        ECKey.ECDSASignature signature = key.sign(Sha256Hash.twiceOf(dataToHash));

        return new MasternodeSignature(signature.encodeToDER());
    }
    catch (KeyCrypterException x)
    {

    }
    errorMessage.append("Sign failed");
    return null;
}
 
开发者ID:HashEngineering,项目名称:dashj,代码行数:19,代码来源:DarkSendSigner.java

示例5: forwardCoins

import org.bitcoinj.crypto.KeyCrypterException; //导入依赖的package包/类
private static void forwardCoins(Transaction tx) {
    try {
        Coin value = tx.getValueSentToMe(kit.wallet());
        System.out.println("Forwarding " + value.toFriendlyString());
        // Now send the coins back! Send with a small fee attached to ensure rapid confirmation.
        final Coin amountToSend = value.subtract(Transaction.REFERENCE_DEFAULT_MIN_TX_FEE);
        final Wallet.SendResult sendResult = kit.wallet().sendCoins(kit.peerGroup(), forwardingAddress, amountToSend);
        checkNotNull(sendResult);  // We should never try to send more coins than we have!
        System.out.println("Sending ...");
        // Register a callback that is invoked when the transaction has propagated across the network.
        // This shows a second style of registering ListenableFuture callbacks, it works when you don't
        // need access to the object the future returns.
        sendResult.broadcastComplete.addListener(new Runnable() {
            @Override
            public void run() {
                // The wallet has changed now, it'll get auto saved shortly or when the app shuts down.
                System.out.println("Sent coins onwards! Transaction hash is " + sendResult.tx.getHashAsString());
            }
        }, MoreExecutors.directExecutor());
    } catch (KeyCrypterException | InsufficientMoneyException e) {
        // We don't use encrypted wallets in this example - can never happen.
        throw new RuntimeException(e);
    }
}
 
开发者ID:bitcoinj,项目名称:bitcoinj,代码行数:25,代码来源:ForwardingService.java

示例6: doRaiseFee

import org.bitcoinj.crypto.KeyCrypterException; //导入依赖的package包/类
private void doRaiseFee(final KeyParameter encryptionKey) {
    // construct child-pays-for-parent
    final TransactionOutput outputToSpend = checkNotNull(findSpendableOutput(wallet, transaction, feeRaise));
    final Transaction transactionToSend = new Transaction(Constants.NETWORK_PARAMETERS);
    transactionToSend.addInput(outputToSpend);
    transactionToSend.addOutput(outputToSpend.getValue().subtract(feeRaise),
            wallet.freshAddress(KeyPurpose.CHANGE));
    transactionToSend.setPurpose(Transaction.Purpose.RAISE_FEE);

    final SendRequest sendRequest = SendRequest.forTx(transactionToSend);
    sendRequest.aesKey = encryptionKey;

    try {
        wallet.signTransaction(sendRequest);

        log.info("raise fee: cpfp {}", transactionToSend);

        wallet.commitTx(transactionToSend);
        application.broadcastTransaction(transactionToSend);

        state = State.DONE;
        updateView();

        dismiss();
    } catch (final KeyCrypterException x) {
        badPasswordView.setVisibility(View.VISIBLE);

        state = State.INPUT;
        updateView();

        passwordView.requestFocus();

        log.info("raise fee: bad spending password");
    }
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:36,代码来源:RaiseFeeDialogFragment.java

示例7: cannotImportEncryptedKey

import org.bitcoinj.crypto.KeyCrypterException; //导入依赖的package包/类
@Test(expected = KeyCrypterException.class)
public void cannotImportEncryptedKey() {
    final ECKey key1 = new ECKey();
    chain.importKeys(ImmutableList.of(key1));
    chain = chain.toEncrypted("foobar");
    ECKey encryptedKey = chain.getKey(KeyChain.KeyPurpose.RECEIVE_FUNDS);
    assertTrue(encryptedKey.isEncrypted());

    BasicKeyChain chain2 = new BasicKeyChain();
    chain2.importKeys(ImmutableList.of(encryptedKey));
}
 
开发者ID:Grant-Redmond,项目名称:cryptwallet,代码行数:12,代码来源:BasicKeyChainTest.java

示例8: cannotMixParams

import org.bitcoinj.crypto.KeyCrypterException; //导入依赖的package包/类
@Test(expected = KeyCrypterException.class)
public void cannotMixParams() throws Exception {
    chain = chain.toEncrypted("foobar");
    KeyCrypterScrypt scrypter = new KeyCrypterScrypt(2);    // Some bogus params.
    ECKey key1 = new ECKey().encrypt(scrypter, scrypter.deriveKey("other stuff"));
    chain.importKeys(key1);
}
 
开发者ID:Grant-Redmond,项目名称:cryptwallet,代码行数:8,代码来源:BasicKeyChainTest.java

示例9: onAddCoinTaskFinished

import org.bitcoinj.crypto.KeyCrypterException; //导入依赖的package包/类
@Override
public void onAddCoinTaskFinished(Exception error, WalletAccount newAccount) {
    if (Dialogs.dismissAllowingStateLoss(getSupportFragmentManager(), ADD_COIN_TASK_BUSY_DIALOG_TAG)) return;
    addCoinTask = null;
    final Intent result = new Intent();
    if (error != null) {
        if (error instanceof KeyCrypterException) {
            new AlertDialog.Builder(this)
                    .setTitle(getString(com.fillerino.wallet.R.string.unlocking_wallet_error_title))
                    .setMessage(com.fillerino.wallet.R.string.unlocking_wallet_error_detail)
                    .setPositiveButton(com.fillerino.wallet.R.string.button_retry, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            showAddCoinDialog();
                        }
                    })
                    .setNegativeButton(com.fillerino.wallet.R.string.button_cancel, null)
                    .create().show();
        } else {
            String message = getResources().getString(com.fillerino.wallet.R.string.add_coin_error,
                    selectedCoin.getName(), error.getMessage());
            Toast.makeText(AddCoinsActivity.this, message, Toast.LENGTH_LONG).show();
            setResult(RESULT_CANCELED, result);
            finish();
        }
    } else {
        result.putExtra(Constants.ARG_ACCOUNT_ID, newAccount.getId());
        setResult(RESULT_OK, result);
        finish();
    }

}
 
开发者ID:filipnyquist,项目名称:lbry-android,代码行数:33,代码来源:AddCoinsActivity.java

示例10: checkAESKey

import org.bitcoinj.crypto.KeyCrypterException; //导入依赖的package包/类
@Override
public boolean checkAESKey(KeyParameter aesKey) {
    checkNotNull(aesKey, "Cannot check null KeyParameter");
    checkState(getKeyCrypter() != null, "Key chain not encrypted");
    try {
        return rootKey.decrypt(aesKey).getPubKeyPoint().equals(rootKey.getPubKeyPoint());
    } catch (KeyCrypterException e) {
        return false;
    }
}
 
开发者ID:filipnyquist,项目名称:lbry-android,代码行数:11,代码来源:SimpleHDKeyChain.java

示例11: checkAESKey

import org.bitcoinj.crypto.KeyCrypterException; //导入依赖的package包/类
@Override
public boolean checkAESKey(KeyParameter aesKey) {
    checkNotNull(aesKey, "Cannot check null KeyParameter");
    checkNotNull(getKeyCrypter(), "Key not encrypted");
    try {
        return Arrays.equals(publicKey,
                Crypto.getPublicKey(entropy.decrypt(aesKey).getPrivKeyBytes()));
    } catch (KeyCrypterException e) {
        return false;
    }
}
 
开发者ID:filipnyquist,项目名称:lbry-android,代码行数:12,代码来源:NxtFamilyKey.java

示例12: doRaiseFee

import org.bitcoinj.crypto.KeyCrypterException; //导入依赖的package包/类
private void doRaiseFee(final KeyParameter encryptionKey)
{
    // construct child-pays-for-parent
    final TransactionOutput outputToSpend = checkNotNull(findSpendableOutput(wallet, transaction));
    final Transaction transactionToSend = new Transaction(Constants.NETWORK_PARAMETERS);
    transactionToSend.addInput(outputToSpend);
    transactionToSend.addOutput(outputToSpend.getValue().subtract(FEE_RAISE), wallet.freshAddress(KeyPurpose.CHANGE));
    transactionToSend.setPurpose(Transaction.Purpose.RAISE_FEE);

    final SendRequest sendRequest = SendRequest.forTx(transactionToSend);
    sendRequest.aesKey = encryptionKey;

    try
    {
        wallet.signTransaction(sendRequest);

        log.info("raise fee: cpfp {}", transactionToSend);

        wallet.commitTx(transactionToSend);
        application.broadcastTransaction(transactionToSend);

        state = State.DONE;
        updateView();

        dismiss();
    }
    catch (final KeyCrypterException x)
    {
        badPasswordView.setVisibility(View.VISIBLE);

        state = State.INPUT;
        updateView();

        passwordView.requestFocus();

        log.info("raise fee: bad spending password");
    }
}
 
开发者ID:soapboxsys,项目名称:ombuds-android,代码行数:39,代码来源:RaiseFeeDialogFragment.java

示例13: decrypt

import org.bitcoinj.crypto.KeyCrypterException; //导入依赖的package包/类
private static void decrypt() {
    if (password == null) {
        System.err.println("You must provide a --password");
        return;
    }
    if (!wallet.isEncrypted()) {
        System.err.println("This wallet is not encrypted.");
        return;
    }
    try {
        wallet.decrypt(password);
    } catch (KeyCrypterException e) {
        System.err.println("Password incorrect.");
    }
}
 
开发者ID:HashEngineering,项目名称:namecoinj,代码行数:16,代码来源:WalletTool.java

示例14: decryptWallet

import org.bitcoinj.crypto.KeyCrypterException; //导入依赖的package包/类
public void decryptWallet(BAPassword password) throws NoWalletPasswordException{
	if(isWalletEncrypted())
	if(password.hasPassword()){
		try {
			mWalletWrapper.decryptWallet(password.toString());
		}
		catch(KeyCrypterException returnException) { 
			throw new NoWalletPasswordException("Illegal Password");
		}
		LOG.info("Decrypted wallet with password: " + password.toString());
	}
	else
		throw new NoWalletPasswordException("Illegal Password");
}
 
开发者ID:BitcoinAuthenticator,项目名称:Wallet,代码行数:15,代码来源:WalletOperation.java

示例15: checkIfPasswordDecryptsWallet

import org.bitcoinj.crypto.KeyCrypterException; //导入依赖的package包/类
/**
    * Will check if the given password can decrypt the wallet.<br>
    * If wallet is encrypted, at the end of the check will keep the wallet encrypted.<br>
    * If wallet is not encrypted or the password does decrypt the wallet, this will return true;
    * 
    * @param password
    * @return
    * @throws NoWalletPasswordException 
    */
private boolean checkIfPasswordDecryptsWallet(BAPassword password){
	if(Authenticator.getWalletOperation().isWalletEncrypted()){
   		try{
   			Authenticator.getWalletOperation().decryptWallet(password);
   			Authenticator.getWalletOperation().encryptWallet(password);
   		}
   		catch(KeyCrypterException | NoWalletPasswordException  e){
   			return false;
   		} 	
   	}
	
	return true;
}
 
开发者ID:BitcoinAuthenticator,项目名称:Wallet,代码行数:23,代码来源:Controller.java


注:本文中的org.bitcoinj.crypto.KeyCrypterException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。