org.bitcoinj.core.Address.toString()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(148)

本文整理了Java中org.bitcoinj.core.Address.toString()方法的一些代码示例,展示了Address.toString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Address.toString()方法的具体详情如下:
包路径:org.bitcoinj.core.Address
类名称:Address
方法名:toString

Address.toString介绍

暂无

代码示例

代码示例来源:origin: Multibit-Legacy/multibit-hd

  1. /**
  2. * @return The contact name if present, otherwise the Bitcoin address
  3. */
  4. public String getSummary() {
  5. if (contact.isPresent()) {
  6. return contact.get().getName();
  7. }
  8. // The Base58 representation of this address
  9. return bitcoinAddress.toString();
  10. }
  11. }

代码示例来源:origin: uncleleonfan/FunWallet

  1. @Override
  2. public void run() {
  3. Coin balance = wallet.getBalance(Wallet.BalanceType.ESTIMATED);
  4. mAddressText.setText(address.toString());
  5. String balanceString = String.valueOf(balance.value / 100000) + " mBTC";
  6. mBalanceText.setText(balanceString);
  7. BitmapDrawable bitmapDrawable = new BitmapDrawable(getResources(), bitmap);
  8. bitmapDrawable.setFilterBitmap(false);
  9. mQrImageView.setImageDrawable(bitmapDrawable);
  10. }
  11. });

代码示例来源:origin: cash.bitcoinj/bitcoinj-core

  1. /**
  2. * Simple Bitcoin URI builder using known good fields.
  3. *
  4. * @param address The Bitcoin address
  5. * @param amount The amount
  6. * @param label A label
  7. * @param message A message
  8. * @return A String containing the Bitcoin URI
  9. */
  10. public static String convertToBitcoinURI(Address address, Coin amount,
  11. String label, String message) {
  12. return convertToBitcoinURI(address.getParameters(), address.toString(), amount, label, message);
  13. }

代码示例来源:origin: fr.acinq/bitcoinj-core

  1. /**
  2. * Simple Bitcoin URI builder using known good fields.
  3. *
  4. * @param address The Bitcoin address
  5. * @param amount The amount
  6. * @param label A label
  7. * @param message A message
  8. * @return A String containing the Bitcoin URI
  9. */
  10. public static String convertToBitcoinURI(Address address, Coin amount,
  11. String label, String message) {
  12. return convertToBitcoinURI(address.getParameters(), address.toString(), amount, label, message);
  13. }

代码示例来源:origin: Multibit-Legacy/multibit-hd

  1. private void selectNameOrBitcoinAddress(Optional<Recipient> recipient) {
  2. if (recipient.get().getContact().isPresent()) {
  3. editor.setText(recipient.get().getContact().get().getName());
  4. } else {
  5. editor.setText(recipient.get().getBitcoinAddress().toString());
  6. }
  7. }

代码示例来源:origin: cash.bitcoinj/bitcoinj-core

  1. public ECKey decrypt(String passphrase) throws BadPassphraseException {
  2. String normalizedPassphrase = Normalizer.normalize(passphrase, Normalizer.Form.NFC);
  3. ECKey key = ecMultiply ? decryptEC(normalizedPassphrase) : decryptNoEC(normalizedPassphrase);
  4. Sha256Hash hash = Sha256Hash.twiceOf(key.toAddress(params).toString().getBytes(Charsets.US_ASCII));
  5. byte[] actualAddressHash = Arrays.copyOfRange(hash.getBytes(), 0, 4);
  6. if (!Arrays.equals(actualAddressHash, addressHash))
  7. throw new BadPassphraseException();
  8. return key;
  9. }

代码示例来源:origin: fr.acinq/bitcoinj-core

  1. public ECKey decrypt(String passphrase) throws BadPassphraseException {
  2. String normalizedPassphrase = Normalizer.normalize(passphrase, Normalizer.Form.NFC);
  3. ECKey key = ecMultiply ? decryptEC(normalizedPassphrase) : decryptNoEC(normalizedPassphrase);
  4. Sha256Hash hash = Sha256Hash.twiceOf(key.toAddress(params).toString().getBytes(Charsets.US_ASCII));
  5. byte[] actualAddressHash = Arrays.copyOfRange(hash.getBytes(), 0, 4);
  6. if (!Arrays.equals(actualAddressHash, addressHash))
  7. throw new BadPassphraseException();
  8. return key;
  9. }

代码示例来源:origin: greenaddress/GreenBits

  1. public ECKey decrypt(String passphrase) throws BadPassphraseException {
  2. String normalizedPassphrase = Normalizer.normalize(passphrase, Normalizer.Form.NFC);
  3. ECKey key = ecMultiply ? decryptEC(normalizedPassphrase) : decryptNoEC(normalizedPassphrase);
  4. Sha256Hash hash = Sha256Hash.twiceOf(key.toAddress(params).toString().getBytes(Charsets.US_ASCII));
  5. byte[] actualAddressHash = Arrays.copyOfRange(hash.getBytes(), 0, 4);
  6. if (!Arrays.equals(actualAddressHash, addressHash))
  7. throw new BadPassphraseException();
  8. return key;
  9. }

代码示例来源:origin: greenaddress/GreenBits

  1. @Test
  2. public void comparisonBytesVsString() throws Exception {
  3. // TODO: To properly test this we need a much larger data set
  4. Address a = Address.fromBase58(mainParams, "1Dorian4RoXcnBv9hnQ4Y2C1an6NJ4UrjX");
  5. Address b = Address.fromBase58(mainParams, "1EXoDusjGwvnjZUyKkxZ4UHEf77z6A5S4P");
  6. int resultBytes = a.compareTo(b);
  7. int resultsString = a.toString().compareTo(b.toString());
  8. assertTrue( resultBytes < 0 );
  9. assertTrue( resultsString < 0 );
  10. }
  11. }

代码示例来源:origin: greenaddress/GreenBits

  1. @Test
  2. public void stringification() throws Exception {
  3. // Test a testnet address.
  4. Address a = new Address(testParams, HEX.decode("fda79a24e50ff70ff42f7d89585da5bd19d9e5cc"));
  5. assertEquals("n4eA2nbYqErp7H6jebchxAN59DmNpksexv", a.toString());
  6. assertFalse(a.isP2SHAddress());
  7. Address b = new Address(mainParams, HEX.decode("4a22c3c4cbb31e4d03b15550636762bda0baf85a"));
  8. assertEquals("17kzeh4N8g49GFvdDzSf8PjaPfyoD1MndL", b.toString());
  9. assertFalse(b.isP2SHAddress());
  10. }

代码示例来源:origin: DanielKrawisz/Shufflepuff

  1. @Test
  2. public void testSend() throws Exception {
  3. WalletAppKit nomKit = bitcoinCryptoNoP.getKit();
  4. Wallet wallet = nomKit.wallet();
  5. System.out.println("Current Receive Address: " + wallet.currentReceiveAddress().toString() + "\nIssued Receive Addresses: \n" + wallet.getIssuedReceiveAddresses().toString() + "\nMnemonic: " + wallet.getActiveKeychain().getMnemonicCode().toString() + "\nWallets Balance: " + wallet.getBalance().toPlainString() + " BTC");
  6. // Get a ready to send TX in its Raw HEX format
  7. System.out.println("Raw TX HEX: " + bitcoinCryptoNoP.sendOffline("n2ooxjPCQ19f56ivrCBq93DM6a71TA89bc", 10000));
  8. // Create and send transaciton using the wallets broadcast
  9. org.bitcoinj.core.Transaction sentTransaction = bitcoinCryptoNoP.send("n2ooxjPCQ19f56ivrCBq93DM6a71TA89bc", 10000);
  10. System.out.println("Transaction sent. Find txid: " + sentTransaction.getHashAsString());
  11. }

代码示例来源:origin: greenaddress/GreenBits

  1. @Test
  2. public void testScriptSig() throws Exception {
  3. byte[] sigProgBytes = HEX.decode(sigProg);
  4. Script script = new Script(sigProgBytes);
  5. // Test we can extract the from address.
  6. byte[] hash160 = Utils.sha256hash160(script.getPubKey());
  7. Address a = new Address(PARAMS, hash160);
  8. assertEquals("mkFQohBpy2HDXrCwyMrYL5RtfrmeiuuPY2", a.toString());
  9. }

代码示例来源:origin: greenaddress/GreenBits

  1. @Test
  2. public void testScriptPubKey() throws Exception {
  3. // Check we can extract the to address
  4. byte[] pubkeyBytes = HEX.decode(pubkeyProg);
  5. Script pubkey = new Script(pubkeyBytes);
  6. assertEquals("DUP HASH160 PUSHDATA(20)[33e81a941e64cda12c6a299ed322ddbdd03f8d0e] EQUALVERIFY CHECKSIG", pubkey.toString());
  7. Address toAddr = new Address(PARAMS, pubkey.getPubKeyHash());
  8. assertEquals("mkFQohBpy2HDXrCwyMrYL5RtfrmeiuuPY2", toAddr.toString());
  9. }

代码示例来源:origin: Coinomi/coinomi-android

  1. @Test
  2. public void testMini() throws Exception {
  3. SerializedKey serializedKey = new SerializedKey(BTC_MINI_PRIV);
  4. assertFalse(serializedKey.isEncrypted());
  5. SerializedKey.TypedKey key = serializedKey.getKey();
  6. assertTrue(key.possibleType.contains(BTC));
  7. assertEquals(BTC_MINI_ADDR, key.key.toAddress(BTC).toString());
  8. }
  9. }

代码示例来源:origin: Coinomi/coinomi-android

  1. @Test
  2. public void testWif() throws Exception {
  3. SerializedKey serializedKey = new SerializedKey(BTC_WIF_PRIV);
  4. assertFalse(serializedKey.isEncrypted());
  5. SerializedKey.TypedKey key = serializedKey.getKey();
  6. assertTrue(key.possibleType.contains(BTC));
  7. assertEquals(BTC_WIF_ADDR, key.key.toAddress(BTC).toString());
  8. }

代码示例来源:origin: openwalletGH/openwallet-android

  1. @Test
  2. public void testMini() throws Exception {
  3. SerializedKey serializedKey = new SerializedKey(BTC_MINI_PRIV);
  4. assertFalse(serializedKey.isEncrypted());
  5. SerializedKey.TypedKey key = serializedKey.getKey();
  6. assertTrue(key.possibleType.contains(BTC));
  7. assertEquals(BTC_MINI_ADDR, key.key.toAddress(BTC).toString());
  8. }
  9. }

代码示例来源:origin: openwalletGH/openwallet-android

  1. @Test
  2. public void testWif() throws Exception {
  3. SerializedKey serializedKey = new SerializedKey(BTC_WIF_PRIV);
  4. assertFalse(serializedKey.isEncrypted());
  5. SerializedKey.TypedKey key = serializedKey.getKey();
  6. assertTrue(key.possibleType.contains(BTC));
  7. assertEquals(BTC_WIF_ADDR, key.key.toAddress(BTC).toString());
  8. }

代码示例来源:origin: greenaddress/GreenBits

  1. @Test
  2. public void brokenURIs() throws BitcoinURIParseException {
  3. // Check we can parse the incorrectly formatted URIs produced by blockchain.info and its iPhone app.
  4. String str = "bitcoin://1KzTSfqjF2iKCduwz59nv2uqh1W2JsTxZH?amount=0.01000000";
  5. BitcoinURI uri = new BitcoinURI(str);
  6. assertEquals("1KzTSfqjF2iKCduwz59nv2uqh1W2JsTxZH", uri.getAddress().toString());
  7. assertEquals(CENT, uri.getAmount());
  8. }

代码示例来源:origin: greenaddress/GreenBits

  1. @Test
  2. public void base58Encoding() throws Exception {
  3. String addr = "mqAJmaxMcG5pPHHc3H3NtyXzY7kGbJLuMF";
  4. String privkey = "92shANodC6Y4evT5kFzjNFQAdjqTtHAnDTLzqBBq4BbKUPyx6CD";
  5. ECKey key = DumpedPrivateKey.fromBase58(TestNet3Params.get(), privkey).getKey();
  6. assertEquals(privkey, key.getPrivateKeyEncoded(TestNet3Params.get()).toString());
  7. assertEquals(addr, key.toAddress(TestNet3Params.get()).toString());
  8. }

代码示例来源:origin: greenaddress/GreenBits

  1. @Test
  2. public void testP2SHOutputScript() throws Exception {
  3. String P2SHAddressString = "35b9vsyH1KoFT5a5KtrKusaCcPLkiSo1tU";
  4. Address P2SHAddress = Address.fromBase58(MainNetParams.get(), P2SHAddressString);
  5. Script script = ScriptBuilder.createOutputScript(P2SHAddress);
  6. Transaction tx = new Transaction(MainNetParams.get());
  7. tx.addOutput(Coin.COIN, script);
  8. assertEquals(P2SHAddressString, tx.getOutput(0).getAddressFromP2SH(MainNetParams.get()).toString());
  9. }

相关文章