@Test public void testFormatAsBitcoinSignedMessage() throws Exception { String actual = BitcoinMessages.formatAsBitcoinSignedMessage( "16R2kAxaUNM4xj6ykKbxEugpJdYyJzTP13", "Hello World", "H0b22gIQIfutUzm7Z9qchdfhUtaO52alhNPK3emrkGOfbOzGHVPuWD9rMIphxniwBNgF/YN4c5C/dMwXz3yJz5k=" ); FixtureAsserts.assertStringMatchesNormalisedStringFixture( "Unexpected formatting of Bitcoin signed message", actual, "/fixtures/messages/test-simple.txt"); }
public static String formatAsBitcoinSignedMessage( String addressText, String message, String signature ) { final Address signingAddress; try { signingAddress = new Address(BitcoinNetwork.current().get(), addressText); } catch (AddressFormatException e) { return ""; } String versionField = VERSION + ": MultiBit HD (" + Configurations.currentConfiguration.getCurrentVersion() + ")"; String commentField = COMMENT + ": https: String addressField = ADDRESS + ": " + signingAddress.toString(); return String.format( "-----%s-----%n%s%n-----%s-----%n%s%n%s%n%s%n%n%s%n-----%s-----%n", BEGIN_SIGNED_MESSAGE, message, BEGIN_SIGNATURE, versionField, commentField, addressField, signature, END_BITCOIN_SIGNATURE ); }
BitcoinMessages { public static String formatAsBitcoinSignedMessage( String addressText, String message, String signature ) { final Address signingAddress; try { signingAddress = new Address(BitcoinNetwork.current().get(), addressText); } catch (AddressFormatException e) { return ""; } String versionField = VERSION + ": MultiBit HD (" + Configurations.currentConfiguration.getCurrentVersion() + ")"; String commentField = COMMENT + ": https: String addressField = ADDRESS + ": " + signingAddress.toString(); return String.format( "-----%s-----%n%s%n-----%s-----%n%s%n%s%n%s%n%n%s%n-----%s-----%n", BEGIN_SIGNED_MESSAGE, message, BEGIN_SIGNATURE, versionField, commentField, addressField, signature, END_BITCOIN_SIGNATURE ); } }
BitcoinMessages { public static String formatAsBitcoinSignedMessage( String addressText, String message, String signature ) { final Address signingAddress; try { signingAddress = new Address(BitcoinNetwork.current().get(), addressText); } catch (AddressFormatException e) { return ""; } String versionField = VERSION + ": MultiBit HD (" + Configurations.currentConfiguration.getCurrentVersion() + ")"; String commentField = COMMENT + ": https: String addressField = ADDRESS + ": " + signingAddress.toString(); return String.format( "-----%s-----%n%s%n-----%s-----%n%s%n%s%n%s%n%n%s%n-----%s-----%n", BEGIN_SIGNED_MESSAGE, message, BEGIN_SIGNATURE, versionField, commentField, addressField, signature, END_BITCOIN_SIGNATURE ); }  }
BitcoinMessages { public static String formatAsBitcoinSignedMessage( String addressText, String message, String signature ) { final Address signingAddress; try { signingAddress = new Address(BitcoinNetwork.current().get(), addressText); } catch (AddressFormatException e) { return ""; } String versionField = VERSION + ": MultiBit HD (" + Configurations.currentConfiguration.getCurrentVersion() + ")"; String commentField = COMMENT + ": https: String addressField = ADDRESS + ": " + signingAddress.toString(); return String.format( "-----%s-----%n%s%n-----%s-----%n%s%n%s%n%s%n%n%s%n-----%s-----%n", BEGIN_SIGNED_MESSAGE, message, BEGIN_SIGNATURE, versionField, commentField, addressField, signature, END_BITCOIN_SIGNATURE ); }  static String formatAsBitcoinSignedMessage(
    String addressText,
    String message,
    String signature
  ); static SignedMessage parseSignedMessage(Optional<String> signatureBlock); }
BitcoinMessages { public static String formatAsBitcoinSignedMessage( String addressText, String message, String signature ) { final Address signingAddress; try { signingAddress = new Address(BitcoinNetwork.current().get(), addressText); } catch (AddressFormatException e) { return ""; } String versionField = VERSION + ": MultiBit HD (" + Configurations.currentConfiguration.getCurrentVersion() + ")"; String commentField = COMMENT + ": https: String addressField = ADDRESS + ": " + signingAddress.toString(); return String.format( "-----%s-----%n%s%n-----%s-----%n%s%n%s%n%s%n%n%s%n-----%s-----%n", BEGIN_SIGNED_MESSAGE, message, BEGIN_SIGNATURE, versionField, commentField, addressField, signature, END_BITCOIN_SIGNATURE ); }  static String formatAsBitcoinSignedMessage(
    String addressText,
    String message,
    String signature
  ); static SignedMessage parseSignedMessage(Optional<String> signatureBlock);  }