本文整理汇总了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();
}