use of snowblossom.proto.SigSpec in project snowblossom by snowblossomcoin.
the class AddressUtil method prettyDisplayAddressSpec.
public static void prettyDisplayAddressSpec(AddressSpec spec, PrintStream out, NetworkParams params, int c_idx, Set<String> signed_list) throws ValidationException {
AddressSpecHash hash = getHashForSpec(spec);
String address = getAddressString(params.getAddressPrefix(), hash);
out.print("AddressSpec " + address);
out.println(String.format(" %dof%d", spec.getRequiredSigners(), spec.getSigSpecsCount()));
for (int s = 0; s < spec.getSigSpecsCount(); s++) {
String key = c_idx + ":" + s;
boolean signed = false;
if (signed_list.contains(key))
signed = true;
SigSpec sig = spec.getSigSpecs(s);
String algo = SignatureUtil.getAlgo(sig.getSignatureType());
out.print(" sigspec:" + algo);
if (signed) {
out.print(" SIGNED");
}
out.print(" pub:");
out.println(HexUtil.getHexString(sig.getPublicKey()));
}
}
use of snowblossom.proto.SigSpec in project snowblossom by snowblossomcoin.
the class AddressUtil method getHashForSpec.
public static AddressSpecHash getHashForSpec(AddressSpec spec, MessageDigest md) {
try {
ByteArrayOutputStream byte_out = new ByteArrayOutputStream(200);
DataOutputStream data_out = new DataOutputStream(byte_out);
data_out.writeInt(spec.getRequiredSigners());
data_out.writeInt(spec.getSigSpecsCount());
for (SigSpec sig_spec : spec.getSigSpecsList()) {
data_out.writeInt(sig_spec.getSignatureType());
data_out.writeInt(sig_spec.getPublicKey().size());
data_out.write(sig_spec.getPublicKey().toByteArray());
}
data_out.flush();
md.update(byte_out.toByteArray());
return new AddressSpecHash(md.digest());
} catch (java.io.IOException e) {
throw new RuntimeException(e);
}
}
Aggregations