net.bither.bitherj.utils.Utils Java Examples

The following examples show how to use net.bither.bitherj.utils.Utils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VerifyMessagePanel.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
/**
 * Verify the message text against the address specified and update UI
 */
private void verifyMessage() {
    String addressText = WhitespaceTrimmer.trim(verifyingAddress.getText().trim());
    String messageText = messageTextArea.getText().trim();
    String signatureText = signatureTextArea.getText().trim();
    if (Utils.isEmpty(addressText) || Utils.isEmpty(messageText) || Utils.isEmpty(signatureText)) {
        new MessageDialog(LocaliserUtils.getString("verify_message_signature_verify_failed")).showMsg();
    } else {
        boolean isVerify = PrivateKeyUtil.verifyMessage(addressText, messageText, signatureText);
        if (isVerify) {
            new MessageDialog(LocaliserUtils.getString("verify_message_signature_verify_success")).showMsg();
        } else {
            new MessageDialog(LocaliserUtils.getString("verify_message_signature_verify_failed")).showMsg();
        }
    }
}
 
Example #2
Source File: SelectQRCodePanel.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
protected void fromFile() {
    clearMessage();
    startFileChooser(new IFileChooser() {
        @Override
        public void selectFile(final File file) {
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    if (file != null) {
                        String str = QRCodeEncoderDecoder.decode(file);
                        if (Utils.isEmpty(str)) {
                            setMsg(LocaliserUtils.getString("no_format_qr_code"));
                        } else {
                            scanQRCode.handleResult(str, SelectQRCodePanel.this);
                        }

                    }
                }
            });


        }
    });

}
 
Example #3
Source File: BackupUtil.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
private static ECKey getEckeyFormBackupHot(String address, CharSequence password) {
    File file = FileUtil.getBackupFile();
    String str = Utils.readFile(file);
    if (str.contains(address)) {
        String[] backupStrArray = str.split(PrivateKeyUtil.BACKUP_KEY_SPLIT_MUTILKEY_STRING);
        for (String backupStr : backupStrArray) {
            if (backupStr.contains(address)) {
                String[] strArray = QRCodeUtil.splitString(backupStr);
                if (strArray.length > 3) {
                    String keyString = backupStr.substring(strArray[0]
                            .length() + 1);
                    return PrivateKeyUtil.getECKeyFromSingleString(
                            keyString, password);
                }
            }
        }
    }
    return null;
}
 
Example #4
Source File: ScanTransportQRCodeDialog.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
public void handleResult(String result) {

        if (Utils.isEmpty(result)) {
            setMessage("No QR code");
        } else {
            if (resultValid(result)) {
                QRCodeTransportPage page = QRCodeTransportPage
                        .formatQrCodeTransport(result);
                pages.add(page);
                totalPage = page.getSumPage();
                if (page.getCurrentPage() < totalPage - 1) {
                    String str = String.format(LocaliserUtils.getString("scan_qr_transport_page_label"),
                            pages.size() + 1, totalPage);
                    setMessage(str);
                    //        startScan();
                } else {
                    complete();
                }
            } else {
                shake();
            }

        }

    }
 
Example #5
Source File: SelectQRCodePanel.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
protected void fromFile() {
    clearMessage();
    startFileChooser(new IFileChooser() {
        @Override
        public void selectFile(final File file) {
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    if (file != null) {
                        String str = QRCodeEncoderDecoder.decode(file);
                        if (Utils.isEmpty(str)) {
                            setMsg(LocaliserUtils.getString("no_format_qr_code"));
                        } else {
                            scanQRCode.handleResult(str, SelectQRCodePanel.this);
                        }

                    }
                }
            });


        }
    });

}
 
Example #6
Source File: SplitBCCHDAccountSendActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
@Override
protected void validateValues() {
    boolean isValidAmounts = false;
        btcAmount = getAmount(AbstractDb.hdAccountAddressProvider.getUnspentOutputByBlockNo(splitCoin.getForkBlockHeight(),
                AddressManager.getInstance().getHDAccountHot().getHdSeedId()));
    if (btcAmount > 0) {
        isValidAmounts = true;
    }
    toAddress = etAddress.getText().toString().trim();
    boolean isValidAddress = Utils.validSplitBitCoinAddress(toAddress,splitCoin);
    boolean isValidPassword = true;
    if (etPassword.getVisibility() == View.VISIBLE) {
        SecureCharSequence password = new SecureCharSequence(etPassword.getText());
        isValidPassword = Utils.validPassword(password) && password.length() >= 6 &&
                password.length() <= getResources().getInteger(R.integer.password_length_max);
        password.wipe();
    }
    btnSend.setEnabled(isValidAddress && isValidAmounts && isValidPassword);
}
 
Example #7
Source File: ScanTransportQRCodeDialog.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
public void handleResult(String result) {

        if (Utils.isEmpty(result)) {
            setMessage("No QR code");
        } else {
            if (resultValid(result)) {
                QRCodeTransportPage page = QRCodeTransportPage
                        .formatQrCodeTransport(result);
                pages.add(page);
                totalPage = page.getSumPage();
                if (page.getCurrentPage() < totalPage - 1) {
                    String str = String.format(LocaliserUtils.getString("scan_qr_transport_page_label"),
                            pages.size() + 1, totalPage);
                    setMessage(str);
                    //        startScan();
                } else {
                    complete();
                }
            } else {
                shake();
            }

        }

    }
 
Example #8
Source File: DialogImportPrivateKeyText.java    From bither-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(View v) {
    clickedId = v.getId();
    if (v.getId() == R.id.btn_ok) {
        String s = et.getText().toString();
        tvError.setText(R.string.import_private_key_text_format_error);
        if (Utils.isEmpty(s)) {
            tvError.setVisibility(View.VISIBLE);
            shake();
            return;
        } else if (!Utils.validBitcoinPrivateKey(s)) {
            tvError.setVisibility(View.VISIBLE);
            shake();
            return;
        }

        privateKeyString = et.getText().toString();
        dismiss();

    } else {
        dismiss();
    }
}
 
Example #9
Source File: ECKeyTest.java    From bitherj with Apache License 2.0 6 votes vote down vote up
@Override
public synchronized void nextBytes(byte[] bytes) {
    for (int i = 0; i < bytes.length; i++) {
        bytes[i] = 0;
    }
    if (index == 0) {
        System.out.println("call nextBytes: " + Utils.bytesToHexString(bytes));
    } else {
        SecureRandom secureRandom = new SecureRandom();
        secureRandom.nextBytes(bytes);

        assertTrue("use new bytes: " + Utils.bytesToHexString(bytes), index > 0);
    }
    index++;


}
 
Example #10
Source File: PeerListFragment.java    From bither-android with Apache License 2.0 6 votes vote down vote up
private void refreshPeer() {
    if (peerCacheList != null) {
        Collections.sort(peerCacheList, new Comparator<Peer>() {
            @Override
            public int compare(Peer lhs, Peer rhs) {
                if (lhs.getClientVersion() == 0 && rhs.getClientVersion() > 0) {
                    return 1;
                }
                if (rhs.getClientVersion() == 0 && lhs.getClientVersion() > 0) {
                    return -1;
                }
                return -1 * Long.valueOf(Utils.parseLongFromAddress(
                        lhs.getPeerAddress())).compareTo(
                        Long.valueOf(Utils.parseLongFromAddress(rhs.getPeerAddress())));

            }
        });
        for (final Peer peer : peerCacheList) {
            adapter.add(peer);
        }
    }
}
 
Example #11
Source File: BCCAssetsHDAccountMonitoredActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
@Override
protected void validateValues() {
    boolean isValidAmounts = false;
    btcAmount = getAmount(outs);
    if (btcAmount > 0) {
        isValidAmounts = true;
    }
    toAddress = etAddress.getText().toString().trim();
    boolean isValidAddress = Utils.validBicoinAddress(toAddress);
    boolean isValidPassword = true;
    if (etPassword.getVisibility() == View.VISIBLE) {
        SecureCharSequence password = new SecureCharSequence(etPassword.getText());
        isValidPassword = Utils.validPassword(password) && password.length() >= 6 &&
                password.length() <= getResources().getInteger(R.integer.password_length_max);
        password.wipe();
    }
    btnSend.setEnabled(isValidAddress && isValidAmounts && isValidPassword);
}
 
Example #12
Source File: SendBitcoinPanel.java    From bither-desktop-java with Apache License 2.0 6 votes vote down vote up
protected void onSend() {
    bitcoinAddress = tfAddress.getText().trim();
    if (Utils.validBicoinAddress(bitcoinAddress)) {
        if (Utils.compareString(bitcoinAddress, changeAddress)) {
            new MessageDialog(LocaliserUtils.getString("select_change_address_change_to_same_warn")).showMsg();
            return;
        }
        String amtString = tfAmt.getText().trim();
        long btc = GenericUtils.toNanoCoins(amtString, 0).longValue();
        try {
            SecureCharSequence secureCharSequence = new SecureCharSequence(currentPassword.getPassword());
            CompleteTransactionRunnable completeTransactionRunnable = new CompleteTransactionRunnable(
                    Bither.getActionAddress(), btc, bitcoinAddress, changeAddress, secureCharSequence);
            completeTransactionRunnable.setRunnableListener(completeTransactionListener);
            new Thread(completeTransactionRunnable).start();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
 
Example #13
Source File: HDAccountMonitoredSendActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
@Override
protected void sendClicked() {
    final long btc = amountCalculatorLink.getAmount();
    if (btc > 0) {
        btcAmount = btc;
        tx = null;
        String address = etAddress.getText().toString().trim();
        if (Utils.validBicoinAddress(address)) {
            toAddress = address;
            if (!dp.isShowing()) {
                dp.show();
            }
            new Thread() {
                @Override
                public void run() {
                    send();
                }
            }.start();
        } else {
            DropdownMessage.showDropdownMessage(HDAccountMonitoredSendActivity.this, R.string
                    .send_failed);
        }
    }
}
 
Example #14
Source File: PeerAddress.java    From bitherj with Apache License 2.0 6 votes vote down vote up
@Override
protected void bitcoinSerializeToStream(OutputStream stream) throws IOException {
    if (protocolVersion >= 31402) {
        //TODO this appears to be dynamic because the client only ever sends out it's own address
        //so assumes itself to be up.  For a fuller implementation this needs to be dynamic only if
        //the address refers to this client.
        int secs = (int) (Utils.currentTimeMillis() / 1000);
        uint32ToByteStreamLE(secs, stream);
    }
    uint64ToByteStreamLE(services, stream);  // nServices.
    // Java does not provide any utility to map an IPv4 address into IPv6 space, so we have to do it by hand.
    byte[] ipBytes = addr.getAddress();
    if (ipBytes.length == 4) {
        byte[] v6addr = new byte[16];
        System.arraycopy(ipBytes, 0, v6addr, 12, 4);
        v6addr[10] = (byte) 0xFF;
        v6addr[11] = (byte) 0xFF;
        ipBytes = v6addr;
    }
    stream.write(ipBytes);
    // And write out the port. Unlike the rest of the protocol, address and port is in big endian byte order.
    stream.write((byte) (0xFF & port >> 8));
    stream.write((byte) (0xFF & port));
}
 
Example #15
Source File: ScanQRCodeTransportActivity.java    From bither-android with Apache License 2.0 6 votes vote down vote up
@Override
public boolean resultValid(String result) {
       boolean repeated = true;
	if (!Utils.compareString(result, lastResult)) {
           repeated = false;
		shake();
	}
	lastResult = result;
	QRCodeTransportPage page = QRCodeTransportPage
			.formatQrCodeTransport(result);
	if (page == null) {
           if (!repeated && Utils.validBicoinAddress(result) && Utils.compareString(tvTitle.getText()
                   .toString(), getString(R.string.scan_for_all_addresses_in_bither_cold_title))) {
               DropdownMessage.showDropdownMessage(this,
                       R.string.add_address_watch_only_scanned_address_warning);
           }
           return false;
       }
       if (page.getCurrentPage() == pages.size()) {
           return true;
       }
	return false;
}
 
Example #16
Source File: SendHDMBitcoinPanel.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
public boolean setQrCodeResult(String qr) {

            if (!Utils.isEmpty(qr)) {
                try {
                    String[] stringArray = QRCodeUtil.splitString(qr);
                    sigs = new ArrayList<TransactionSignature>();
                    for (String str : stringArray) {
                        if (!Utils.isEmpty(str)) {
                            TransactionSignature transactionSignature = new
                                    TransactionSignature(ECKey.ECDSASignature.decodeFromDER
                                    (Utils.hexStringToByteArray(str)),
                                    TransactionSignature.SigHash.ALL, false);
                            sigs.add(transactionSignature);
                        }
                    }
                } catch (Exception e) {
                    sigs = null;
                    e.printStackTrace();
                    new MessageDialog(LocaliserUtils.getString("send_failed")).showMsg();
                }
            } else {
                sigs = null;
            }
            try {
                lock.lock();
                fetchedCondition.signal();
            } finally {
                lock.unlock();
            }
            return true;

        }
 
Example #17
Source File: AddEnterpriseHDMSeedActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == ImportFromQRTag) {
        final String seedStr = data.getStringExtra(ScanActivity.INTENT_EXTRA_RESULT);
        if (seedStr.indexOf(QRCodeUtil.Enterprise_HDM_QR_CODE_FLAG) == 0) {
            DialogPassword dialogPassword = new DialogPassword(this, new
                    ImportSeedPasswordListener(seedStr));
            dialogPassword.setCheckPre(false);
            dialogPassword.setCheckPasswordListener(new ICheckPasswordListener() {
                @Override
                public boolean checkPassword(SecureCharSequence password) {
                    String keyString = seedStr.substring(1);
                    String[] passwordSeeds = QRCodeUtil.splitOfPasswordSeed(keyString);
                    String encreyptString = Utils.joinString(new String[]{passwordSeeds[0],
                            passwordSeeds[1], passwordSeeds[2]}, QRCodeUtil.QR_CODE_SPLIT);
                    EncryptedData encryptedData = new EncryptedData(encreyptString);
                    byte[] result = null;
                    try {
                        result = encryptedData.decrypt(password);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    return result != null;
                }
            });
            dialogPassword.setTitle(R.string.import_private_key_qr_code_password);
            dialogPassword.show();
        } else {
            DropdownMessage.showDropdownMessage(AddEnterpriseHDMSeedActivity.this, R.string
                    .enterprise_hdm_seed_import_format_error);
        }
        return;
    }
    super.onActivityResult(requestCode, resultCode, data);
}
 
Example #18
Source File: ScanQRCodeWithOtherActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
@Override
public boolean resultValid(String result) {
    boolean isValid = qrCodeType.checkFormat(result);
    if (!isValid) {
        if (!Utils.compareString(lastResult, result)) {
            shake();
            lastResult = result;
        }
    }
    return isValid;
}
 
Example #19
Source File: PasswordSeed.java    From bitherj with Apache License 2.0 5 votes vote down vote up
public boolean checkPassword(CharSequence password) {
    ECKey ecKey = PrivateKeyUtil.getECKeyFromSingleString(keyStr, password);
    String ecKeyAddress;
    if (ecKey == null) {
        return false;
    } else {
        ecKeyAddress = ecKey.toAddress();
        ecKey.clearPrivateKey();
    }
    return Utils.compareString(this.address,
            ecKeyAddress);

}
 
Example #20
Source File: BtcToMoneyTextView.java    From bither-android with Apache License 2.0 5 votes vote down vote up
private void refreshText() {
	getPrice();
	if (btc != null) {
		if (price == 0) {
			setText(BitherSetting.UNKONW_ADDRESS_STRING);
		} else {
			double money = btc.doubleValue() / 100000000.0 * price;
			setText(AppSharedPreference.getInstance()
					.getDefaultExchangeType().getSymbol()
					+ Utils.formatDoubleToMoneyString(money));
		}
	} else {
		setText(BitherSetting.UNKONW_ADDRESS_STRING);
	}
}
 
Example #21
Source File: InputParser.java    From bither-android with Apache License 2.0 5 votes vote down vote up
@Override
public void parse() {
    if (input.startsWith("bitcoin:")) {
        try {
            final BitcoinURI bitcoinUri = new BitcoinURI(input);
            final String address = bitcoinUri.getAddress();
            final String addressLabel = bitcoinUri.getLabel();
            final long amount = bitcoinUri.getAmount();
            final String bluetoothMac = (String) bitcoinUri.getParameterByName(Bluetooth
                    .MAC_URI_PARAM);
            bitcoinRequest(address, addressLabel, amount, bluetoothMac);
        } catch (final BitcoinURI.BitcoinURIParseException x) {
            error(R.string.input_parser_invalid_bitcoin_uri, input);
        }
    } else if (PATTERN_BITCOIN_ADDRESS.matcher(input).matches() && splitCoin != null) {
        if (Utils.validSplitBitCoinAddress(input, splitCoin)) {
            bitcoinRequest(input, null, 0, null);
        } else {
            error(R.string.scan_watch_only_address_error);
        }
    } else if (PATTERN_BITCOIN_ADDRESS.matcher(input).matches()) {
        if (Utils.validBicoinAddress(input)) {
            bitcoinRequest(input, null, 0, null);
        } else {
            error(R.string.scan_watch_only_address_error);
        }
    } else if (input.toLowerCase().startsWith(BitcoinNewAddressPrefix) && Bech32.decode(input) != null) {
        if (isColdSendBtc) {
            error(R.string.cold_no_support_bc1_segwit_address);
        } else {
            bitcoinRequest(input.toLowerCase(), null, 0, null);
        }
    } else {
        error(R.string.scan_watch_only_address_error);
    }
}
 
Example #22
Source File: HDAccount.java    From bitherj with Apache License 2.0 5 votes vote down vote up
public void decryptMnemonicSeed(CharSequence password) throws KeyCrypterException {
    if (hdSeedId < 0) {
        return;
    }
    String encrypted = getEncryptedMnemonicSeed();
    if (!Utils.isEmpty(encrypted)) {
        mnemonicSeed = new EncryptedData(encrypted).decrypt(password);
    }
}
 
Example #23
Source File: AddAddressWatchOnlyView.java    From bither-android with Apache License 2.0 5 votes vote down vote up
public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == BitherSetting.INTENT_REF.SCAN_ALL_IN_BITHER_COLD_REUEST_CODE
            && resultCode == Activity.RESULT_OK) {
        if (data.getExtras().containsKey(ScanActivity.INTENT_EXTRA_RESULT)) {
            final String content = data
                    .getStringExtra(ScanActivity.INTENT_EXTRA_RESULT);
            if (Utils.isEmpty(content) ||
                    !QRCodeEnodeUtil.checkPubkeysQRCodeContent(content)) {
                DropdownMessage
                        .showDropdownMessage(
                                activity,
                                R.string.scan_for_all_addresses_in_bither_cold_failed);
                return true;
            }
            ThreadNeedService thread = new ThreadNeedService(dp, activity) {

                @Override
                public void runWithService(BlockchainService service) {
                    processQrCodeContent(content, service);
                }
            };
            thread.start();
        }
        return true;
    }
    return false;
}
 
Example #24
Source File: EnterpriseHDMSendActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
private String getChangeAddress() {
    String change = dialogSelectChangeAddress.getChangeAddress().getAddress();
    if (Utils.compareString(change, address.getAddress())) {
        return null;
    }
    return change;
}
 
Example #25
Source File: ECKey.java    From bitherj with Apache License 2.0 5 votes vote down vote up
/**
 * Given an arbitrary piece of text and a Bitcoin-format message signature encoded in base64, returns an ECKey
 * containing the public key that was used to sign it. This can then be compared to the expected public key to
 * determine if the signature was correct. These sorts of signatures are compatible with the Bitcoin-Qt/bitcoind
 * format generated by signmessage/verifymessage RPCs and GUI menu options. They are intended for humans to verify
 * their communications with each other, hence the base64 format and the fact that the input is text.
 *
 * @param message         Some piece of human readable text.
 * @param signatureBase64 The Bitcoin-format message signature in base64
 * @throws java.security.SignatureException If the public key could not be recovered or if there was a signature format error.
 */
public static ECKey signedMessageToKey(String message, String signatureBase64) throws SignatureException {
    byte[] signatureEncoded;
    try {
        signatureEncoded = Base64.decode(signatureBase64);
    } catch (RuntimeException e) {
        // This is what you get back from Bouncy Castle if base64 doesn't decode :(
        throw new SignatureException("Could not decode base64", e);
    }
    byte[] messageBytes = Utils.formatMessageForSigning(message);
    return signedMessageToKey(messageBytes, signatureEncoded);

}
 
Example #26
Source File: VerifyMessageSignatureActivity.java    From bither-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    final String address = etAddress.getText().toString().trim();
    final String message = etMessage.getText().toString().trim();
    final String signature = etSignature.getText().toString().trim();
    if (Utils.isEmpty(address) || Utils.isEmpty(message) || Utils.isEmpty(signature)) {
        return;
    }
    imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
    setVerifyButtonVerifying();
    new Thread() {
        @Override
        public void run() {
            signed = PrivateKeyUtil.verifyMessage(address, message, signature);
            btnVerify.post(new Runnable() {
                @Override
                public void run() {
                    if(signed){
                        setVerifyButtonSuccess();
                    }else{
                        setVerifyButtonFailed();
                    }
                    DropdownMessage.showDropdownMessage(VerifyMessageSignatureActivity
                                    .this,
                            signed ? R.string.verify_message_signature_verify_success : R
                                    .string.verify_message_signature_verify_failed);
                }
            });
        }
    }.start();
}
 
Example #27
Source File: HDMKeychain.java    From bitherj with Apache License 2.0 5 votes vote down vote up
public static boolean checkPassword(String keysString, CharSequence password) throws
        MnemonicException.MnemonicLengthException {
    String[] passwordSeeds = QRCodeUtil.splitOfPasswordSeed(keysString);
    String address = Base58.hexToBase58WithAddress(passwordSeeds[0]);
    String encreyptString = Utils.joinString(new String[]{passwordSeeds[1], passwordSeeds[2],
            passwordSeeds[3]}, QRCodeUtil.QR_CODE_SPLIT);
    byte[] seed = new EncryptedData(encreyptString).decrypt(password);
    MnemonicCode mnemonic = MnemonicCode.instance();

    byte[] s = mnemonic.toSeed(mnemonic.toMnemonic(seed), "");

    DeterministicKey master = HDKeyDerivation.createMasterPrivateKey(s);

    DeterministicKey purpose = master.deriveHardened(44);

    DeterministicKey coinType = purpose.deriveHardened(0);

    DeterministicKey account = coinType.deriveHardened(0);

    DeterministicKey external = account.deriveSoftened(0);

    external.clearPrivateKey();

    DeterministicKey key = external.deriveSoftened(0);
    boolean result = Utils.compareString(address, Utils.toAddress(key.getPubKeyHash()));
    key.wipe();

    return result;
}
 
Example #28
Source File: SignatureHDMApi.java    From bitherj with Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, String> getParams() throws Exception {
    Map<String, String> params = new HashMap<String, String>();
    params.put(HttpSetting.PASSWORD, Utils.base64Encode(password));
    params.put(HttpSetting.UNSIGN, Utils.encodeBytesForService(unSigns));
    return params;
}
 
Example #29
Source File: SendHDMBitcoinPanel.java    From bither-desktop-java with Apache License 2.0 5 votes vote down vote up
@Override
public void initialiseContent(JPanel panel) {
    panel.setLayout(new MigLayout(
            Panels.migXYLayout(),
            "[]", // Column constraints
            "[][][][]" // Row constraints
    ));

    JLabel label = Labels.newValueLabel(LocaliserUtils.getString("address_balance") + " : " + Utils.bitcoinValueToPlainString(Bither.getActionAddress().getBalance()));
    panel.add(label, "align center,wrap");
    panel.add(newEnterAddressPanel(), "push,wrap");
    panel.add(newAmountPanel(), "push,wrap");
    panel.add(getenterPasswordMaV(), "push,wrap");
    if (!hdmAddress.isInRecovery()) {
        JButton btnSwitchCold = Buttons.newNormalButton(new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                signWithCold = true;
                onOK();
            }
        }, MessageKey.hdm_send_with_cold, AwesomeIcon.QRCODE);
        panel.add(btnSwitchCold, "push ,align right,shrink");
    }
    if (!Utils.isEmpty(this.doateAddress)) {
        tfAddress.setText(this.doateAddress);
    }
    validateValues();


}
 
Example #30
Source File: DownloadAvatarRunnable.java    From bither-android with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    String avatar = AppSharedPreference.getInstance().getUserAvatar();
    if (!Utils.isEmpty(avatar)) {
        try {
            File file = ImageFileUtil.getSmallAvatarFile(avatar);
            if (!file.exists()) {
                DownloadFile downloadFile = new DownloadFile();
                downloadFile.downloadFile(BitherUrl.BITHER_DOWNLOAD_AVATAR, file);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}