MCPcopy Create free account
hub / github.com/chain/Core / crossCore

Method crossCore

docs/core/examples/java/MultipartyTrades.java:105–152  ·  view source on GitHub ↗
(
    Client aliceCore, Client bobCore,
    Account alice, Account bob,
    String aliceDollarAssetId, String bobBuckAssetId
  )

Source from the content-addressed store, hash-verified

103 }
104
105 public static void crossCore(
106 Client aliceCore, Client bobCore,
107 Account alice, Account bob,
108 String aliceDollarAssetId, String bobBuckAssetId
109 ) throws Exception {
110 // snippet build-trade-alice
111 Transaction.Template aliceTrade = new Transaction.Builder()
112 .addAction(new Transaction.Action.SpendFromAccount()
113 .setAccountAlias("alice")
114 .setAssetAlias("aliceDollar")
115 .setAmount(50)
116 ).addAction(new Transaction.Action.ControlWithAccount()
117 .setAccountAlias("alice")
118 .setAssetId(bobBuckAssetId)
119 .setAmount(100)
120 ).build(aliceCore);
121 // endsnippet
122
123 // snippet sign-trade-alice
124 Transaction.Template aliceTradeSigned = HsmSigner.sign(aliceTrade.allowAdditionalActions());
125 // endsnippet
126
127 // snippet base-transaction-alice
128 String baseTransactionFromAlice = aliceTradeSigned.rawTransaction;
129 // endsnippet
130
131 // snippet build-trade-bob
132 Transaction.Template bobTrade = new Transaction.Builder()
133 .setBaseTransaction(baseTransactionFromAlice)
134 .addAction(new Transaction.Action.SpendFromAccount()
135 .setAccountAlias("bob")
136 .setAssetAlias("bobBuck")
137 .setAmount(100)
138 ).addAction(new Transaction.Action.ControlWithAccount()
139 .setAccountAlias("bob")
140 .setAssetId(aliceDollarAssetId)
141 .setAmount(50)
142 ).build(bobCore);
143 // endsnippet
144
145 // snippet sign-trade-bob
146 Transaction.Template bobTradeSigned = HsmSigner.sign(bobTrade);
147 // endsnippet
148
149 // snippet submit-trade-bob
150 Transaction.submit(bobCore, bobTradeSigned);
151 // endsnippet
152 }
153}

Callers 1

mainMethod · 0.95

Calls 10

signMethod · 0.95
submitMethod · 0.95
addActionMethod · 0.80
setBaseTransactionMethod · 0.80
buildMethod · 0.45
setAmountMethod · 0.45
setAssetAliasMethod · 0.45
setAccountAliasMethod · 0.45
setAssetIdMethod · 0.45

Tested by

no test coverage detected