Created
February 2, 2022 13:26
-
-
Save MrStahlfelge/bfc70f7333344622263feb92830f176f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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