(String[] args)
| 7 | |
| 8 | class BatchOperations { |
| 9 | public static void main(String[] args) throws Exception { |
| 10 | Client client = new Client(); |
| 11 | |
| 12 | MockHsm.Key key = MockHsm.Key.create(client); |
| 13 | HsmSigner.addKey(key, MockHsm.getSignerClient(client)); |
| 14 | |
| 15 | // snippet asset-builders |
| 16 | List<Asset.Builder> assetBuilders = Arrays.asList( |
| 17 | new Asset.Builder() |
| 18 | .setAlias("gold") |
| 19 | .addRootXpub(key.xpub) |
| 20 | .setQuorum(1), |
| 21 | new Asset.Builder() |
| 22 | .setAlias("silver") |
| 23 | .addRootXpub(key.xpub) |
| 24 | .setQuorum(1), |
| 25 | new Asset.Builder() |
| 26 | .setAlias("bronze") |
| 27 | .addRootXpub(key.xpub) |
| 28 | .setQuorum(0) |
| 29 | ); |
| 30 | // endsnippet |
| 31 | |
| 32 | // snippet asset-create-batch |
| 33 | BatchResponse<Asset> assetBatch = Asset.createBatch(client, assetBuilders); |
| 34 | // endsnippet |
| 35 | |
| 36 | // snippet asset-create-handle-errors |
| 37 | for (int i = 0; i < assetBatch.size(); i++) { |
| 38 | if (assetBatch.isError(i)) { |
| 39 | APIException error = assetBatch.errorsByIndex().get(i); |
| 40 | System.out.println("asset " + i + " error: " + error); |
| 41 | } else { |
| 42 | Asset asset = assetBatch.successesByIndex().get(i); |
| 43 | System.out.println("asset " + i + " created, ID: " + asset.id); |
| 44 | } |
| 45 | } |
| 46 | // endsnippet |
| 47 | |
| 48 | // snippet nondeterministic-errors |
| 49 | assetBuilders = Arrays.asList( |
| 50 | new Asset.Builder() |
| 51 | .setAlias("platinum") |
| 52 | .addRootXpub(key.xpub) |
| 53 | .setQuorum(1), |
| 54 | new Asset.Builder() |
| 55 | .setAlias("platinum") |
| 56 | .addRootXpub(key.xpub) |
| 57 | .setQuorum(1), |
| 58 | new Asset.Builder() |
| 59 | .setAlias("platinum") |
| 60 | .addRootXpub(key.xpub) |
| 61 | .setQuorum(1) |
| 62 | ); |
| 63 | // endsnippet |
| 64 | |
| 65 | assetBatch = Asset.createBatch(client, assetBuilders); |
| 66 |
nothing calls this directly
no test coverage detected