本文整理匯總了Java中org.bitcoinj.core.NetworkParameters.getUriScheme方法的典型用法代碼示例。如果您正苦於以下問題:Java NetworkParameters.getUriScheme方法的具體用法?Java NetworkParameters.getUriScheme怎麽用?Java NetworkParameters.getUriScheme使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bitcoinj.core.NetworkParameters
的用法示例。
在下文中一共展示了NetworkParameters.getUriScheme方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: convertToBitcoinURI
import org.bitcoinj.core.NetworkParameters; //導入方法依賴的package包/類
/**
* Simple Bitcoin URI builder using known good fields.
*
* @param params The network parameters that determine which network the URI
* is for.
* @param address The Bitcoin address
* @param amount The amount
* @param label A label
* @param message A message
* @return A String containing the Bitcoin URI
*/
public static String convertToBitcoinURI(NetworkParameters params,
String address, @Nullable Coin amount,
@Nullable String label, @Nullable String message) {
checkNotNull(params);
checkNotNull(address);
if (amount != null && amount.signum() < 0) {
throw new IllegalArgumentException("Coin must be positive");
}
StringBuilder builder = new StringBuilder();
String scheme = params.getUriScheme();
builder.append(scheme).append(":").append(address);
boolean questionMarkHasBeenOutput = false;
if (amount != null) {
builder.append(QUESTION_MARK_SEPARATOR).append(FIELD_AMOUNT).append("=");
builder.append(amount.toPlainString());
questionMarkHasBeenOutput = true;
}
if (label != null && !"".equals(label)) {
if (questionMarkHasBeenOutput) {
builder.append(AMPERSAND_SEPARATOR);
} else {
builder.append(QUESTION_MARK_SEPARATOR);
questionMarkHasBeenOutput = true;
}
builder.append(FIELD_LABEL).append("=").append(encodeURLString(label));
}
if (message != null && !"".equals(message)) {
if (questionMarkHasBeenOutput) {
builder.append(AMPERSAND_SEPARATOR);
} else {
builder.append(QUESTION_MARK_SEPARATOR);
}
builder.append(FIELD_MESSAGE).append("=").append(encodeURLString(message));
}
return builder.toString();
}