use of org.bitcoinj.core.DumpedPrivateKey in project bitcoin-wallet by bitcoin-wallet.
the class SweepWalletFragment method maybeDecodeKey.
private void maybeDecodeKey() {
checkState(state == State.DECODE_KEY);
checkState(privateKeyToSweep != null);
if (privateKeyToSweep instanceof DumpedPrivateKey) {
final ECKey key = ((DumpedPrivateKey) privateKeyToSweep).getKey();
askConfirmSweep(key);
} else if (privateKeyToSweep instanceof BIP38PrivateKey) {
badPasswordView.setVisibility(View.INVISIBLE);
final String password = passwordView.getText().toString().trim();
// get rid of it asap
passwordView.setText(null);
if (!password.isEmpty()) {
ProgressDialogFragment.showProgress(fragmentManager, getString(R.string.sweep_wallet_fragment_decrypt_progress));
new DecodePrivateKeyTask(backgroundHandler) {
@Override
protected void onSuccess(ECKey decryptedKey) {
log.info("successfully decoded BIP38 private key");
ProgressDialogFragment.dismissProgress(fragmentManager);
askConfirmSweep(decryptedKey);
}
@Override
protected void onBadPassphrase() {
log.info("failed decoding BIP38 private key (bad password)");
ProgressDialogFragment.dismissProgress(fragmentManager);
badPasswordView.setVisibility(View.VISIBLE);
passwordView.requestFocus();
}
}.decodePrivateKey((BIP38PrivateKey) privateKeyToSweep, password);
}
} else {
throw new IllegalStateException("cannot handle type: " + privateKeyToSweep.getClass().getName());
}
}
use of org.bitcoinj.core.DumpedPrivateKey in project elastic-core-maven by OrdinaryDude.
the class RedeemTest method redeem_different_sig_and_receipient.
private static boolean redeem_different_sig_and_receipient(String address_entry, String secretPhrase, long accountId, String[] bitcoin_privkeys, boolean graceblock) {
String secp_signatures = "";
NetworkParameters params = MainNetParams.get();
long target_id = Account.getId(Crypto.getPublicKey(secretPhrase));
String message = Redeem.getSignMessage(Redeem.getClaimableAmount(address_entry), address_entry, target_id);
// Sign inputs
for (int i = 0; i < bitcoin_privkeys.length; ++i) {
ECKey key;
DumpedPrivateKey dumpedPrivateKey = DumpedPrivateKey.fromBase58(params, bitcoin_privkeys[i]);
key = dumpedPrivateKey.getKey();
String signed = key.signMessage(message);
bitcoin_privkeys[i] = signed;
}
secp_signatures = String.join("-", bitcoin_privkeys);
final Attachment attachment = new Attachment.RedeemAttachment(address_entry, secp_signatures);
boolean success = false;
try {
make(attachment, secretPhrase, accountId, Redeem.getClaimableAmount(address_entry), true, graceblock);
success = true;
} catch (Exception e) {
Logger.logErrorMessage(e.getMessage());
}
return success;
}
use of org.bitcoinj.core.DumpedPrivateKey in project elastic-core-maven by OrdinaryDude.
the class RedeemFunctions method redeem.
public static boolean redeem(String address_entry, String secretPhrase, String[] bitcoin_privkeys, boolean graceblock) {
String secp_signatures = "";
NetworkParameters params = MainNetParams.get();
long target_id = Account.getId(Crypto.getPublicKey(secretPhrase));
String message = Redeem.getSignMessage(Redeem.getClaimableAmount(address_entry), address_entry, target_id);
// Sign inputs
for (int i = 0; i < bitcoin_privkeys.length; ++i) {
ECKey key;
DumpedPrivateKey dumpedPrivateKey = DumpedPrivateKey.fromBase58(params, bitcoin_privkeys[i]);
key = dumpedPrivateKey.getKey();
String signed = key.signMessage(message);
bitcoin_privkeys[i] = signed;
}
secp_signatures = String.join("-", bitcoin_privkeys);
final Attachment attachment = new Attachment.RedeemAttachment(address_entry, secp_signatures);
boolean success = false;
try {
make(attachment, secretPhrase, Account.getId(Crypto.getPublicKey(secretPhrase)), Redeem.getClaimableAmount(address_entry), true, graceblock);
success = true;
} catch (Exception e) {
Logger.logErrorMessage(e.getMessage());
}
return success;
}
Aggregations