Skip to content

Commit

Permalink
make the examples execute w/o output_id since SubmitResponse does not…
Browse files Browse the repository at this point in the history
… return output ids yet
  • Loading branch information
oleganza committed Jan 20, 2017
1 parent 7806269 commit 7339bd3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions docs/core/examples/java/UnspentOutputs.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,15 @@ public static void main(String[] args) throws Exception {
}
// endsnippet

String prevOutputId = issuanceTx.outputs.get(0).outputId;
// TODO: update API to include output IDs into Transaction.SubmitResponse, not just txid.
// Or have a client-side helper to compute OutputID from (txid,position) pair.
String prevTransactionId = issuanceTx.id;

// snippet build-transaction-all
Transaction.Template spendOutput = new Transaction.Builder()
.addAction(new Transaction.Action.SpendAccountUnspentOutput()
.setOutputId(prevOutputId)
.setTransactionId(prevTransactionId)
.setPosition(0)
).addAction(new Transaction.Action.ControlWithAccount()
.setAccountAlias("bob")
.setAssetAlias("gold")
Expand All @@ -87,12 +90,11 @@ public static void main(String[] args) throws Exception {

Transaction.submit(client, HsmSigner.sign(spendOutput));

prevOutputId = issuanceTx.outputs.get(1).outputId;

// snippet build-transaction-partial
Transaction.Template spendOutputWithChange = new Transaction.Builder()
.addAction(new Transaction.Action.SpendAccountUnspentOutput()
.setOutputId(prevOutputId)
.setTransactionId(prevTransactionId)
.setPosition(1)
).addAction(new Transaction.Action.ControlWithAccount()
.setAccountAlias("bob")
.setAssetAlias("gold")
Expand Down

0 comments on commit 7339bd3

Please sign in to comment.