Skip to content

Instantly share code, notes, and snippets.

@MrStahlfelge
Created February 2, 2022 13:26
Show Gist options
  • Save MrStahlfelge/bfc70f7333344622263feb92830f176f to your computer and use it in GitHub Desktop.
Save MrStahlfelge/bfc70f7333344622263feb92830f176f to your computer and use it in GitHub Desktop.
@GetMapping("/roundTrip/{address}")
public ErgoPayResponse roundTrip(@PathVariable String address) {
// sends 1 ERG around to and from the address
ErgoPayResponse response = new ErgoPayResponse();
try {
boolean isMainNet = isMainNetAddress(address);
long amountToSend = 1000L * 1000L * 1000L;
Address sender = Address.create(address);
Address recipient = Address.create(address);
byte[] reduced = getReducedSendTx(isMainNet, amountToSend, sender, recipient).toBytes();
response.reducedTx = Base64.getUrlEncoder().encodeToString(reduced);
response.address = address;
response.message = "Here is your 1 ERG round trip.";
response.messageSeverity = ErgoPayResponse.Severity.INFORMATION;
} catch (Throwable t) {
response.messageSeverity = ErgoPayResponse.Severity.ERROR;
response.message = (t.getMessage());
}
return response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment