-
Notifications
You must be signed in to change notification settings - Fork 45
/
XrplClient.java
565 lines (521 loc) · 24.3 KB
/
XrplClient.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
package org.xrpl.xrpl4j.client;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.annotations.Beta;
import com.google.common.base.Preconditions;
import okhttp3.HttpUrl;
import org.immutables.value.Value;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xrpl.xrpl4j.codec.binary.XrplBinaryCodec;
import org.xrpl.xrpl4j.keypairs.DefaultKeyPairService;
import org.xrpl.xrpl4j.keypairs.KeyPairService;
import org.xrpl.xrpl4j.model.client.XrplMethods;
import org.xrpl.xrpl4j.model.client.accounts.AccountChannelsRequestParams;
import org.xrpl.xrpl4j.model.client.accounts.AccountChannelsResult;
import org.xrpl.xrpl4j.model.client.accounts.AccountInfoRequestParams;
import org.xrpl.xrpl4j.model.client.accounts.AccountInfoResult;
import org.xrpl.xrpl4j.model.client.accounts.AccountLinesRequestParams;
import org.xrpl.xrpl4j.model.client.accounts.AccountLinesResult;
import org.xrpl.xrpl4j.model.client.accounts.AccountObjectsRequestParams;
import org.xrpl.xrpl4j.model.client.accounts.AccountObjectsResult;
import org.xrpl.xrpl4j.model.client.accounts.AccountTransactionsRequestParams;
import org.xrpl.xrpl4j.model.client.accounts.AccountTransactionsResult;
import org.xrpl.xrpl4j.model.client.channels.ChannelVerifyRequestParams;
import org.xrpl.xrpl4j.model.client.channels.ChannelVerifyResult;
import org.xrpl.xrpl4j.model.client.fees.FeeResult;
import org.xrpl.xrpl4j.model.client.ledger.LedgerRequestParams;
import org.xrpl.xrpl4j.model.client.ledger.LedgerResult;
import org.xrpl.xrpl4j.model.client.path.RipplePathFindRequestParams;
import org.xrpl.xrpl4j.model.client.path.RipplePathFindResult;
import org.xrpl.xrpl4j.model.client.server.ServerInfo;
import org.xrpl.xrpl4j.model.client.server.ServerInfoResult;
import org.xrpl.xrpl4j.model.client.transactions.SignedTransaction;
import org.xrpl.xrpl4j.model.client.transactions.SubmitMultiSignedRequestParams;
import org.xrpl.xrpl4j.model.client.transactions.SubmitMultiSignedResult;
import org.xrpl.xrpl4j.model.client.transactions.SubmitRequestParams;
import org.xrpl.xrpl4j.model.client.transactions.SubmitResult;
import org.xrpl.xrpl4j.model.client.transactions.TransactionRequestParams;
import org.xrpl.xrpl4j.model.client.transactions.TransactionResult;
import org.xrpl.xrpl4j.model.jackson.ObjectMapperFactory;
import org.xrpl.xrpl4j.model.transactions.AccountDelete;
import org.xrpl.xrpl4j.model.transactions.AccountSet;
import org.xrpl.xrpl4j.model.transactions.Address;
import org.xrpl.xrpl4j.model.transactions.CheckCancel;
import org.xrpl.xrpl4j.model.transactions.CheckCash;
import org.xrpl.xrpl4j.model.transactions.CheckCreate;
import org.xrpl.xrpl4j.model.transactions.DepositPreAuth;
import org.xrpl.xrpl4j.model.transactions.EscrowCancel;
import org.xrpl.xrpl4j.model.transactions.EscrowCreate;
import org.xrpl.xrpl4j.model.transactions.EscrowFinish;
import org.xrpl.xrpl4j.model.transactions.Hash256;
import org.xrpl.xrpl4j.model.transactions.OfferCancel;
import org.xrpl.xrpl4j.model.transactions.OfferCreate;
import org.xrpl.xrpl4j.model.transactions.Payment;
import org.xrpl.xrpl4j.model.transactions.PaymentChannelClaim;
import org.xrpl.xrpl4j.model.transactions.PaymentChannelCreate;
import org.xrpl.xrpl4j.model.transactions.PaymentChannelFund;
import org.xrpl.xrpl4j.model.transactions.SetRegularKey;
import org.xrpl.xrpl4j.model.transactions.SignerListSet;
import org.xrpl.xrpl4j.model.transactions.Transaction;
import org.xrpl.xrpl4j.model.transactions.TrustSet;
import org.xrpl.xrpl4j.model.transactions.XrpCurrencyAmount;
import org.xrpl.xrpl4j.wallet.Wallet;
/**
* A client which wraps a rippled network client and is responsible for higher order functionality such as signing and
* serializing transactions, as well as hiding certain implementation details from the public API such as JSON RPC
* request object creation.
* <p>
* Note: This client is currently marked as {@link Beta}, and should be used as a reference implementation ONLY.
*/
@Beta
public class XrplClient {
private static final Logger LOGGER = LoggerFactory.getLogger(XrplClient.class);
private final ObjectMapper objectMapper;
private final XrplBinaryCodec binaryCodec;
private final JsonRpcClient jsonRpcClient;
private final KeyPairService keyPairService;
/**
* Public constructor.
*
* @param rippledUrl The {@link HttpUrl} of the rippled node to connect to.
*/
public XrplClient(HttpUrl rippledUrl) {
this.objectMapper = ObjectMapperFactory.create();
this.binaryCodec = new XrplBinaryCodec();
this.jsonRpcClient = JsonRpcClient.construct(rippledUrl);
this.keyPairService = DefaultKeyPairService.getInstance();
}
/**
* Submit a {@link Transaction} to the XRP Ledger.
*
* @param <T> The type of {@link Transaction} that is being submitted.
* @param wallet The {@link Wallet} of the XRPL account submitting {@code unsignedTransaction}.
* @param unsignedTransaction An unsigned {@link Transaction} to submit. {@link Transaction#transactionSignature()}
* must not be provided, and {@link Transaction#signingPublicKey()} must be provided.
*
* @return The {@link SubmitResult} resulting from the submission request.
*
* @throws JsonRpcClientErrorException If {@code jsonRpcClient} throws an error.
* @see "https://xrpl.org/submit.html"
*/
public <T extends Transaction> SubmitResult<T> submit(
Wallet wallet,
T unsignedTransaction
) throws JsonRpcClientErrorException {
Preconditions.checkArgument(
unsignedTransaction.signingPublicKey().isPresent(),
"Transaction.signingPublicKey() must be set."
);
SignedTransaction<T> signedTransaction = signTransaction(wallet, unsignedTransaction);
return submit(signedTransaction);
}
/**
* Submit a {@link SignedTransaction} to the ledger.
*
* @param signedTransaction A {@link SignedTransaction} to submit.
* @param <T> The type of {@link Transaction} contained in the {@link SignedTransaction} object.
*
* @return The {@link SubmitResult} resulting from the submission request.
*
* @throws JsonRpcClientErrorException If {@code jsonRpcClient} throws an error.
*/
public <T extends Transaction> SubmitResult<T> submit(
SignedTransaction<T> signedTransaction
) throws JsonRpcClientErrorException {
JsonRpcRequest request = JsonRpcRequest.builder()
.method(XrplMethods.SUBMIT)
.addParams(SubmitRequestParams.of(signedTransaction.signedTransactionBlob()))
.build();
JavaType resultType = objectMapper.getTypeFactory()
.constructParametricType(SubmitResult.class, signedTransaction.signedTransaction().getClass());
return jsonRpcClient.send(request, resultType);
}
/**
* Submit a {@link SignedTransaction} to the XRP Ledger.
*
* @param <T> The type of signed {@link Transaction} that is being submitted.
* @param signedTransaction A {@link org.xrpl.xrpl4j.crypto.signing.SignedTransaction} to submit.
*
* @return The {@link SubmitResult} resulting from the submission request.
*
* @throws JsonRpcClientErrorException If {@code jsonRpcClient} throws an error.
* @throws JsonProcessingException if any JSON is invalid.
* @see "https://xrpl.org/submit.html"
*/
public <T extends Transaction> SubmitResult<T> submit(
final org.xrpl.xrpl4j.crypto.signing.SignedTransaction signedTransaction
) throws JsonRpcClientErrorException, JsonProcessingException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("About to submit signedTransaction: {}", signedTransaction);
}
String signedJson = objectMapper.writeValueAsString(signedTransaction.signedTransaction());
String signedBlob = binaryCodec.encode(signedJson); // <-- txBlob must be binary-encoded.
JsonRpcRequest request = JsonRpcRequest.builder()
.method(XrplMethods.SUBMIT)
.addParams(SubmitRequestParams.of(signedBlob))
.build();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("About to submit JsonRpcRequest: {}", request);
}
JavaType resultType = objectMapper.getTypeFactory()
.constructParametricType(SubmitResult.class, signedTransaction.unsignedTransaction().getClass());
return jsonRpcClient.send(request, resultType);
}
/**
* Submit a multisigned {@link Transaction} to the ledger.
*
* @param transaction A multisigned {@link Transaction}.
* @param <T> A type parameter for the type of {@link Transaction} being submitted.
*
* @return A {@link SubmitMultiSignedResult} of type {@link T}.
*
* @throws JsonRpcClientErrorException if {@code jsonRpcClient} throws an error.
*/
public <T extends Transaction> SubmitMultiSignedResult<T> submitMultisigned(
T transaction
) throws JsonRpcClientErrorException {
JsonRpcRequest request = JsonRpcRequest.builder()
.method(XrplMethods.SUBMIT_MULTISIGNED)
.addParams(SubmitMultiSignedRequestParams.of(transaction))
.build();
JavaType resultType = objectMapper.getTypeFactory().constructParametricType(
SubmitMultiSignedResult.class, transaction.getClass()
);
return jsonRpcClient.send(request, resultType);
}
/**
* Get the current state of the open-ledger requirements for transaction costs.
*
* @return A {@link FeeResult} containing information about current transaction costs.
*
* @throws JsonRpcClientErrorException If {@code jsonRpcClient} throws an error.
* @see "https://xrpl.org/fee.html"
*/
public FeeResult fee() throws JsonRpcClientErrorException {
JsonRpcRequest request = JsonRpcRequest.builder()
.method(XrplMethods.FEE)
.build();
return jsonRpcClient.send(request, FeeResult.class);
}
/**
* Get the "server_info" for the rippled node.
*
* @return A {@link ServerInfo} containing information about the server.
*
* @throws JsonRpcClientErrorException If {@code jsonRpcClient} throws an error.
* @see "https://xrpl.org/server_info.html"
*/
public ServerInfo serverInfo() throws JsonRpcClientErrorException {
JsonRpcRequest request = JsonRpcRequest.builder()
.method(XrplMethods.SERVER_INFO)
.build();
return jsonRpcClient.send(request, ServerInfoResult.class).info();
}
/**
* Get the {@link AccountChannelsResult} for the account specified in {@code params} by making an account_channels
* method call.
*
* @param params The {@link AccountChannelsRequestParams} to send in the request.
*
* @return The {@link AccountChannelsResult} returned by the account_channels method call.
*
* @throws JsonRpcClientErrorException If {@code jsonRpcClient} throws an error.
*/
public AccountChannelsResult accountChannels(AccountChannelsRequestParams params) throws JsonRpcClientErrorException {
JsonRpcRequest request = JsonRpcRequest.builder()
.method(XrplMethods.ACCOUNT_CHANNELS)
.addParams(params)
.build();
return jsonRpcClient.send(request, AccountChannelsResult.class);
}
/**
* Get the {@link AccountInfoResult} for the account specified in {@code params} by making an account_info method
* call.
*
* @param params The {@link AccountInfoRequestParams} to send in the request.
*
* @return The {@link AccountInfoResult} returned by the account_info method call.
*
* @throws JsonRpcClientErrorException If {@code jsonRpcClient} throws an error.
*/
public AccountInfoResult accountInfo(AccountInfoRequestParams params) throws JsonRpcClientErrorException {
JsonRpcRequest request = JsonRpcRequest.builder()
.method(XrplMethods.ACCOUNT_INFO)
.addParams(params)
.build();
return jsonRpcClient.send(request, AccountInfoResult.class);
}
/**
* Get the {@link AccountObjectsResult} for the account specified in {@code params} by making an account_objects
* method call.
*
* @param params The {@link AccountObjectsRequestParams} to send in the request.
*
* @return The {@link AccountObjectsResult} returned by the account_objects method call.
*
* @throws JsonRpcClientErrorException If {@code jsonRpcClient} throws an error.
*/
public AccountObjectsResult accountObjects(AccountObjectsRequestParams params) throws JsonRpcClientErrorException {
JsonRpcRequest request = JsonRpcRequest.builder()
.method(XrplMethods.ACCOUNT_OBJECTS)
.addParams(params)
.build();
return jsonRpcClient.send(request, AccountObjectsResult.class);
}
/**
* Get the {@link AccountTransactionsResult} for the specified {@code address} by making an account_tx method call.
*
* @param address The {@link Address} of the account to request.
*
* @return The {@link AccountTransactionsResult} returned by the account_tx method call.
*
* @throws JsonRpcClientErrorException If {@code jsonRpcClient} throws an error.
*/
public AccountTransactionsResult accountTransactions(Address address) throws JsonRpcClientErrorException {
return accountTransactions(AccountTransactionsRequestParams.builder()
.account(address)
.build());
}
/**
* Get the {@link AccountTransactionsResult} for the account specified in {@code params} by making an account_tx
* method call.
*
* @param params The {@link AccountTransactionsRequestParams} to send in the request.
*
* @return The {@link AccountTransactionsResult} returned by the account_tx method call.
*
* @throws JsonRpcClientErrorException If {@code jsonRpcClient} throws an error.
*/
public AccountTransactionsResult accountTransactions(AccountTransactionsRequestParams params)
throws JsonRpcClientErrorException {
JsonRpcRequest request = JsonRpcRequest.builder()
.method(XrplMethods.ACCOUNT_TX)
.addParams(params)
.build();
return jsonRpcClient.send(request, AccountTransactionsResult.class);
}
/**
* Get a transaction from the ledger by sending a tx method request.
*
* @param params The {@link TransactionRequestParams} to send in the request.
* @param transactionType The {@link Transaction} type of the transaction with the hash {@code params.transaction()}.
* @param <T> Type parameter for the type of {@link Transaction} that the {@link TransactionResult} will
*
* @return A {@link TransactionResult} containing the requested transaction and other metadata.
*
* @throws JsonRpcClientErrorException If {@code jsonRpcClient} throws an error.
*/
public <T extends Transaction> TransactionResult<T> transaction(
TransactionRequestParams params,
Class<T> transactionType
) throws JsonRpcClientErrorException {
JsonRpcRequest request = JsonRpcRequest.builder()
.method(XrplMethods.TX)
.addParams(params)
.build();
JavaType resultType = objectMapper.getTypeFactory()
.constructParametricType(TransactionResult.class, transactionType);
return jsonRpcClient.send(request, resultType);
}
/**
* Get the contents of a ledger by sending a ledger method request.
*
* @param params The {@link LedgerRequestParams} to send in the request.
*
* @return A {@link LedgerResult} containing the ledger details.
*
* @throws JsonRpcClientErrorException if {@code jsonRpcClient} throws an error.
*/
public LedgerResult ledger(LedgerRequestParams params) throws JsonRpcClientErrorException {
JsonRpcRequest request = JsonRpcRequest.builder()
.method(XrplMethods.LEDGER)
.addParams(params)
.build();
return jsonRpcClient.send(request, LedgerResult.class);
}
/**
* Try to find a payment path for a rippling payment by sending a ripple_path_find method request.
*
* @param params The {@link RipplePathFindRequestParams} to send in the request.
*
* @return A {@link RipplePathFindResult} containing possible paths.
*
* @throws JsonRpcClientErrorException if {@code jsonRpcClient} throws an error.
*/
public RipplePathFindResult ripplePathFind(RipplePathFindRequestParams params) throws JsonRpcClientErrorException {
JsonRpcRequest request = JsonRpcRequest.builder()
.method(XrplMethods.RIPPLE_PATH_FIND)
.addParams(params)
.build();
return jsonRpcClient.send(request, RipplePathFindResult.class);
}
/**
* Get the trust lines for a given account by sending an account_lines method request.
*
* @param params The {@link AccountLinesRequestParams} to send in the request.
*
* @return The {@link AccountLinesResult} containing the requested trust lines.
*
* @throws JsonRpcClientErrorException if {@code jsonRpcClient} throws an error.
*/
public AccountLinesResult accountLines(AccountLinesRequestParams params) throws JsonRpcClientErrorException {
JsonRpcRequest request = JsonRpcRequest.builder()
.method(XrplMethods.ACCOUNT_LINES)
.addParams(params)
.build();
return jsonRpcClient.send(request, AccountLinesResult.class);
}
/**
* Verify a payment channel claim signature by making a "channel_verify" rippled API method call.
*
* @param channelId A {@link Hash256} containing the Channel ID.
* @param amount An {@link XrpCurrencyAmount} representing the amount of the claim.
* @param signature The signature of the {@link PaymentChannelClaim} transaction.
* @param publicKey A {@link String} containing the public key associated with the key used to generate the
* signature.
*
* @return The result of the request, as a {@link ChannelVerifyResult}.
*
* @throws JsonRpcClientErrorException if {@code jsonRpcClient} throws an error.
*/
public ChannelVerifyResult channelVerify(
Hash256 channelId,
XrpCurrencyAmount amount,
String signature,
String publicKey
) throws JsonRpcClientErrorException {
ChannelVerifyRequestParams params = ChannelVerifyRequestParams.builder()
.channelId(channelId)
.amount(amount)
.signature(signature)
.publicKey(publicKey)
.build();
JsonRpcRequest request = JsonRpcRequest.builder()
.method(XrplMethods.CHANNEL_VERIFY)
.addParams(params)
.build();
return jsonRpcClient.send(request, ChannelVerifyResult.class);
}
public <T extends Transaction> SignedTransaction<T> signTransaction(
Wallet wallet, T unsignedTransaction
) {
try {
String unsignedJson = objectMapper.writeValueAsString(unsignedTransaction);
String unsignedBinaryHex = binaryCodec.encodeForSigning(unsignedJson);
String signature = keyPairService.sign(unsignedBinaryHex, wallet.privateKey()
.orElseThrow(() -> new RuntimeException("Wallet must provide a private key to sign the transaction.")));
T signedTransaction = (T) addSignature(unsignedTransaction, signature);
String signedJson = objectMapper.writeValueAsString(signedTransaction);
String signedBinary = binaryCodec.encode(signedJson);
return SignedTransaction.<T>builder()
.signedTransaction(signedTransaction)
.signedTransactionBlob(signedBinary)
.build();
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
/**
* Add {@link Transaction#transactionSignature()} to the given unsignedTransaction. Because {@link Transaction} is not
* a {@link Value.Immutable}, it does not have a generated builder like the subclasses. Thus, this method needs to
* rebuild transactions based on their runtime type.
*
* @param unsignedTransaction An unsigned {@link Transaction} to add a signature to. {@link
* Transaction#transactionSignature()} must not be provided, and {@link
* Transaction#signingPublicKey()} must be provided. a {@link Value.Immutable}, it does not
* have a generated builder like the subclasses. Thus, this method needs to rebuild
* transactions based on their runtime type.
* @param signature The hex encoded {@link String} containing the transaction signature.
*
* @return A copy of {@code unsignedTransaction} with the {@link Transaction#transactionSignature()} field added.
*
* @deprecated This method will go away in a future version and be replaced with the implementation in SignatureUtils
* in the xrpl4j-crypto module.
*/
@Deprecated
private Transaction addSignature(
Transaction unsignedTransaction,
String signature
) {
if (Payment.class.isAssignableFrom(unsignedTransaction.getClass())) {
return Payment.builder().from((Payment) unsignedTransaction)
.transactionSignature(signature)
.build();
} else if (AccountSet.class.isAssignableFrom(unsignedTransaction.getClass())) {
return AccountSet.builder().from((AccountSet) unsignedTransaction)
.transactionSignature(signature)
.build();
} else if (AccountDelete.class.isAssignableFrom(unsignedTransaction.getClass())) {
return AccountDelete.builder().from((AccountDelete) unsignedTransaction)
.transactionSignature(signature)
.build();
} else if (CheckCancel.class.isAssignableFrom(unsignedTransaction.getClass())) {
return CheckCancel.builder().from((CheckCancel) unsignedTransaction)
.transactionSignature(signature)
.build();
} else if (CheckCash.class.isAssignableFrom(unsignedTransaction.getClass())) {
return CheckCash.builder().from((CheckCash) unsignedTransaction)
.transactionSignature(signature)
.build();
} else if (CheckCreate.class.isAssignableFrom(unsignedTransaction.getClass())) {
return CheckCreate.builder().from((CheckCreate) unsignedTransaction)
.transactionSignature(signature)
.build();
} else if (DepositPreAuth.class.isAssignableFrom(unsignedTransaction.getClass())) {
return DepositPreAuth.builder().from((DepositPreAuth) unsignedTransaction)
.transactionSignature(signature)
.build();
} else if (EscrowCreate.class.isAssignableFrom(unsignedTransaction.getClass())) {
return EscrowCreate.builder().from((EscrowCreate) unsignedTransaction)
.transactionSignature(signature)
.build();
} else if (EscrowCancel.class.isAssignableFrom(unsignedTransaction.getClass())) {
return EscrowCancel.builder().from((EscrowCancel) unsignedTransaction)
.transactionSignature(signature)
.build();
} else if (EscrowFinish.class.isAssignableFrom(unsignedTransaction.getClass())) {
return EscrowFinish.builder().from((EscrowFinish) unsignedTransaction)
.transactionSignature(signature)
.build();
} else if (TrustSet.class.isAssignableFrom(unsignedTransaction.getClass())) {
return TrustSet.builder().from((TrustSet) unsignedTransaction)
.transactionSignature(signature)
.build();
} else if (OfferCreate.class.isAssignableFrom(unsignedTransaction.getClass())) {
return OfferCreate.builder().from((OfferCreate) unsignedTransaction)
.transactionSignature(signature)
.build();
} else if (OfferCancel.class.isAssignableFrom(unsignedTransaction.getClass())) {
return OfferCancel.builder().from((OfferCancel) unsignedTransaction)
.transactionSignature(signature)
.build();
} else if (PaymentChannelCreate.class.isAssignableFrom(unsignedTransaction.getClass())) {
return PaymentChannelCreate.builder().from((PaymentChannelCreate) unsignedTransaction)
.transactionSignature(signature)
.build();
} else if (PaymentChannelClaim.class.isAssignableFrom(unsignedTransaction.getClass())) {
return PaymentChannelClaim.builder().from((PaymentChannelClaim) unsignedTransaction)
.transactionSignature(signature)
.build();
} else if (PaymentChannelFund.class.isAssignableFrom(unsignedTransaction.getClass())) {
return PaymentChannelFund.builder().from((PaymentChannelFund) unsignedTransaction)
.transactionSignature(signature)
.build();
} else if (SetRegularKey.class.isAssignableFrom(unsignedTransaction.getClass())) {
return SetRegularKey.builder().from((SetRegularKey) unsignedTransaction)
.transactionSignature(signature)
.build();
} else if (SignerListSet.class.isAssignableFrom(unsignedTransaction.getClass())) {
return SignerListSet.builder().from((SignerListSet) unsignedTransaction)
.transactionSignature(signature)
.build();
}
// Never happens
throw new IllegalArgumentException("Signing fields could not be added to the unsignedTransaction.");
}
public JsonRpcClient getJsonRpcClient() {
return jsonRpcClient;
}
}