Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String network = "nodes.devnet.iota.org";
- int port = 443;
- IotaAPI api = new IotaAPI.Builder()
- .host(network)
- .port(port)
- .protocol("https")
- .timeout(500)
- .localPoW(new PearlDiverLocalPoW())
- .build();
- String seed = "9999999999TESTSEED9999999";
- IotaAccount account = new IotaAccount.Builder(seed)
- .api(api)
- .securityLevel(2)
- .mwm(14)
- .store(new AccountFileStore("account.store"))
- .build();
- ConditionalDepositAddress address = account.newDepositAddress(new Date(Long.MAX_VALUE), true, 0).get();
- // nextZeroValueAddress fails when we dont have a deposit address made, ever
- // Both The message and the tag are optional, and can be null (default messages to "IOTA Accounts Transfer")
- Future<Bundle> bundle = account.sendZeroValue("Hello!", "COOL9TAG", address.getDepositAddress().getHashCheckSum());
- bundle.get();
- // Calling send with 0 value, will act the same as sendZeroValue
- Future<Bundle> bundle = account.send(address.getDepositAddress().getHashCheckSum(), 0, "Hello!", "COOL9TAG");
- bundle.get();
- // Sweep the entire account to 1 address
- Date n = new Date(System.currentTimeMillis() + 1000 * 60 * 60);
- ConditionalDepositAddress address = account.newDepositAddress(n, false, account.usableBalance()).get();
- Future<Bundle> bundle = account.send(
- address.getDepositAddress().getHashCheckSum(),
- address.getRequest().getExpectedAmount(),
- Optional.of("Sweep of all addresses"), Optional.of("IOTA9SWEEP"));
- bundle.get();
- // Or accept a CDA
- String magnet = "";
- ConditionalDepositAddress cda = DepositFactory.get().parse(magnet, MagnetMethod.class);
- Future<Bundle> bundle = account.send(
- cda.getDepositAddress().getHashCheckSum(),
- cda.getRequest().getExpectedAmount(),
- Optional.of("Thanks for that pizza!"), Optional.of("OMNOMNOM"));
Add Comment
Please, Sign In to add comment