use of org.xel.Attachment in project elastic-core-maven by OrdinaryDude.
the class RedeemFunctions method redeem.
public static boolean redeem(String address_entry, String secretPhrase, String[] bitcoin_privkeys, boolean graceblock) {
String secp_signatures = "";
NetworkParameters params = MainNetParams.get();
long target_id = Account.getId(Crypto.getPublicKey(secretPhrase));
String message = Redeem.getSignMessage(Redeem.getClaimableAmount(address_entry), address_entry, target_id);
// Sign inputs
for (int i = 0; i < bitcoin_privkeys.length; ++i) {
ECKey key;
DumpedPrivateKey dumpedPrivateKey = DumpedPrivateKey.fromBase58(params, bitcoin_privkeys[i]);
key = dumpedPrivateKey.getKey();
String signed = key.signMessage(message);
bitcoin_privkeys[i] = signed;
}
secp_signatures = String.join("-", bitcoin_privkeys);
final Attachment attachment = new Attachment.RedeemAttachment(address_entry, secp_signatures);
boolean success = false;
try {
make(attachment, secretPhrase, Account.getId(Crypto.getPublicKey(secretPhrase)), Redeem.getClaimableAmount(address_entry), true, graceblock);
success = true;
} catch (Exception e) {
Logger.logErrorMessage(e.getMessage());
}
return success;
}
use of org.xel.Attachment in project elastic-core-maven by OrdinaryDude.
the class LeaseBalance method processRequest.
@Override
protected JSONStreamAware processRequest(HttpServletRequest req) throws NxtException {
int period = ParameterParser.getInt(req, "period", Constants.LEASING_DELAY, 65535, true);
Account account = ParameterParser.getSenderAccount(req);
long recipient = ParameterParser.getAccountId(req, "recipient", true);
Account recipientAccount = Account.getAccount(recipient);
if (recipientAccount == null || Account.getPublicKey(recipientAccount.getId()) == null) {
JSONObject response = new JSONObject();
response.put("errorCode", 8);
response.put("errorDescription", "recipient account does not have public key");
return response;
}
Attachment attachment = new Attachment.AccountControlEffectiveBalanceLeasing(period);
return createTransaction(req, account, recipient, 0, attachment);
}
Aggregations