xrpld
Loading...
Searching...
No Matches
JSONRPC_test.cpp
1#include <test/jtx/Account.h>
2#include <test/jtx/Env.h>
3#include <test/jtx/Env_ss.h>
4#include <test/jtx/acctdelete.h>
5#include <test/jtx/amount.h>
6#include <test/jtx/batch.h>
7#include <test/jtx/envconfig.h>
8#include <test/jtx/fee.h>
9#include <test/jtx/multisign.h>
10#include <test/jtx/noop.h>
11#include <test/jtx/pay.h>
12#include <test/jtx/trust.h>
13
14#include <xrpld/app/misc/TxQ.h>
15#include <xrpld/rpc/Role.h>
16#include <xrpld/rpc/detail/TransactionSign.h>
17
18#include <xrpl/basics/contract.h>
19#include <xrpl/beast/unit_test/suite.h>
20#include <xrpl/config/Constants.h>
21#include <xrpl/json/json_reader.h>
22#include <xrpl/json/json_value.h>
23#include <xrpl/json/to_string.h>
24#include <xrpl/protocol/ErrorCodes.h>
25#include <xrpl/protocol/KeyType.h>
26#include <xrpl/protocol/TxFlags.h>
27#include <xrpl/protocol/jss.h>
28#include <xrpl/server/LoadFeeTrack.h>
29#include <xrpl/server/NetworkOPs.h>
30
31#include <array>
32#include <cassert>
33#include <chrono>
34#include <memory>
35#include <sstream>
36#include <stdexcept>
37#include <tuple>
38
39namespace xrpl::rpc {
40
42{
43 char const* token = "";
45 char const* message = "";
46
47 constexpr ExpectedResult() = default;
48
49 constexpr ExpectedResult(char const* token, ErrorCodeI code, char const* message)
51 {
52 }
53};
54
56{
57 char const* const description;
58 int const line;
59 char const* const json;
60 // The JSON is applied to four different interfaces:
61 // 1. sign,
62 // 2. submit,
63 // 3. sign_for, and
64 // 4. submit_multisigned.
65 // The JSON is not valid for all of these interfaces, but it should
66 // crash kNone of them, and should provide reliable error messages.
67 //
68 // The expected array contains the expected error token, code and message
69 // for the above cases.
71
72 constexpr TxnTestData(
73 char const* description,
74 int line,
75 char const* json,
78 {
79 }
80
81 TxnTestData() = delete;
82 TxnTestData(TxnTestData const&) = delete;
85 operator=(TxnTestData const&) = delete;
88};
89
90static constexpr TxnTestData kTxnTestArray[] = {
91
92 {
93 "Minimal payment, no Amount only DeliverMax",
94 __LINE__,
95 R"({
96 "command": "dummy_command",
97 "secret": "masterpassphrase",
98 "tx_json": {
99 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
100 "DeliverMax": "1000000000",
101 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
102 "TransactionType": "Payment"
103 }
104})",
105 {
106 {
107 {},
108 {},
109 {"invalidParams", RpcInvalidParams, "Missing field 'account'."},
110 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
111 },
112 },
113 },
114
115 {
116 "Pass in Fee with minimal payment, both Amount and DeliverMax.",
117 __LINE__,
118 R"({
119 "command": "dummy_command",
120 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
121 "secret": "masterpassphrase",
122 "tx_json": {
123 "Fee": 10,
124 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
125 "Amount": "1000000000",
126 "DeliverMax": "1000000000",
127 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
128 "TransactionType": "Payment"
129 }
130})",
131 {
132 {
133 {},
134 {},
135 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
136 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
137 },
138 },
139 },
140
141 {
142 "Pass in Sequence, no Amount only DeliverMax",
143 __LINE__,
144 R"({
145 "command": "dummy_command",
146 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
147 "secret": "masterpassphrase",
148 "tx_json": {
149 "Sequence": 0,
150 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
151 "DeliverMax": "1000000000",
152 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
153 "TransactionType": "Payment"
154 }
155})",
156 {
157 {
158 {},
159 {},
160 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Fee'."},
161 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.SigningPubKey'."},
162 },
163 },
164 },
165
166 {
167 "Pass in Sequence and Fee with minimal payment, both Amount and "
168 "DeliverMax.",
169 __LINE__,
170 R"({
171 "command": "dummy_command",
172 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
173 "secret": "masterpassphrase",
174 "tx_json": {
175 "Sequence": 0,
176 "Fee": 10,
177 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
178 "Amount": "1000000000",
179 "DeliverMax": "1000000000",
180 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
181 "TransactionType": "Payment"
182 }
183})",
184 {
185 {
186 {},
187 {},
188 {
189 "invalidParams",
191 "A Signer may not be the transaction's Account "
192 "(rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh).",
193 },
194 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.SigningPubKey'."},
195 },
196 },
197 },
198
199 {
200 "Add 'fee_mult_max' field.",
201 __LINE__,
202 R"({
203 "command": "dummy_command",
204 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
205 "secret": "masterpassphrase",
206 "fee_mult_max": 7,
207 "tx_json": {
208 "Sequence": 0,
209 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
210 "Amount": "1000000000",
211 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
212 "TransactionType": "Payment"
213 }
214})",
215 {
216 {
217 {},
218 {},
219 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Fee'."},
220 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.SigningPubKey'."},
221 },
222 },
223 },
224
225 {
226 "Add 'fee_mult_max' and 'fee_div_max' field.",
227 __LINE__,
228 R"({
229 "command": "dummy_command",
230 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
231 "secret": "masterpassphrase",
232 "fee_mult_max": 7,
233 "fee_div_max": 4,
234 "tx_json": {
235 "Sequence": 0,
236 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
237 "Amount": "1000000000",
238 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
239 "TransactionType": "Payment"
240 }
241})",
242 {
243 {
244 {},
245 {},
246 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Fee'."},
247 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.SigningPubKey'."},
248 },
249 },
250 },
251
252 {
253 "fee_mult_max is ignored if 'Fee' is present.",
254 __LINE__,
255 R"({
256 "command": "dummy_command",
257 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
258 "secret": "masterpassphrase",
259 "fee_mult_max": 0,
260 "tx_json": {
261 "Sequence": 0,
262 "Fee": 10,
263 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
264 "Amount": "1000000000",
265 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
266 "TransactionType": "Payment"
267 }
268})",
269 {
270 {
271 {},
272 {},
273 {
274 "invalidParams",
276 "A Signer may not be the transaction's Account "
277 "(rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh).",
278 },
279 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.SigningPubKey'."},
280 },
281 },
282 },
283
284 {
285 "fee_div_max is ignored if 'Fee' is present.",
286 __LINE__,
287 R"({
288 "command": "dummy_command",
289 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
290 "secret": "masterpassphrase",
291 "fee_mult_max": 100,
292 "fee_div_max": 1000,
293 "tx_json": {
294 "Sequence": 0,
295 "Fee": 10,
296 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
297 "Amount": "1000000000",
298 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
299 "TransactionType": "Payment"
300 }
301})",
302 {
303 {
304 {},
305 {},
306 {
307 "invalidParams",
309 "A Signer may not be the transaction's Account "
310 "(rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh).",
311 },
312 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.SigningPubKey'."},
313 },
314 },
315 },
316
317 {
318 "Invalid 'fee_mult_max' field.",
319 __LINE__,
320 R"({
321 "command": "dummy_command",
322 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
323 "secret": "masterpassphrase",
324 "fee_mult_max": "NotAFeeMultiplier",
325 "tx_json": {
326 "Sequence": 0,
327 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
328 "Amount": "1000000000",
329 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
330 "TransactionType": "Payment"
331 }
332})",
333 {
334 {
335 {"highFee", RpcHighFee, "Invalid field 'fee_mult_max', not a positive integer."},
336 {"highFee", RpcHighFee, "Invalid field 'fee_mult_max', not a positive integer."},
337 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Fee'."},
338 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.SigningPubKey'."},
339 },
340 },
341 },
342
343 {
344 "Invalid 'fee_div_max' field.",
345 __LINE__,
346 R"({
347 "command": "dummy_command",
348 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
349 "secret": "masterpassphrase",
350 "fee_mult_max": 5,
351 "fee_div_max": "NotAFeeMultiplier",
352 "tx_json": {
353 "Sequence": 0,
354 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
355 "Amount": "1000000000",
356 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
357 "TransactionType": "Payment"
358 }
359})",
360 {
361 {
362 {"highFee", RpcHighFee, "Invalid field 'fee_div_max', not a positive integer."},
363 {"highFee", RpcHighFee, "Invalid field 'fee_div_max', not a positive integer."},
364 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Fee'."},
365 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.SigningPubKey'."},
366 },
367 },
368 },
369
370 {
371 "Invalid value for 'fee_mult_max' field.",
372 __LINE__,
373 R"({
374 "command": "dummy_command",
375 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
376 "secret": "masterpassphrase",
377 "fee_mult_max": 0,
378 "tx_json": {
379 "Sequence": 0,
380 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
381 "Amount": "1000000000",
382 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
383 "TransactionType": "Payment"
384 }
385})",
386 {
387 {
388 {"highFee", RpcHighFee, "Fee of 10 exceeds the requested tx limit of 0"},
389 {"highFee", RpcHighFee, "Fee of 10 exceeds the requested tx limit of 0"},
390 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Fee'."},
391 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.SigningPubKey'."},
392 },
393 },
394 },
395
396 {
397 "Invalid value for 'fee_div_max' field.",
398 __LINE__,
399 R"({
400 "command": "dummy_command",
401 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
402 "secret": "masterpassphrase",
403 "fee_mult_max": 4,
404 "fee_div_max": 7,
405 "tx_json": {
406 "Sequence": 0,
407 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
408 "Amount": "1000000000",
409 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
410 "TransactionType": "Payment"
411 }
412})",
413 {
414 {
415 {"highFee", RpcHighFee, "Fee of 10 exceeds the requested tx limit of 5"},
416 {"highFee", RpcHighFee, "Fee of 10 exceeds the requested tx limit of 5"},
417 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Fee'."},
418 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.SigningPubKey'."},
419 },
420 },
421 },
422
423 {
424 "Invalid zero value for 'fee_div_max' field.",
425 __LINE__,
426 R"({
427 "command": "dummy_command",
428 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
429 "secret": "masterpassphrase",
430 "fee_mult_max": 4,
431 "fee_div_max": 0,
432 "tx_json": {
433 "Sequence": 0,
434 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
435 "Amount": "1000000000",
436 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
437 "TransactionType": "Payment"
438 }
439})",
440 {
441 {
442 {
443 "invalidParams",
445 "Invalid field 'fee_div_max', not a positive integer.",
446 },
447 {
448 "invalidParams",
450 "Invalid field 'fee_div_max', not a positive integer.",
451 },
452 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Fee'."},
453 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.SigningPubKey'."},
454 },
455 },
456 },
457
458 {
459 "Missing 'Amount'.",
460 __LINE__,
461 R"({
462 "command": "dummy_command",
463 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
464 "secret": "masterpassphrase",
465 "tx_json": {
466 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
467 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
468 "TransactionType": "Payment"
469 }
470})",
471 {
472 {
473 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Amount'."},
474 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Amount'."},
475 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
476 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
477 },
478 },
479 },
480
481 {
482 "Invalid 'Amount'.",
483 __LINE__,
484 R"({
485 "command": "dummy_command",
486 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
487 "secret": "masterpassphrase",
488 "tx_json": {
489 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
490 "Amount": "NotAnAmount",
491 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
492 "TransactionType": "Payment"
493 }
494})",
495 {
496 {
497 {"invalidParams", RpcInvalidParams, "Invalid field 'tx_json.Amount'."},
498 {"invalidParams", RpcInvalidParams, "Invalid field 'tx_json.Amount'."},
499 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
500 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
501 },
502 },
503 },
504
505 {
506 "Missing 'Destination'.",
507 __LINE__,
508 R"({
509 "command": "dummy_command",
510 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
511 "secret": "masterpassphrase",
512 "tx_json": {
513 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
514 "Amount": "1000000000",
515 "TransactionType": "Payment"
516 }
517})",
518 {
519 {
520 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Destination'."},
521 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Destination'."},
522 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
523 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
524 },
525 },
526 },
527
528 {
529 "Invalid 'Destination'.",
530 __LINE__,
531 R"({
532 "command": "dummy_command",
533 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
534 "secret": "masterpassphrase",
535 "tx_json": {
536 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
537 "Amount": "1000000000",
538 "Destination": "NotADestination",
539 "TransactionType": "Payment"
540 }
541})",
542 {
543 {
544 {"invalidParams", RpcInvalidParams, "Invalid field 'tx_json.Destination'."},
545 {"invalidParams", RpcInvalidParams, "Invalid field 'tx_json.Destination'."},
546 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
547 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
548 },
549 },
550 },
551
552 {
553 "Cannot create XRP to XRP paths.",
554 __LINE__,
555 R"({
556 "command": "dummy_command",
557 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
558 "secret": "masterpassphrase",
559 "build_path": 1,
560 "tx_json": {
561 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
562 "Amount": "1000000000",
563 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
564 "TransactionType": "Payment"
565 }
566})",
567 {
568 {
569 {"invalidParams", RpcInvalidParams, "Cannot build XRP to XRP paths."},
570 {"invalidParams", RpcInvalidParams, "Cannot build XRP to XRP paths."},
571 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
572 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
573 },
574 },
575 },
576
577 {
578 "Successful 'build_path'.",
579 __LINE__,
580 R"({
581 "command": "dummy_command",
582 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
583 "secret": "masterpassphrase",
584 "build_path": 1,
585 "tx_json": {
586 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
587 "Amount": {
588 "value": "10",
589 "currency": "USD",
590 "issuer": "rLPwWB1itaUGMV8kbMLLysjGkEpTM2Soy4"
591 },
592 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
593 "TransactionType": "Payment"
594 }
595})",
596 {
597 {
598 {},
599 {},
600 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
601 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
602 },
603 },
604 },
605
606 {
607 "Not valid to include both 'Paths' and 'build_path'.",
608 __LINE__,
609 R"({
610 "command": "dummy_command",
611 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
612 "secret": "masterpassphrase",
613 "build_path": 1,
614 "tx_json": {
615 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
616 "Amount": {
617 "value": "10",
618 "currency": "USD",
619 "issuer": "rLPwWB1itaUGMV8kbMLLysjGkEpTM2Soy4"
620 },
621 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
622 "Paths": "",
623 "TransactionType": "Payment"
624 }
625})",
626 {
627 {
628 {
629 "invalidParams",
631 "Cannot specify both 'tx_json.Paths' and 'build_path'",
632 },
633 {
634 "invalidParams",
636 "Cannot specify both 'tx_json.Paths' and 'build_path'",
637 },
638 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
639 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
640 },
641 },
642 },
643
644 {
645 "Successful 'SendMax'.",
646 __LINE__,
647 R"({
648 "command": "dummy_command",
649 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
650 "secret": "masterpassphrase",
651 "build_path": 1,
652 "tx_json": {
653 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
654 "Amount": {
655 "value": "10",
656 "currency": "USD",
657 "issuer": "rLPwWB1itaUGMV8kbMLLysjGkEpTM2Soy4"
658 },
659 "SendMax": {
660 "value": "5",
661 "currency": "USD",
662 "issuer": "rLPwWB1itaUGMV8kbMLLysjGkEpTM2Soy4"
663 },
664 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
665 "TransactionType": "Payment"
666 }
667})",
668 {
669 {
670 {},
671 {},
672 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
673 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
674 },
675 },
676 },
677
678 {
679 "'Amount' may not be XRP for pathfinding, but 'SendMax' may be XRP.",
680 __LINE__,
681 R"({
682 "command": "dummy_command",
683 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
684 "secret": "masterpassphrase",
685 "build_path": 1,
686 "tx_json": {
687 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
688 "Amount": {
689 "value": "10",
690 "currency": "USD",
691 "issuer": "rLPwWB1itaUGMV8kbMLLysjGkEpTM2Soy4"
692 },
693 "SendMax": 10000,
694 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
695 "TransactionType": "Payment"
696 }
697})",
698 {
699 {
700 {},
701 {},
702 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
703 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
704 },
705 },
706 },
707
708 {
709 "'secret' must be present.",
710 __LINE__,
711 R"({
712 "command": "dummy_command",
713 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
714 "tx_json": {
715 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
716 "Amount": "1000000000",
717 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
718 "TransactionType": "Payment"
719 }
720})",
721 {
722 {
723 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
724 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
725 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
726 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
727 },
728 },
729 },
730
731 {
732 "'secret' must be non-empty.",
733 __LINE__,
734 R"({
735 "command": "dummy_command",
736 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
737 "secret": "",
738 "tx_json": {
739 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
740 "Amount": "1000000000",
741 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
742 "TransactionType": "Payment"
743 }
744})",
745 {
746 {
747 {"badSeed", RpcBadSeed, "Invalid field 'secret'."},
748 {"badSeed", RpcBadSeed, "Invalid field 'secret'."},
749 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
750 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
751 },
752 },
753 },
754
755 {
756 "Use 'seed' instead of 'secret'.",
757 __LINE__,
758 R"({
759 "command": "dummy_command",
760 "account": "rJrxi4Wxev4bnAGVNP9YCdKPdAoKfAmcsi",
761 "key_type": "ed25519",
762 "seed": "sh1yJfwoi98zCygwijUzuHmJDeVKd",
763 "tx_json": {
764 "Account": "rJrxi4Wxev4bnAGVNP9YCdKPdAoKfAmcsi",
765 "Amount": "1000000000",
766 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
767 "TransactionType": "Payment"
768 }
769})",
770 {
771 {
772 {},
773 {},
774 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
775 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
776 },
777 },
778 },
779
780 {
781 "Malformed 'seed'.",
782 __LINE__,
783 R"({
784 "command": "dummy_command",
785 "account": "rJrxi4Wxev4bnAGVNP9YCdKPdAoKfAmcsi",
786 "key_type": "ed25519",
787 "seed": "not a seed",
788 "tx_json": {
789 "Account": "rJrxi4Wxev4bnAGVNP9YCdKPdAoKfAmcsi",
790 "Amount": "1000000000",
791 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
792 "TransactionType": "Payment"
793 }
794})",
795 {
796 {
797 {"badSeed", RpcBadSeed, "Disallowed seed."},
798 {"badSeed", RpcBadSeed, "Disallowed seed."},
799 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
800 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
801 },
802 },
803 },
804
805 {
806 "'tx_json' must be present.",
807 __LINE__,
808 R"({
809 "command": "dummy_command",
810 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
811 "secret": "masterpassphrase",
812 "rx_json": {
813 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
814 "Amount": "1000000000",
815 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
816 "TransactionType": "Payment"
817 }
818})",
819 {
820 {
821 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json'."},
822 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json'."},
823 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json'."},
824 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json'."},
825 },
826 },
827 },
828
829 {
830 "'TransactionType' must be present.",
831 __LINE__,
832 R"({
833 "command": "dummy_command",
834 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
835 "secret": "masterpassphrase",
836 "tx_json": {
837 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
838 "Amount": "1000000000",
839 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
840 }
841})",
842 {
843 {
844 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.TransactionType'."},
845 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.TransactionType'."},
846 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
847 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
848 },
849 },
850 },
851
852 {
853 "The 'TransactionType' must be a pre-established transaction type.",
854 __LINE__,
855 R"({
856 "command": "dummy_command",
857 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
858 "secret": "masterpassphrase",
859 "tx_json": {
860 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
861 "Amount": "1000000000",
862 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
863 "TransactionType": "tt"
864 }
865})",
866 {
867 {
868 {
869 "invalidParams",
871 "Field 'tx_json.TransactionType' has invalid data.",
872 },
873 {
874 "invalidParams",
876 "Field 'tx_json.TransactionType' has invalid data.",
877 },
878 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
879 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
880 },
881 },
882 },
883
884 {
885 "The 'TransactionType' may be represented with an integer.",
886 __LINE__,
887 R"({
888 "command": "dummy_command",
889 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
890 "secret": "masterpassphrase",
891 "tx_json": {
892 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
893 "Amount": "1000000000",
894 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
895 "TransactionType": 0
896 }
897})",
898 {
899 {
900 {},
901 {},
902 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
903 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
904 },
905 },
906 },
907
908 {
909 "'Account' must be present.",
910 __LINE__,
911 R"({
912 "command": "dummy_command",
913 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
914 "secret": "masterpassphrase",
915 "tx_json": {
916 "Amount": "1000000000",
917 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
918 "TransactionType": "Payment"
919 }
920})",
921 {
922 {
923 {"srcActMissing", RpcSrcActMissing, "Missing field 'tx_json.Account'."},
924 {"srcActMissing", RpcSrcActMissing, "Missing field 'tx_json.Account'."},
925 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
926 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
927 },
928 },
929 },
930
931 {
932 "'Account' must be well formed.",
933 __LINE__,
934 R"({
935 "command": "dummy_command",
936 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
937 "secret": "masterpassphrase",
938 "tx_json": {
939 "Account": "NotAnAccount",
940 "Amount": "1000000000",
941 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
942 "TransactionType": "Payment"
943 }
944})",
945 {
946 {
947 {"srcActMalformed", RpcSrcActMalformed, "Invalid field 'tx_json.Account'."},
948 {"srcActMalformed", RpcSrcActMalformed, "Invalid field 'tx_json.Account'."},
949 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
950 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
951 },
952 },
953 },
954
955 {
956 "The 'offline' tag may be added to the transaction.",
957 __LINE__,
958 R"({
959 "command": "dummy_command",
960 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
961 "secret": "masterpassphrase",
962 "offline": 0,
963 "tx_json": {
964 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
965 "Amount": "1000000000",
966 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
967 "TransactionType": "Payment"
968 }
969})",
970 {
971 {
972 {},
973 {},
974 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
975 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
976 },
977 },
978 },
979
980 {
981 "If 'offline' is true then a 'Sequence' field must be supplied.",
982 __LINE__,
983 R"({
984 "command": "dummy_command",
985 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
986 "secret": "masterpassphrase",
987 "offline": 1,
988 "tx_json": {
989 "Fee": 10,
990 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
991 "Amount": "1000000000",
992 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
993 "TransactionType": "Payment"
994 }
995})",
996 {
997 {
998 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
999 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
1000 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
1001 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
1002 },
1003 },
1004 },
1005
1006 {
1007 "If 'offline' is true then a 'Fee' field must be supplied.",
1008 __LINE__,
1009 R"({
1010 "command": "dummy_command",
1011 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1012 "secret": "masterpassphrase",
1013 "offline": 1,
1014 "tx_json": {
1015 "Sequence": 0,
1016 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1017 "Amount": "1000000000",
1018 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1019 "TransactionType": "Payment"
1020 }
1021})",
1022 {
1023 {
1024 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Fee'."},
1025 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Fee'."},
1026 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Fee'."},
1027 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.SigningPubKey'."},
1028 },
1029 },
1030 },
1031
1032 {
1033 "Valid transaction if 'offline' is true.",
1034 __LINE__,
1035 R"({
1036 "command": "dummy_command",
1037 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1038 "secret": "masterpassphrase",
1039 "offline": 1,
1040 "tx_json": {
1041 "Sequence": 0,
1042 "Fee": 10,
1043 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1044 "Amount": "1000000000",
1045 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1046 "TransactionType": "Payment"
1047 }
1048})",
1049 {
1050 {
1051 {},
1052 {},
1053 {
1054 "invalidParams",
1056 "A Signer may not be the transaction's Account "
1057 "(rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh).",
1058 },
1059 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.SigningPubKey'."},
1060 },
1061 },
1062 },
1063
1064 {
1065 "'offline' and 'build_path' are mutually exclusive.",
1066 __LINE__,
1067 R"({
1068 "command": "dummy_command",
1069 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1070 "secret": "masterpassphrase",
1071 "offline": 1,
1072 "build_path": 1,
1073 "tx_json": {
1074 "Sequence": 0,
1075 "Fee": 10,
1076 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1077 "Amount": "1000000000",
1078 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1079 "TransactionType": "Payment"
1080 }
1081})",
1082 {
1083 {
1084 {
1085 "invalidParams",
1087 "Field 'build_path' not allowed in this context.",
1088 },
1089 {
1090 "invalidParams",
1092 "Field 'build_path' not allowed in this context.",
1093 },
1094 {
1095 "invalidParams",
1097 "Field 'build_path' not allowed in this context.",
1098 },
1099 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.SigningPubKey'."},
1100 },
1101 },
1102 },
1103
1104 {
1105 "A 'Flags' field may be specified.",
1106 __LINE__,
1107 R"({
1108 "command": "dummy_command",
1109 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1110 "secret": "masterpassphrase",
1111 "tx_json": {
1112 "Flags": 0,
1113 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1114 "Amount": "1000000000",
1115 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1116 "TransactionType": "Payment"
1117 }
1118})",
1119 {
1120 {
1121 {},
1122 {},
1123 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
1124 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
1125 },
1126 },
1127 },
1128
1129 {
1130 "The 'Flags' field must be numeric.",
1131 __LINE__,
1132 R"({
1133 "command": "dummy_command",
1134 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1135 "secret": "masterpassphrase",
1136 "tx_json": {
1137 "Flags": "NotGoodFlags",
1138 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1139 "Amount": "1000000000",
1140 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1141 "TransactionType": "Payment"
1142 }
1143})",
1144 {
1145 {
1146 {"invalidParams", RpcInvalidParams, "Field 'tx_json.Flags' has invalid data."},
1147 {"invalidParams", RpcInvalidParams, "Field 'tx_json.Flags' has invalid data."},
1148 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
1149 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
1150 },
1151 },
1152 },
1153
1154 {
1155 "It's okay to add a 'debug_signing' field.",
1156 __LINE__,
1157 R"({
1158 "command": "dummy_command",
1159 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1160 "secret": "masterpassphrase",
1161 "debug_signing": 0,
1162 "tx_json": {
1163 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1164 "Amount": "1000000000",
1165 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1166 "TransactionType": "Payment"
1167 }
1168})",
1169 {
1170 {
1171 {},
1172 {},
1173 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
1174 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
1175 },
1176 },
1177 },
1178
1179 {
1180 "Single-sign a multisigned transaction.",
1181 __LINE__,
1182 R"({
1183 "command": "dummy_command",
1184 "account": "rPcNzota6B8YBokhYtcTNqQVCngtbnWfux",
1185 "secret": "a",
1186 "tx_json": {
1187 "Account" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1188 "Amount" : "1000000000",
1189 "Destination" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1190 "Fee" : "50",
1191 "Sequence" : 0,
1192 "Signers" : [
1193 {
1194 "Signer" : {
1195 "Account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1196 "SigningPubKey" : "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020",
1197 "TxnSignature" : "304502210080EB23E78A841DDC5E3A4F10DE6EAF052207D6B519BF8954467ADB221B3F349002202CA458E8D4E4DE7176D27A91628545E7B295A5DFC8ADF0B5CD3E279B6FA02998"
1198 }
1199 }
1200 ],
1201 "SigningPubKey" : "",
1202 "TransactionType" : "Payment"
1203 }
1204})",
1205 {
1206 {
1207 {"alreadyMultisig", RpcAlreadyMultisig, "Already multisigned."},
1208 {"alreadyMultisig", RpcAlreadyMultisig, "Already multisigned."},
1209 {"badSecret", RpcBadSecret, "Secret does not match account."},
1210 {},
1211 },
1212 },
1213 },
1214
1215 {
1216 "Minimal sign_for.",
1217 __LINE__,
1218 R"({
1219 "command": "dummy_command",
1220 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1221 "secret": "masterpassphrase",
1222 "tx_json": {
1223 "Account": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1224 "Amount": "1000000000",
1225 "Destination": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1226 "Fee": 50,
1227 "Sequence": 0,
1228 "SigningPubKey": "",
1229 "TransactionType": "Payment"
1230 }
1231})",
1232 {
1233 {
1234 {"badSecret", RpcBadSecret, "Secret does not match account."},
1235 {"badSecret", RpcBadSecret, "Secret does not match account."},
1236 {},
1237 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Signers'."},
1238 },
1239 },
1240 },
1241
1242 {
1243 "Minimal offline sign_for.",
1244 __LINE__,
1245 R"({
1246 "command": "dummy_command",
1247 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1248 "secret": "masterpassphrase",
1249 "offline": 1,
1250 "tx_json": {
1251 "Account": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1252 "Amount": "1000000000",
1253 "Destination": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1254 "Fee": 50,
1255 "Sequence": 0,
1256 "SigningPubKey": "",
1257 "TransactionType": "Payment"
1258 }
1259})",
1260 {
1261 {
1262 {},
1263 {},
1264 {},
1265 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Signers'."},
1266 },
1267 },
1268 },
1269
1270 {
1271 "Offline sign_for using 'seed' instead of 'secret'.",
1272 __LINE__,
1273 R"({
1274 "command": "dummy_command",
1275 "account": "rJrxi4Wxev4bnAGVNP9YCdKPdAoKfAmcsi",
1276 "key_type": "ed25519",
1277 "seed": "sh1yJfwoi98zCygwijUzuHmJDeVKd",
1278 "offline": 1,
1279 "tx_json": {
1280 "Account": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1281 "Amount": "1000000000",
1282 "Destination": "rJrxi4Wxev4bnAGVNP9YCdKPdAoKfAmcsi",
1283 "Fee": 50,
1284 "Sequence": 0,
1285 "SigningPubKey": "",
1286 "TransactionType": "Payment"
1287 }
1288})",
1289 {
1290 {
1291 {},
1292 {},
1293 {},
1294 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Signers'."},
1295 },
1296 },
1297 },
1298
1299 {
1300 "Malformed seed in sign_for.",
1301 __LINE__,
1302 R"({
1303 "command": "dummy_command",
1304 "account": "rJrxi4Wxev4bnAGVNP9YCdKPdAoKfAmcsi",
1305 "key_type": "ed25519",
1306 "seed": "sh1yJfwoi98zCygwjUzuHmJDeVKd",
1307 "offline": 1,
1308 "tx_json": {
1309 "Account": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1310 "Amount": "1000000000",
1311 "Destination": "rJrxi4Wxev4bnAGVNP9YCdKPdAoKfAmcsi",
1312 "Fee": 50,
1313 "Sequence": 0,
1314 "SigningPubKey": "",
1315 "TransactionType": "Payment"
1316 }
1317})",
1318 {
1319 {
1320 {"badSeed", RpcBadSeed, "Disallowed seed."},
1321 {"badSeed", RpcBadSeed, "Disallowed seed."},
1322 {"badSeed", RpcBadSeed, "Disallowed seed."},
1323 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Signers'."},
1324 },
1325 },
1326 },
1327
1328 {
1329 "Missing 'Account' in sign_for.",
1330 __LINE__,
1331 R"({
1332 "command": "dummy_command",
1333 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1334 "secret": "masterpassphrase",
1335 "tx_json": {
1336 "Amount": "1000000000",
1337 "Destination": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1338 "Fee": 50,
1339 "Sequence": 0,
1340 "SigningPubKey": "",
1341 "TransactionType": "Payment"
1342 }
1343})",
1344 {
1345 {
1346 {"srcActMissing", RpcSrcActMissing, "Missing field 'tx_json.Account'."},
1347 {"srcActMissing", RpcSrcActMissing, "Missing field 'tx_json.Account'."},
1348 {"srcActMissing", RpcSrcActMissing, "Missing field 'tx_json.Account'."},
1349 {"srcActMissing", RpcSrcActMissing, "Missing field 'tx_json.Account'."},
1350 },
1351 },
1352 },
1353
1354 {
1355 "Missing 'Amount' in sign_for.",
1356 __LINE__,
1357 R"({
1358 "command": "dummy_command",
1359 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1360 "secret": "masterpassphrase",
1361 "tx_json": {
1362 "Account": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1363 "Destination": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1364 "Fee": 50,
1365 "Sequence": 0,
1366 "SigningPubKey": "",
1367 "TransactionType": "Payment"
1368 }
1369})",
1370 {
1371 {
1372 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Amount'."},
1373 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Amount'."},
1374 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Amount'."},
1375 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Amount'."},
1376 },
1377 },
1378 },
1379
1380 {
1381 "Missing 'Destination' in sign_for.",
1382 __LINE__,
1383 R"({
1384 "command": "dummy_command",
1385 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1386 "secret": "masterpassphrase",
1387 "tx_json": {
1388 "Account": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1389 "Amount": "1000000000",
1390 "Fee": 50,
1391 "Sequence": 0,
1392 "SigningPubKey": "",
1393 "TransactionType": "Payment"
1394 }
1395})",
1396 {
1397 {
1398 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Destination'."},
1399 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Destination'."},
1400 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Destination'."},
1401 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Destination'."},
1402 },
1403 },
1404 },
1405
1406 {
1407 "Missing 'Destination' in sign_for, use DeliverMax",
1408 __LINE__,
1409 R"({
1410 "command": "dummy_command",
1411 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1412 "secret": "masterpassphrase",
1413 "tx_json": {
1414 "Account": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1415 "DeliverMax": "1000000000",
1416 "Fee": 50,
1417 "Sequence": 0,
1418 "SigningPubKey": "",
1419 "TransactionType": "Payment"
1420 }
1421})",
1422 {
1423 {
1424 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Destination'."},
1425 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Destination'."},
1426 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Destination'."},
1427 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Destination'."},
1428 },
1429 },
1430 },
1431
1432 {
1433 "Missing 'Fee' in sign_for.",
1434 __LINE__,
1435 R"({
1436 "command": "dummy_command",
1437 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1438 "secret": "masterpassphrase",
1439 "tx_json": {
1440 "Account": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1441 "Amount": "1000000000",
1442 "Destination": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1443 "Sequence": 0,
1444 "SigningPubKey": "",
1445 "TransactionType": "Payment"
1446 }
1447})",
1448 {
1449 {
1450 {"badSecret", RpcBadSecret, "Secret does not match account."},
1451 {"badSecret", RpcBadSecret, "Secret does not match account."},
1452 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Fee'."},
1453 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Fee'."},
1454 },
1455 },
1456 },
1457
1458 {
1459 "Missing 'Sequence' in sign_for.",
1460 __LINE__,
1461 R"({
1462 "command": "dummy_command",
1463 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1464 "secret": "masterpassphrase",
1465 "tx_json": {
1466 "Account": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1467 "Amount": "1000000000",
1468 "Destination": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1469 "Fee": 50,
1470 "SigningPubKey": "",
1471 "TransactionType": "Payment"
1472 }
1473})",
1474 {
1475 {
1476 {"badSecret", RpcBadSecret, "Secret does not match account."},
1477 {"badSecret", RpcBadSecret, "Secret does not match account."},
1478 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
1479 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
1480 },
1481 },
1482 },
1483
1484 {
1485 "Missing 'SigningPubKey' in sign_for is automatically filled in.",
1486 __LINE__,
1487 R"({
1488 "command": "dummy_command",
1489 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1490 "secret": "masterpassphrase",
1491 "tx_json": {
1492 "Account": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1493 "Amount": "1000000000",
1494 "Destination": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1495 "Fee": 50,
1496 "Sequence": 0,
1497 "TransactionType": "Payment"
1498 }
1499})",
1500 {
1501 {
1502 {"badSecret", RpcBadSecret, "Secret does not match account."},
1503 {"badSecret", RpcBadSecret, "Secret does not match account."},
1504 {},
1505 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.SigningPubKey'."},
1506 },
1507 },
1508 },
1509
1510 {
1511 "In sign_for, an account may not sign for itself.",
1512 __LINE__,
1513 R"({
1514 "command": "dummy_command",
1515 "account": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1516 "secret": "a",
1517 "tx_json": {
1518 "Account": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1519 "Amount": "1000000000",
1520 "Destination": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1521 "Fee": 50,
1522 "Sequence": 0,
1523 "TransactionType": "Payment"
1524 }
1525})",
1526 {
1527 {
1528 {},
1529 {},
1530 {
1531 "invalidParams",
1533 "A Signer may not be the transaction's Account "
1534 "(rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA).",
1535 },
1536 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.SigningPubKey'."},
1537 },
1538 },
1539 },
1540
1541 {
1542 "Cannot put duplicate accounts in Signers array",
1543 __LINE__,
1544 R"({
1545 "command": "dummy_command",
1546 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1547 "secret": "masterpassphrase",
1548 "tx_json": {
1549 "Account" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1550 "Amount" : "1000000000",
1551 "Destination" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1552 "Fee" : "50",
1553 "Sequence" : 0,
1554 "Signers" : [
1555 {
1556 "Signer" : {
1557 "Account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1558 "SigningPubKey" : "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020",
1559 "TxnSignature" : "304502210080EB23E78A841DDC5E3A4F10DE6EAF052207D6B519BF8954467ADB221B3F349002202CA458E8D4E4DE7176D27A91628545E7B295A5DFC8ADF0B5CD3E279B6FA02998"
1560 }
1561 }
1562 ],
1563 "SigningPubKey" : "",
1564 "TransactionType" : "Payment"
1565 }
1566})",
1567 {
1568 {
1569 {"alreadyMultisig", RpcAlreadyMultisig, "Already multisigned."},
1570 {"alreadyMultisig", RpcAlreadyMultisig, "Already multisigned."},
1571 {
1572 "invalidParams",
1574 "Duplicate Signers:Signer:Account entries "
1575 "(rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh) are not allowed.",
1576 },
1577 {},
1578 },
1579 },
1580 },
1581
1582 {
1583 "Correctly append to pre-established Signers array",
1584 __LINE__,
1585 R"({
1586 "command": "dummy_command",
1587 "account": "rPcNzota6B8YBokhYtcTNqQVCngtbnWfux",
1588 "secret": "c",
1589 "tx_json": {
1590 "Account" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1591 "Amount" : "1000000000",
1592 "Destination" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1593 "Fee" : "50",
1594 "Sequence" : 0,
1595 "Signers" : [
1596 {
1597 "Signer" : {
1598 "Account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1599 "SigningPubKey" : "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020",
1600 "TxnSignature" : "304502210080EB23E78A841DDC5E3A4F10DE6EAF052207D6B519BF8954467ADB221B3F349002202CA458E8D4E4DE7176D27A91628545E7B295A5DFC8ADF0B5CD3E279B6FA02998"
1601 }
1602 }
1603 ],
1604 "SigningPubKey" : "",
1605 "TransactionType" : "Payment"
1606 }
1607})",
1608 {
1609 {
1610 {"alreadyMultisig", RpcAlreadyMultisig, "Already multisigned."},
1611 {"alreadyMultisig", RpcAlreadyMultisig, "Already multisigned."},
1612 {},
1613 {},
1614 },
1615 },
1616 },
1617
1618 {
1619 "Append to pre-established Signers array with bad signature",
1620 __LINE__,
1621 R"({
1622 "command": "dummy_command",
1623 "account": "rPcNzota6B8YBokhYtcTNqQVCngtbnWfux",
1624 "secret": "c",
1625 "tx_json": {
1626 "Account" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1627 "Amount" : "1000000000",
1628 "Destination" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1629 "Fee" : "50",
1630 "Sequence" : 0,
1631 "Signers" : [
1632 {
1633 "Signer" : {
1634 "Account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1635 "SigningPubKey" : "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020",
1636 "TxnSignature" : "304502210080EB23E78A841DDC5E3A4F10DE6EAF052207D6B519BF8954467ACB221B3F349002202CA458E8D4E4DE7176D27A91628545E7B295A5DFC8ADF0B5CD3E279B6FA02998"
1637 }
1638 }
1639 ],
1640 "SigningPubKey" : "",
1641 "TransactionType" : "Payment"
1642 }
1643})",
1644 {
1645 {
1646 {"alreadyMultisig", RpcAlreadyMultisig, "Already multisigned."},
1647 {"alreadyMultisig", RpcAlreadyMultisig, "Already multisigned."},
1648 {"internal", RpcInternal, "Invalid signature."},
1649 {"internal", RpcInternal, "Invalid signature."},
1650 },
1651 },
1652 },
1653
1654 {
1655 "Non-empty 'SigningPubKey' in sign_for.",
1656 __LINE__,
1657 R"({
1658 "command": "dummy_command",
1659 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1660 "secret": "masterpassphrase",
1661 "tx_json": {
1662 "Account": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1663 "Amount": "1000000000",
1664 "Destination": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1665 "Fee": 50,
1666 "Sequence": 0,
1667 "SigningPubKey": "1",
1668 "TransactionType": "Payment"
1669 }
1670})",
1671 {
1672 {
1673 {"badSecret", RpcBadSecret, "Secret does not match account."},
1674 {"badSecret", RpcBadSecret, "Secret does not match account."},
1675 {
1676 "invalidParams",
1678 "When multi-signing 'tx_json.SigningPubKey' must be empty.",
1679 },
1680 {
1681 "invalidParams",
1683 "When multi-signing 'tx_json.SigningPubKey' must be empty.",
1684 },
1685 },
1686 },
1687 },
1688
1689 {
1690 "Missing 'TransactionType' in sign_for.",
1691 __LINE__,
1692 R"({
1693 "command": "dummy_command",
1694 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1695 "secret": "masterpassphrase",
1696 "tx_json": {
1697 "Account": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1698 "Amount": "1000000000",
1699 "Destination": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1700 "Fee": 50,
1701 "Sequence": 0,
1702 "SigningPubKey": "",
1703 }
1704})",
1705 {
1706 {
1707 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.TransactionType'."},
1708 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.TransactionType'."},
1709 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.TransactionType'."},
1710 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.TransactionType'."},
1711 },
1712 },
1713 },
1714
1715 {
1716 "TxnSignature in sign_for.",
1717 __LINE__,
1718 R"({
1719 "command": "dummy_command",
1720 "account": "rPcNzota6B8YBokhYtcTNqQVCngtbnWfux",
1721 "secret": "c",
1722 "tx_json": {
1723 "Account" : "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1724 "Amount" : "1000000000",
1725 "Destination" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1726 "Fee" : "50",
1727 "Sequence" : 0,
1728 "Signers" : [
1729 {
1730 "Signer" : {
1731 "Account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1732 "SigningPubKey" : "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020",
1733 "TxnSignature" : "304502210080EB23E78A841DDC5E3A4F10DE6EAF052207D6B519BF8954467ADB221B3F349002202CA458E8D4E4DE7176D27A91628545E7B295A5DFC8ADF0B5CD3E279B6FA02998"
1734 }
1735 }
1736 ],
1737 "SigningPubKey" : "",
1738 "TxnSignature" : "304502210080EB23E78A841DDC5E3A4F10DE6EAF052207D6B519BF8954467ADB221B3F349002202CA458E8D4E4DE7176D27A91628545E7B295A5DFC8ADF0B5CD3E279B6FA02998",
1739 "TransactionType" : "Payment"
1740 }
1741})",
1742 {
1743 {
1744 {"alreadyMultisig", RpcAlreadyMultisig, "Already multisigned."},
1745 {"alreadyMultisig", RpcAlreadyMultisig, "Already multisigned."},
1746 {"alreadySingleSig", RpcAlreadySingleSig, "Already single-signed."},
1747 {"signingMalformed", RpcSigningMalformed, "Signing of transaction is malformed."},
1748 },
1749 },
1750 },
1751
1752 {
1753 "Invalid field 'tx_json': string instead of object",
1754 __LINE__,
1755 R"({
1756 "command": "dummy_command",
1757 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1758 "secret": "masterpassphrase",
1759 "tx_json": ""
1760})",
1761 {
1762 {
1763 {"invalidParams", RpcInvalidParams, "Invalid field 'tx_json', not object."},
1764 {"invalidParams", RpcInvalidParams, "Invalid field 'tx_json', not object."},
1765 {"invalidParams", RpcInvalidParams, "Invalid field 'tx_json', not object."},
1766 {"invalidParams", RpcInvalidParams, "Invalid field 'tx_json', not object."},
1767 },
1768 },
1769 },
1770
1771 {
1772 "Invalid field 'tx_json': integer instead of object",
1773 __LINE__,
1774 R"({
1775 "command": "dummy_command",
1776 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1777 "secret": "masterpassphrase",
1778 "tx_json": 20160331
1779})",
1780 {
1781 {
1782 {"invalidParams", RpcInvalidParams, "Invalid field 'tx_json', not object."},
1783 {"invalidParams", RpcInvalidParams, "Invalid field 'tx_json', not object."},
1784 {"invalidParams", RpcInvalidParams, "Invalid field 'tx_json', not object."},
1785 {"invalidParams", RpcInvalidParams, "Invalid field 'tx_json', not object."},
1786 },
1787 },
1788 },
1789
1790 {
1791 "Invalid field 'tx_json': array instead of object",
1792 __LINE__,
1793 R"({
1794 "command": "dummy_command",
1795 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1796 "secret": "masterpassphrase",
1797 "tx_json": [ "hello", "world" ]
1798})",
1799 {
1800 {
1801 {"invalidParams", RpcInvalidParams, "Invalid field 'tx_json', not object."},
1802 {"invalidParams", RpcInvalidParams, "Invalid field 'tx_json', not object."},
1803 {"invalidParams", RpcInvalidParams, "Invalid field 'tx_json', not object."},
1804 {"invalidParams", RpcInvalidParams, "Invalid field 'tx_json', not object."},
1805 },
1806 },
1807 },
1808
1809 {
1810 "Pass in Fee with minimal payment, both Amount and DeliverMax.",
1811 __LINE__,
1812 R"({
1813 "command": "dummy_command",
1814 "account": "r9zN9x52FiCFAcicCLMQKbj1nxYhxJbbSy",
1815 "secret": "ssgN6zTvtM1q9XV8DvJpWm8LBYWiY",
1816 "tx_json": {
1817 "Fee": 10,
1818 "Account": "r9zN9x52FiCFAcicCLMQKbj1nxYhxJbbSy",
1819 "Amount": "1000000000",
1820 "DeliverMax": "1000000000",
1821 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1822 "TransactionType": "Payment"
1823 }
1824})",
1825 {
1826 {
1827 {"srcActNotFound", RpcSrcActNotFound, "Source account not found."},
1828 {"srcActNotFound", RpcSrcActNotFound, "Source account not found."},
1829 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
1830 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
1831 },
1832 },
1833 },
1834
1835 {
1836 "Minimal submit_multisigned.",
1837 __LINE__,
1838 R"({
1839 "command": "submit_multisigned",
1840 "tx_json": {
1841 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1842 "Amount": "1000000000",
1843 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1844 "Fee": 50,
1845 "Sequence": 0,
1846 "Signers" : [
1847 {
1848 "Signer" : {
1849 "Account" : "rPcNzota6B8YBokhYtcTNqQVCngtbnWfux",
1850 "SigningPubKey" : "02FE36A690D6973D55F88553F5D2C4202DE75F2CF8A6D0E17C70AC223F044501F8",
1851 "TxnSignature" : "3045022100909D01399AFFAD1E30D250CE61F93975B7F61E47B5244D78C3E86D9806535D95022012E389E0ACB016334052B7FE07FA6CEFDC8BE82CB410FA841D5049641C89DC8F"
1852 }
1853 }
1854 ],
1855 "SigningPubKey": "",
1856 "TransactionType": "Payment"
1857 }
1858})",
1859 {
1860 {
1861 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
1862 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
1863 {"invalidParams", RpcInvalidParams, "Missing field 'account'."},
1864 {},
1865 },
1866 },
1867 },
1868
1869 {
1870 "Minimal submit_multisigned with bad signature.",
1871 __LINE__,
1872 R"({
1873 "command": "submit_multisigned",
1874 "tx_json": {
1875 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1876 "Amount": "1000000000",
1877 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1878 "Fee": 50,
1879 "Sequence": 0,
1880 "Signers": [
1881 {
1882 "Signer": {
1883 "Account": "rPcNzota6B8YBokhYtcTNqQVCngtbnWfux",
1884 "TxnSignature": "3045022100F9ED357606932697A4FAB2BE7F222C21DD93CA4CFDD90357AADD07465E8457D6022038173193E3DFFFB5D78DD738CC0905395F885DA65B98FDB9793901FE3FD26ECE",
1885 "SigningPubKey": "02FE36A690D6973D55F88553F5D2C4202DE75F2CF8A6D0E17C70AC223F044501F8"
1886 }
1887 }
1888 ],
1889 "SigningPubKey": "",
1890 "TransactionType": "Payment"
1891 }
1892})",
1893 {
1894 {
1895 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
1896 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
1897 {"invalidParams", RpcInvalidParams, "Missing field 'account'."},
1898 {"internal", RpcInternal, "Invalid signature."},
1899 },
1900 },
1901 },
1902
1903 {
1904 "Missing tx_json in submit_multisigned.",
1905 __LINE__,
1906 R"({
1907 "command": "submit_multisigned",
1908 "Signers": [
1909 {
1910 "Signer": {
1911 "Account": "rPcNzota6B8YBokhYtcTNqQVCngtbnWfux",
1912 "TxnSignature": "3045022100F9ED357606932697A4FAB2BE7F222C21DD93CA4CFDD90357AADD07465E8457D6022038173193E3DFFFB5D78DD738CC0905395F885DA65B98FDB9793901FE3FD26ECE",
1913 "SigningPubKey": "02FE36A690D6973D55F88553F5D2C4202DE75F2CF8A6D0E17C70AC223F044501F8"
1914 }
1915 }
1916 ]
1917})",
1918 {
1919 {
1920 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
1921 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
1922 {"invalidParams", RpcInvalidParams, "Missing field 'account'."},
1923 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json'."},
1924 },
1925 },
1926 },
1927
1928 {
1929 "Missing sequence in submit_multisigned.",
1930 __LINE__,
1931 R"({
1932 "command": "submit_multisigned",
1933 "tx_json": {
1934 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1935 "Amount": "1000000000",
1936 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1937 "Fee": 50,
1938 "Signers": [
1939 {
1940 "Signer": {
1941 "Account": "rPcNzota6B8YBokhYtcTNqQVCngtbnWfux",
1942 "TxnSignature": "3045022100F9ED357606932697A4FAB2BE7F222C21DD93CA4CFDD90357AADD07465E8457D6022038173193E3DFFFB5D78DD738CC0905395F885DA65B98FDB9793901FE3FD26ECE",
1943 "SigningPubKey": "02FE36A690D6973D55F88553F5D2C4202DE75F2CF8A6D0E17C70AC223F044501F8"
1944 }
1945 }
1946 ],
1947 "SigningPubKey": "",
1948 "TransactionType": "Payment"
1949 }
1950})",
1951 {
1952 {
1953 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
1954 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
1955 {"invalidParams", RpcInvalidParams, "Missing field 'account'."},
1956 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
1957 },
1958 },
1959 },
1960
1961 {
1962 "Missing SigningPubKey in submit_multisigned.",
1963 __LINE__,
1964 R"({
1965 "command": "submit_multisigned",
1966 "tx_json": {
1967 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
1968 "Amount": "1000000000",
1969 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
1970 "Fee": 50,
1971 "Signers": [
1972 {
1973 "Signer": {
1974 "Account": "rPcNzota6B8YBokhYtcTNqQVCngtbnWfux",
1975 "TxnSignature": "3045022100F9ED357606932697A4FAB2BE7F222C21DD93CA4CFDD90357AADD07465E8457D6022038173193E3DFFFB5D78DD738CC0905395F885DA65B98FDB9793901FE3FD26ECE",
1976 "SigningPubKey": "02FE36A690D6973D55F88553F5D2C4202DE75F2CF8A6D0E17C70AC223F044501F8"
1977 }
1978 }
1979 ],
1980 "Sequence": 0,
1981 "TransactionType": "Payment"
1982 }
1983})",
1984 {
1985 {
1986 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
1987 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
1988 {"invalidParams", RpcInvalidParams, "Missing field 'account'."},
1989 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.SigningPubKey'."},
1990 },
1991 },
1992 },
1993
1994 {
1995 "Non-empty SigningPubKey in submit_multisigned.",
1996 __LINE__,
1997 R"({
1998 "command": "submit_multisigned",
1999 "tx_json": {
2000 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2001 "Amount": "1000000000",
2002 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
2003 "Fee": 50,
2004 "Sequence": 0,
2005 "Signers": [
2006 {
2007 "Signer": {
2008 "Account": "rPcNzota6B8YBokhYtcTNqQVCngtbnWfux",
2009 "TxnSignature": "3045022100F9ED357606932697A4FAB2BE7F222C21DD93CA4CFDD90357AADD07465E8457D6022038173193E3DFFFB5D78DD738CC0905395F885DA65B98FDB9793901FE3FD26ECE",
2010 "SigningPubKey": "02FE36A690D6973D55F88553F5D2C4202DE75F2CF8A6D0E17C70AC223F044501F8"
2011 }
2012 }
2013 ],
2014 "SigningPubKey": "02FE36A690D6973D55F88553F5D2C4202DE75F2CF8A6D0E17C70AC223F044501F8",
2015 "TransactionType": "Payment"
2016 }
2017})",
2018 {
2019 {
2020 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2021 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2022 {"invalidParams", RpcInvalidParams, "Missing field 'account'."},
2023 {
2024 "invalidParams",
2026 "When multi-signing 'tx_json.SigningPubKey' must be empty.",
2027 },
2028 },
2029 },
2030 },
2031
2032 {
2033 "Missing TransactionType in submit_multisigned.",
2034 __LINE__,
2035 R"({
2036 "command": "submit_multisigned",
2037 "tx_json": {
2038 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2039 "Amount": "1000000000",
2040 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
2041 "Fee": 50,
2042 "Signers": [
2043 {
2044 "Signer": {
2045 "Account": "rPcNzota6B8YBokhYtcTNqQVCngtbnWfux",
2046 "TxnSignature": "3045022100F9ED357606932697A4FAB2BE7F222C21DD93CA4CFDD90357AADD07465E8457D6022038173193E3DFFFB5D78DD738CC0905395F885DA65B98FDB9793901FE3FD26ECE",
2047 "SigningPubKey": "02FE36A690D6973D55F88553F5D2C4202DE75F2CF8A6D0E17C70AC223F044501F8"
2048 }
2049 }
2050 ],
2051 "Sequence": 0,
2052 "SigningPubKey": "",
2053 }
2054})",
2055 {
2056 {
2057 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2058 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2059 {"invalidParams", RpcInvalidParams, "Missing field 'account'."},
2060 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.TransactionType'."},
2061 },
2062 },
2063 },
2064
2065 {
2066 "Missing Account in submit_multisigned.",
2067 __LINE__,
2068 R"({
2069 "command": "submit_multisigned",
2070 "tx_json": {
2071 "Amount": "1000000000",
2072 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
2073 "Fee": 50,
2074 "Sequence": 0,
2075 "Signers": [
2076 {
2077 "Signer": {
2078 "Account": "rPcNzota6B8YBokhYtcTNqQVCngtbnWfux",
2079 "TxnSignature": "3045022100F9ED357606932697A4FAB2BE7F222C21DD93CA4CFDD90357AADD07465E8457D6022038173193E3DFFFB5D78DD738CC0905395F885DA65B98FDB9793901FE3FD26ECE",
2080 "SigningPubKey": "02FE36A690D6973D55F88553F5D2C4202DE75F2CF8A6D0E17C70AC223F044501F8"
2081 }
2082 }
2083 ],
2084 "SigningPubKey": "",
2085 "TransactionType": "Payment"
2086 }
2087})",
2088 {
2089 {
2090 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2091 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2092 {"invalidParams", RpcInvalidParams, "Missing field 'account'."},
2093 {"srcActMissing", RpcSrcActMissing, "Missing field 'tx_json.Account'."},
2094 },
2095 },
2096 },
2097
2098 {
2099 "Malformed Account in submit_multisigned.",
2100 __LINE__,
2101 R"({
2102 "command": "submit_multisigned",
2103 "tx_json": {
2104 "Account": "NotAnAccount",
2105 "Amount": "1000000000",
2106 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
2107 "Fee": 50,
2108 "Sequence": 0,
2109 "Signers": [
2110 {
2111 "Signer": {
2112 "Account": "rPcNzota6B8YBokhYtcTNqQVCngtbnWfux",
2113 "TxnSignature": "3045022100F9ED357606932697A4FAB2BE7F222C21DD93CA4CFDD90357AADD07465E8457D6022038173193E3DFFFB5D78DD738CC0905395F885DA65B98FDB9793901FE3FD26ECE",
2114 "SigningPubKey": "02FE36A690D6973D55F88553F5D2C4202DE75F2CF8A6D0E17C70AC223F044501F8"
2115 }
2116 }
2117 ],
2118 "SigningPubKey": "",
2119 "TransactionType": "Payment"
2120 }
2121})",
2122 {
2123 {
2124 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2125 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2126 {"invalidParams", RpcInvalidParams, "Missing field 'account'."},
2127 {"srcActMalformed", RpcSrcActMalformed, "Invalid field 'tx_json.Account'."},
2128 },
2129 },
2130 },
2131
2132 {
2133 "Account not in ledger in submit_multisigned.",
2134 __LINE__,
2135 R"({
2136 "command": "submit_multisigned",
2137 "tx_json": {
2138 "Account": "rDg53Haik2475DJx8bjMDSDPj4VX7htaMd",
2139 "Amount": "1000000000",
2140 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
2141 "Fee": 50,
2142 "Sequence": 0,
2143 "Signers": [
2144 {
2145 "Signer": {
2146 "Account": "rPcNzota6B8YBokhYtcTNqQVCngtbnWfux",
2147 "TxnSignature": "3045022100F9ED357606932697A4FAB2BE7F222C21DD93CA4CFDD90357AADD07465E8457D6022038173193E3DFFFB5D78DD738CC0905395F885DA65B98FDB9793901FE3FD26ECE",
2148 "SigningPubKey": "02FE36A690D6973D55F88553F5D2C4202DE75F2CF8A6D0E17C70AC223F044501F8"
2149 }
2150 }
2151 ],
2152 "SigningPubKey": "",
2153 "TransactionType": "Payment"
2154 }
2155})",
2156 {
2157 {
2158 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2159 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2160 {"invalidParams", RpcInvalidParams, "Missing field 'account'."},
2161 {"srcActNotFound", RpcSrcActNotFound, "Source account not found."},
2162 },
2163 },
2164 },
2165
2166 {
2167 "Missing Fee in submit_multisigned.",
2168 __LINE__,
2169 R"({
2170 "command": "submit_multisigned",
2171 "tx_json": {
2172 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2173 "Amount": "1000000000",
2174 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
2175 "Sequence": 0,
2176 "Signers": [
2177 {
2178 "Signer": {
2179 "Account": "rPcNzota6B8YBokhYtcTNqQVCngtbnWfux",
2180 "TxnSignature": "3045022100F9ED357606932697A4FAB2BE7F222C21DD93CA4CFDD90357AADD07465E8457D6022038173193E3DFFFB5D78DD738CC0905395F885DA65B98FDB9793901FE3FD26ECE",
2181 "SigningPubKey": "02FE36A690D6973D55F88553F5D2C4202DE75F2CF8A6D0E17C70AC223F044501F8"
2182 }
2183 }
2184 ],
2185 "SigningPubKey": "",
2186 "TransactionType": "Payment"
2187 }
2188})",
2189 {
2190 {
2191 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2192 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2193 {"invalidParams", RpcInvalidParams, "Missing field 'account'."},
2194 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Fee'."},
2195 },
2196 },
2197 },
2198
2199 {
2200 "Non-numeric Fee in submit_multisigned.",
2201 __LINE__,
2202 R"({
2203 "command": "submit_multisigned",
2204 "tx_json": {
2205 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2206 "Amount": "1000000000",
2207 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
2208 "Fee": 50.1,
2209 "Sequence": 0,
2210 "Signers": [
2211 {
2212 "Signer": {
2213 "Account": "rPcNzota6B8YBokhYtcTNqQVCngtbnWfux",
2214 "TxnSignature": "3045022100F9ED357606932697A4FAB2BE7F222C21DD93CA4CFDD90357AADD07465E8457D6022038173193E3DFFFB5D78DD738CC0905395F885DA65B98FDB9793901FE3FD26ECE",
2215 "SigningPubKey": "02FE36A690D6973D55F88553F5D2C4202DE75F2CF8A6D0E17C70AC223F044501F8"
2216 }
2217 }
2218 ],
2219 "SigningPubKey": "",
2220 "TransactionType": "Payment"
2221 }
2222})",
2223 {
2224 {
2225 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2226 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2227 {"invalidParams", RpcInvalidParams, "Missing field 'account'."},
2228 {"invalidParams", RpcInvalidParams, "Field 'tx_json.Fee' has invalid data."},
2229 },
2230 },
2231 },
2232
2233 {
2234 "Missing Amount in submit_multisigned Payment.",
2235 __LINE__,
2236 R"({
2237 "command": "submit_multisigned",
2238 "tx_json": {
2239 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2240 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
2241 "Fee": 50000000,
2242 "Sequence": 0,
2243 "Signers": [
2244 {
2245 "Signer": {
2246 "Account": "rPcNzota6B8YBokhYtcTNqQVCngtbnWfux",
2247 "TxnSignature": "3045022100F9ED357606932697A4FAB2BE7F222C21DD93CA4CFDD90357AADD07465E8457D6022038173193E3DFFFB5D78DD738CC0905395F885DA65B98FDB9793901FE3FD26ECE",
2248 "SigningPubKey": "02FE36A690D6973D55F88553F5D2C4202DE75F2CF8A6D0E17C70AC223F044501F8"
2249 }
2250 }
2251 ],
2252 "SigningPubKey": "",
2253 "TransactionType": "Payment"
2254 }
2255})",
2256 {
2257 {
2258 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2259 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2260 {"invalidParams", RpcInvalidParams, "Missing field 'account'."},
2261 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Amount'."},
2262 },
2263 },
2264 },
2265
2266 {
2267 "Invalid Amount in submit_multisigned Payment.",
2268 __LINE__,
2269 R"({
2270 "command": "submit_multisigned",
2271 "tx_json": {
2272 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2273 "Amount": "NotANumber",
2274 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
2275 "Fee": 50,
2276 "Sequence": 0,
2277 "Signers": [
2278 {
2279 "Signer": {
2280 "Account": "rPcNzota6B8YBokhYtcTNqQVCngtbnWfux",
2281 "TxnSignature": "3045022100F9ED357606932697A4FAB2BE7F222C21DD93CA4CFDD90357AADD07465E8457D6022038173193E3DFFFB5D78DD738CC0905395F885DA65B98FDB9793901FE3FD26ECE",
2282 "SigningPubKey": "02FE36A690D6973D55F88553F5D2C4202DE75F2CF8A6D0E17C70AC223F044501F8"
2283 }
2284 }
2285 ],
2286 "SigningPubKey": "",
2287 "TransactionType": "Payment"
2288 }
2289})",
2290 {
2291 {
2292 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2293 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2294 {"invalidParams", RpcInvalidParams, "Missing field 'account'."},
2295 {"invalidParams", RpcInvalidParams, "Invalid field 'tx_json.Amount'."},
2296 },
2297 },
2298 },
2299
2300 {
2301 "Invalid DeliverMax in submit_multisigned Payment.",
2302 __LINE__,
2303 R"({
2304 "command": "submit_multisigned",
2305 "tx_json": {
2306 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2307 "DeliverMax": "NotANumber",
2308 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
2309 "Fee": 50,
2310 "Sequence": 0,
2311 "Signers": [
2312 {
2313 "Signer": {
2314 "Account": "rPcNzota6B8YBokhYtcTNqQVCngtbnWfux",
2315 "TxnSignature": "3045022100F9ED357606932697A4FAB2BE7F222C21DD93CA4CFDD90357AADD07465E8457D6022038173193E3DFFFB5D78DD738CC0905395F885DA65B98FDB9793901FE3FD26ECE",
2316 "SigningPubKey": "02FE36A690D6973D55F88553F5D2C4202DE75F2CF8A6D0E17C70AC223F044501F8"
2317 }
2318 }
2319 ],
2320 "SigningPubKey": "",
2321 "TransactionType": "Payment"
2322 }
2323})",
2324 {
2325 {
2326 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2327 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2328 {"invalidParams", RpcInvalidParams, "Missing field 'account'."},
2329 {"invalidParams", RpcInvalidParams, "Invalid field 'tx_json.Amount'."},
2330 },
2331 },
2332 },
2333
2334 {
2335 "No build_path in submit_multisigned.",
2336 __LINE__,
2337 R"({
2338 "command": "submit_multisigned",
2339 "build_path": 1,
2340 "tx_json": {
2341 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2342 "Amount": "1000000000",
2343 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
2344 "Fee": 50,
2345 "Sequence": 0,
2346 "Signers": [
2347 {
2348 "Signer": {
2349 "Account": "rPcNzota6B8YBokhYtcTNqQVCngtbnWfux",
2350 "TxnSignature": "3045022100F9ED357606932697A4FAB2BE7F222C21DD93CA4CFDD90357AADD07465E8457D6022038173193E3DFFFB5D78DD738CC0905395F885DA65B98FDB9793901FE3FD26ECE",
2351 "SigningPubKey": "02FE36A690D6973D55F88553F5D2C4202DE75F2CF8A6D0E17C70AC223F044501F8"
2352 }
2353 }
2354 ],
2355 "SigningPubKey": "",
2356 "TransactionType": "Payment"
2357 }
2358})",
2359 {
2360 {
2361 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2362 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2363 {"invalidParams", RpcInvalidParams, "Missing field 'account'."},
2364 {
2365 "invalidParams",
2367 "Field 'build_path' not allowed in this context.",
2368 },
2369 },
2370 },
2371 },
2372
2373 {
2374 "Missing Destination in submit_multisigned Payment.",
2375 __LINE__,
2376 R"({
2377 "command": "submit_multisigned",
2378 "tx_json": {
2379 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2380 "Amount": "1000000000",
2381 "Fee": 50,
2382 "Sequence": 0,
2383 "Signers": [
2384 {
2385 "Signer": {
2386 "Account": "rPcNzota6B8YBokhYtcTNqQVCngtbnWfux",
2387 "TxnSignature": "3045022100F9ED357606932697A4FAB2BE7F222C21DD93CA4CFDD90357AADD07465E8457D6022038173193E3DFFFB5D78DD738CC0905395F885DA65B98FDB9793901FE3FD26ECE",
2388 "SigningPubKey": "02FE36A690D6973D55F88553F5D2C4202DE75F2CF8A6D0E17C70AC223F044501F8"
2389 }
2390 }
2391 ],
2392 "SigningPubKey": "",
2393 "TransactionType": "Payment"
2394 }
2395})",
2396 {
2397 {
2398 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2399 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2400 {"invalidParams", RpcInvalidParams, "Missing field 'account'."},
2401 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Destination'."},
2402 },
2403 },
2404 },
2405
2406 {
2407 "Malformed Destination in submit_multisigned Payment.",
2408 __LINE__,
2409 R"({
2410 "command": "submit_multisigned",
2411 "tx_json": {
2412 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2413 "Amount": "1000000000",
2414 "Destination": "NotADestination",
2415 "Fee": 50,
2416 "Sequence": 0,
2417 "Signers": [
2418 {
2419 "Signer": {
2420 "Account": "rPcNzota6B8YBokhYtcTNqQVCngtbnWfux",
2421 "TxnSignature": "3045022100F9ED357606932697A4FAB2BE7F222C21DD93CA4CFDD90357AADD07465E8457D6022038173193E3DFFFB5D78DD738CC0905395F885DA65B98FDB9793901FE3FD26ECE",
2422 "SigningPubKey": "02FE36A690D6973D55F88553F5D2C4202DE75F2CF8A6D0E17C70AC223F044501F8"
2423 }
2424 }
2425 ],
2426 "SigningPubKey": "",
2427 "TransactionType": "Payment"
2428 }
2429})",
2430 {
2431 {
2432 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2433 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2434 {"invalidParams", RpcInvalidParams, "Missing field 'account'."},
2435 {"invalidParams", RpcInvalidParams, "Invalid field 'tx_json.Destination'."},
2436 },
2437 },
2438 },
2439
2440 {
2441 "Missing Signers field in submit_multisigned.",
2442 __LINE__,
2443 R"({
2444 "command": "submit_multisigned",
2445 "tx_json": {
2446 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2447 "Amount": "1000000000",
2448 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
2449 "Fee": 50,
2450 "Sequence": 0,
2451 "SigningPubKey": "",
2452 "TransactionType": "Payment"
2453 }
2454})",
2455 {
2456 {
2457 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2458 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2459 {"invalidParams", RpcInvalidParams, "Missing field 'account'."},
2460 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Signers'."},
2461 },
2462 },
2463 },
2464
2465 {
2466 "Signers not an array in submit_multisigned.",
2467 __LINE__,
2468 R"({
2469 "command": "submit_multisigned",
2470 "tx_json": {
2471 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2472 "Amount": "1000000000",
2473 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
2474 "Fee": 50,
2475 "Sequence": 0,
2476 "Signers": {
2477 "Account": "rPcNzota6B8YBokhYtcTNqQVCngtbnWfux",
2478 "TxnSignature": "3045022100F9ED357606932697A4FAB2BE7F222C21DD93CA4CFDD90357AADD07465E8457D6022038173193E3DFFFB5D78DD738CC0905395F885DA65B98FDB9793901FE3FD26ECE",
2479 "SigningPubKey": "02FE36A690D6973D55F88553F5D2C4202DE75F2CF8A6D0E17C70AC223F044501F8"
2480 },
2481 "SigningPubKey": "",
2482 "TransactionType": "Payment"
2483 }
2484})",
2485 {
2486 {
2487 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2488 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2489 {"invalidParams", RpcInvalidParams, "Missing field 'account'."},
2490 {"invalidParams", RpcInvalidParams, "Field 'tx_json.Signers' is not a JSON array."},
2491 },
2492 },
2493 },
2494
2495 {
2496 "Empty Signers array in submit_multisigned.",
2497 __LINE__,
2498 R"({
2499 "command": "submit_multisigned",
2500 "tx_json": {
2501 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2502 "Amount": "1000000000",
2503 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
2504 "Fee": 50,
2505 "Sequence": 0,
2506 "Signers": [
2507 ],
2508 "SigningPubKey": "",
2509 "TransactionType": "Payment"
2510 }
2511})",
2512 {
2513 {
2514 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2515 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2516 {"invalidParams", RpcInvalidParams, "Missing field 'account'."},
2517 {"invalidParams", RpcInvalidParams, "tx_json.Signers array may not be empty."},
2518 },
2519 },
2520 },
2521
2522 {
2523 "Duplicate Signer in submit_multisigned.",
2524 __LINE__,
2525 R"({
2526 "command": "submit_multisigned",
2527 "tx_json": {
2528 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2529 "Amount": "1000000000",
2530 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
2531 "Fee": 50,
2532 "Sequence": 0,
2533 "Signers": [
2534 {
2535 "Signer": {
2536 "Account": "rPcNzota6B8YBokhYtcTNqQVCngtbnWfux",
2537 "TxnSignature": "3045022100F9ED357606932697A4FAB2BE7F222C21DD93CA4CFDD90357AADD07465E8457D6022038173193E3DFFFB5D78DD738CC0905395F885DA65B98FDB9793901FE3FD26ECE",
2538 "SigningPubKey": "02FE36A690D6973D55F88553F5D2C4202DE75F2CF8A6D0E17C70AC223F044501F8"
2539 }
2540 },
2541 {
2542 "Signer": {
2543 "Account": "rPcNzota6B8YBokhYtcTNqQVCngtbnWfux",
2544 "TxnSignature": "3045022100F9ED357606932697A4FAB2BE7F222C21DD93CA4CFDD90357AADD07465E8457D6022038173193E3DFFFB5D78DD738CC0905395F885DA65B98FDB9793901FE3FD26ECE",
2545 "SigningPubKey": "02FE36A690D6973D55F88553F5D2C4202DE75F2CF8A6D0E17C70AC223F044501F8"
2546 }
2547 }
2548 ],
2549 "SigningPubKey": "",
2550 "TransactionType": "Payment"
2551 }
2552})",
2553 {
2554 {
2555 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2556 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2557 {"invalidParams", RpcInvalidParams, "Missing field 'account'."},
2558 {
2559 "invalidParams",
2561 "Duplicate Signers:Signer:Account entries "
2562 "(rPcNzota6B8YBokhYtcTNqQVCngtbnWfux) are not allowed.",
2563 },
2564 },
2565 },
2566 },
2567
2568 {
2569 "Signer is tx_json Account in submit_multisigned.",
2570 __LINE__,
2571 R"({
2572 "command": "submit_multisigned",
2573 "tx_json": {
2574 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2575 "Amount": "1000000000",
2576 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
2577 "Fee": 50,
2578 "Sequence": 0,
2579 "Signers": [
2580 {
2581 "Signer": {
2582 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2583 "TxnSignature": "3045022100F9ED357606932697A4FAB2BE7F222C21DD93CA4CFDD90357AADD07465E8457D6022038173193E3DFFFB5D78DD738CC0905395F885DA65B98FDB9793901FE3FD26ECE",
2584 "SigningPubKey": "02FE36A690D6973D55F88553F5D2C4202DE75F2CF8A6D0E17C70AC223F044501F8"
2585 }
2586 }
2587 ],
2588 "SigningPubKey": "",
2589 "TransactionType": "Payment"
2590 }
2591})",
2592 {
2593 {
2594 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2595 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2596 {"invalidParams", RpcInvalidParams, "Missing field 'account'."},
2597 {
2598 "invalidParams",
2600 "A Signer may not be the transaction's Account "
2601 "(rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh).",
2602 },
2603 },
2604 },
2605 },
2606
2607 {
2608 "Empty Signers array in submit_multisigned, use DeliverMax",
2609 __LINE__,
2610 R"({
2611 "command": "submit_multisigned",
2612 "tx_json": {
2613 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2614 "DeliverMax": "10000000",
2615 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
2616 "Fee": 50,
2617 "Sequence": 0,
2618 "Signers": [
2619 ],
2620 "SigningPubKey": "",
2621 "TransactionType": "Payment"
2622 }
2623})",
2624 {
2625 {
2626 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2627 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2628 {"invalidParams", RpcInvalidParams, "Missing field 'account'."},
2629 {"invalidParams", RpcInvalidParams, "tx_json.Signers array may not be empty."},
2630 },
2631 },
2632 },
2633
2634 {
2635 "Empty Signers array in submit_multisigned, use DeliverMax and Amount",
2636 __LINE__,
2637 R"({
2638 "command": "submit_multisigned",
2639 "tx_json": {
2640 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2641 "Amount": "10000000",
2642 "DeliverMax": "10000000",
2643 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
2644 "Fee": 50,
2645 "Sequence": 0,
2646 "Signers": [
2647 ],
2648 "SigningPubKey": "",
2649 "TransactionType": "Payment"
2650 }
2651})",
2652 {
2653 {
2654 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2655 {"invalidParams", RpcInvalidParams, "Missing field 'secret'."},
2656 {"invalidParams", RpcInvalidParams, "Missing field 'account'."},
2657 {"invalidParams", RpcInvalidParams, "tx_json.Signers array may not be empty."},
2658 },
2659 },
2660 },
2661
2662 {
2663 "Payment cannot specify different DeliverMax and Amount.",
2664 __LINE__,
2665 R"({
2666 "command": "dummy_command",
2667 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2668 "secret": "masterpassphrase",
2669 "debug_signing": 0,
2670 "tx_json": {
2671 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2672 "Amount": "1000000000",
2673 "DeliverMax": "1000000020",
2674 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
2675 "Fee": 50,
2676 "Sequence": 0,
2677 "SigningPubKey": "",
2678 "TransactionType": "Payment"
2679 }
2680})",
2681 {
2682 {
2683 {
2684 "invalidParams",
2686 "Cannot specify differing 'Amount' and 'DeliverMax'",
2687 },
2688 {
2689 "invalidParams",
2691 "Cannot specify differing 'Amount' and 'DeliverMax'",
2692 },
2693 {
2694 "invalidParams",
2696 "Cannot specify differing 'Amount' and 'DeliverMax'",
2697 },
2698 {
2699 "invalidParams",
2701 "Cannot specify differing 'Amount' and 'DeliverMax'",
2702 },
2703 },
2704 },
2705 },
2706 {
2707 "Payment cannot specify bad DomainID.",
2708 __LINE__,
2709 R"({
2710 "command": "dummy_command",
2711 "account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2712 "secret": "masterpassphrase",
2713 "debug_signing": 0,
2714 "tx_json": {
2715 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2716 "Amount": "1000000000",
2717 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
2718 "Fee": 50,
2719 "Sequence": 0,
2720 "SigningPubKey": "",
2721 "TransactionType": "Payment",
2722 "DomainID": "invalid",
2723 }
2724})",
2725 {
2726 {
2727 {"domainMalformed", RpcDomainMalformed, "Unable to parse 'DomainID'."},
2728 {"domainMalformed", RpcDomainMalformed, "Unable to parse 'DomainID'."},
2729 {"domainMalformed", RpcDomainMalformed, "Unable to parse 'DomainID'."},
2730 {"domainMalformed", RpcDomainMalformed, "Unable to parse 'DomainID'."},
2731 },
2732 },
2733 },
2734
2735 {
2736 "Minimal delegated transaction.",
2737 __LINE__,
2738 R"({
2739 "command": "dummy_command",
2740 "secret": "a",
2741 "tx_json": {
2742 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2743 "Amount": "1000000000",
2744 "Destination": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA",
2745 "TransactionType": "Payment",
2746 "Delegate": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
2747 }
2748})",
2749 {
2750 {
2751 {},
2752 {},
2753 {"invalidParams", RpcInvalidParams, "Missing field 'account'."},
2754 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
2755 },
2756 },
2757 },
2758
2759 {
2760 "Delegate not well formed.",
2761 __LINE__,
2762 R"({
2763 "command": "dummy_command",
2764 "secret": "a",
2765 "tx_json": {
2766 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2767 "Amount": "1000000000",
2768 "Destination": "rJrxi4Wxev4bnAGVNP9YCdKPdAoKfAmcsi",
2769 "TransactionType": "Payment",
2770 "Delegate": "NotAnAccount"
2771 }
2772})",
2773 {
2774 {
2775 {"srcActMalformed", RpcSrcActMalformed, "Invalid field 'tx_json.Delegate'."},
2776 {"srcActMalformed", RpcSrcActMalformed, "Invalid field 'tx_json.Delegate'."},
2777 {"invalidParams", RpcInvalidParams, "Missing field 'account'."},
2778 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
2779 },
2780 },
2781 },
2782
2783 {
2784 "Delegate not in ledger.",
2785 __LINE__,
2786 R"({
2787 "command": "dummy_command",
2788 "secret": "a",
2789 "tx_json": {
2790 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2791 "Amount": "1000000000",
2792 "Destination": "rJrxi4Wxev4bnAGVNP9YCdKPdAoKfAmcsi",
2793 "TransactionType": "Payment",
2794 "Delegate": "rDg53Haik2475DJx8bjMDSDPj4VX7htaMd"
2795 }
2796})",
2797 {
2798 {
2799 {"delegateActNotFound", RpcDelegateActNotFound, "Delegate account not found."},
2800 {"delegateActNotFound", RpcDelegateActNotFound, "Delegate account not found."},
2801 {"invalidParams", RpcInvalidParams, "Missing field 'account'."},
2802 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
2803 },
2804 },
2805 },
2806
2807 {
2808 "Delegate and secret not match.",
2809 __LINE__,
2810 R"({
2811 "command": "dummy_command",
2812 "secret": "aa",
2813 "tx_json": {
2814 "Account": "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
2815 "Amount": "1000000000",
2816 "Destination": "rJrxi4Wxev4bnAGVNP9YCdKPdAoKfAmcsi",
2817 "TransactionType": "Payment",
2818 "Delegate": "rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA"
2819 }
2820})",
2821 {
2822 {
2823 {"badSecret", RpcBadSecret, "Secret does not match account."},
2824 {"badSecret", RpcBadSecret, "Secret does not match account."},
2825 {"invalidParams", RpcInvalidParams, "Missing field 'account'."},
2826 {"invalidParams", RpcInvalidParams, "Missing field 'tx_json.Sequence'."},
2827 },
2828 },
2829 },
2830
2831};
2832
2834{
2835public:
2836 void
2838 {
2839 testcase("bad RPC command");
2840 test::jtx::Env env(*this);
2841 json::Value const result{env.rpc("bad_command", R"({"MakingThisUp": 0})")};
2842
2843 BEAST_EXPECT(result[jss::result][jss::error] == "unknownCmd");
2844 BEAST_EXPECT(result[jss::result][jss::error_code] == RpcUnknownCommand);
2845 BEAST_EXPECT(result[jss::result][jss::error_message] == "Unknown method.");
2846 BEAST_EXPECT(result[jss::result][jss::request][jss::command] == "bad_command");
2847 }
2848
2849 void
2851 {
2852 testcase("autofill fails");
2853 using namespace test::jtx;
2854
2855 // test batch raw transactions max size
2856 {
2857 Env env(*this);
2858 auto const ledger = env.current();
2859 auto const& feeTrack = env.app().getFeeTrack();
2860 json::Value req;
2861 Account const alice("alice");
2862 Account const bob("bob");
2863 env.fund(XRP(100000), alice);
2864 env.close();
2865
2866 auto const batchFee = batch::calcBatchFee(env, 0, 2);
2867 auto const seq = env.seq(alice);
2868 auto jt = env.jtnofill(
2869 batch::outer(alice, env.seq(alice), batchFee, tfAllOrNothing),
2870 batch::Inner(pay(alice, bob, XRP(1)), seq + 1),
2871 batch::Inner(pay(alice, bob, XRP(2)), seq + 2),
2872 batch::Inner(pay(alice, bob, XRP(3)), seq + 3),
2873 batch::Inner(pay(alice, bob, XRP(4)), seq + 4),
2874 batch::Inner(pay(alice, bob, XRP(5)), seq + 5),
2875 batch::Inner(pay(alice, bob, XRP(6)), seq + 6),
2876 batch::Inner(pay(alice, bob, XRP(7)), seq + 7),
2877 batch::Inner(pay(alice, bob, XRP(8)), seq + 8),
2878 batch::Inner(pay(alice, bob, XRP(9)), seq + 9));
2879
2880 jt.jv.removeMember(jss::Fee);
2881 jt.jv.removeMember(jss::TxnSignature);
2882 req[jss::tx_json] = jt.jv;
2883 json::Value const result = checkFee(
2884 req,
2886 true,
2887 env.app().config(),
2888 feeTrack,
2889 env.app().getTxQ(),
2890 env.app());
2891 BEAST_EXPECT(result.size() == 0);
2892 BEAST_EXPECT(
2893 req[jss::tx_json].isMember(jss::Fee) &&
2894 req[jss::tx_json][jss::Fee] == env.current()->fees().base.jsonClipped());
2895 }
2896
2897 // test signers max size
2898 {
2899 Env env(*this);
2900 auto const ledger = env.current();
2901 auto const& feeTrack = env.app().getFeeTrack();
2902 json::Value req;
2903 Account const alice("alice");
2904 Account const bob("bob");
2905 env.fund(XRP(100000), alice, bob);
2906 env.close();
2907
2908 auto const jt = env.jtnofill(
2909 noop(alice),
2910 Msig(
2911 alice,
2912 alice,
2913 alice,
2914 alice,
2915 alice,
2916 alice,
2917 alice,
2918 alice,
2919 alice,
2920 alice,
2921 alice,
2922 alice,
2923 alice,
2924 alice,
2925 alice,
2926 alice,
2927 alice,
2928 alice,
2929 alice,
2930 alice,
2931 alice,
2932 alice,
2933 alice,
2934 alice,
2935 alice,
2936 alice,
2937 alice,
2938 alice,
2939 alice,
2940 alice,
2941 alice,
2942 alice,
2943 alice,
2944 alice,
2945 alice,
2946 alice,
2947 alice,
2948 alice,
2949 alice,
2950 alice));
2951
2952 req[jss::tx_json] = jt.jv;
2953 json::Value const result = checkFee(
2954 req,
2956 true,
2957 env.app().config(),
2958 feeTrack,
2959 env.app().getTxQ(),
2960 env.app());
2961 BEAST_EXPECT(result.size() == 0);
2962 BEAST_EXPECT(
2963 req[jss::tx_json].isMember(jss::Fee) &&
2964 req[jss::tx_json][jss::Fee] == env.current()->fees().base.jsonClipped());
2965 }
2966 }
2967
2968 void
2970 {
2971 testcase("autofill fees");
2972 // Pin the reference fee so the asserted error messages don't depend on
2973 // UNIT_TEST_REFERENCE_FEE.
2975 cfg->fees.referenceFee = 10;
2976 return cfg;
2977 }));
2978 auto const baseFee = static_cast<int>(env.current()->fees().base.drops());
2979 auto const ledger = env.current();
2980 auto const& feeTrack = env.app().getFeeTrack();
2981
2982 {
2983 json::Value req;
2984 json::Reader().parse(R"({ "fee_mult_max" : 1, "tx_json" : { } } )", req);
2985 json::Value const result = checkFee(
2986 req,
2988 true,
2989 env.app().config(),
2990 feeTrack,
2991 env.app().getTxQ(),
2992 env.app());
2993
2994 BEAST_EXPECT(!rpc::containsError(result));
2995 BEAST_EXPECT(
2996 req[jss::tx_json].isMember(jss::Fee) && req[jss::tx_json][jss::Fee] == baseFee);
2997 }
2998
2999 {
3000 json::Value req;
3002 "{ \"fee_mult_max\" : 3, \"fee_div_max\" : 2, "
3003 "\"tx_json\" : { } } ",
3004 req);
3005 json::Value const result = checkFee(
3006 req,
3008 true,
3009 env.app().config(),
3010 feeTrack,
3011 env.app().getTxQ(),
3012 env.app());
3013
3014 BEAST_EXPECT(!rpc::containsError(result));
3015 BEAST_EXPECT(
3016 req[jss::tx_json].isMember(jss::Fee) && req[jss::tx_json][jss::Fee] == baseFee);
3017 }
3018
3019 {
3020 json::Value req;
3021 json::Reader().parse(R"({ "fee_mult_max" : 0, "tx_json" : { } } )", req);
3022 json::Value const result = checkFee(
3023 req,
3025 true,
3026 env.app().config(),
3027 feeTrack,
3028 env.app().getTxQ(),
3029 env.app());
3030
3031 BEAST_EXPECT(result[jss::error] == "highFee");
3032 BEAST_EXPECT(result[jss::error_code] == RpcHighFee);
3033 BEAST_EXPECT(
3034 result[jss::error_message] == "Fee of 10 exceeds the requested tx limit of 0");
3035 BEAST_EXPECT(!req[jss::tx_json].isMember(jss::Fee));
3036 }
3037
3038 {
3039 // 3/6 = 1/2, but use the bigger number make sure
3040 // we're dividing.
3041 json::Value req;
3043 "{ \"fee_mult_max\" : 3, \"fee_div_max\" : 6, "
3044 "\"tx_json\" : { } } ",
3045 req);
3046 json::Value const result = checkFee(
3047 req,
3049 true,
3050 env.app().config(),
3051 feeTrack,
3052 env.app().getTxQ(),
3053 env.app());
3054
3055 BEAST_EXPECT(result[jss::error] == "highFee");
3056 BEAST_EXPECT(result[jss::error_code] == RpcHighFee);
3057 BEAST_EXPECT(
3058 result[jss::error_message] == "Fee of 10 exceeds the requested tx limit of 5");
3059 BEAST_EXPECT(!req[jss::tx_json].isMember(jss::Fee));
3060 }
3061
3062 {
3063 json::Value req;
3065 "{ \"fee_mult_max\" : 0, \"fee_div_max\" : 2, "
3066 "\"tx_json\" : { } } ",
3067 req);
3068 json::Value const result = checkFee(
3069 req,
3071 true,
3072 env.app().config(),
3073 feeTrack,
3074 env.app().getTxQ(),
3075 env.app());
3076
3077 BEAST_EXPECT(result[jss::error] == "highFee");
3078 BEAST_EXPECT(result[jss::error_code] == RpcHighFee);
3079 BEAST_EXPECT(
3080 result[jss::error_message] == "Fee of 10 exceeds the requested tx limit of 0");
3081 BEAST_EXPECT(!req[jss::tx_json].isMember(jss::Fee));
3082 }
3083
3084 {
3085 json::Value req;
3087 "{ \"fee_mult_max\" : 10, \"fee_div_max\" : 0, "
3088 "\"tx_json\" : { } } ",
3089 req);
3090 json::Value const result = checkFee(
3091 req,
3093 true,
3094 env.app().config(),
3095 feeTrack,
3096 env.app().getTxQ(),
3097 env.app());
3098
3099 BEAST_EXPECT(result[jss::error] == "invalidParams");
3100 BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
3101 BEAST_EXPECT(
3102 result[jss::error_message] ==
3103 "Invalid field 'fee_div_max', not a positive integer.");
3104 BEAST_EXPECT(!req[jss::tx_json].isMember(jss::Fee));
3105 }
3106
3107 {
3108 // transaction with a higher base fee
3109 json::Value req;
3110 test::jtx::Account const alice("alice");
3111 req[jss::tx_json] = test::jtx::acctdelete(env.master.human(), alice.human());
3112 json::Value const result = checkFee(
3113 req,
3115 true,
3116 env.app().config(),
3117 feeTrack,
3118 env.app().getTxQ(),
3119 env.app());
3120
3121 BEAST_EXPECT(result.size() == 0);
3122 BEAST_EXPECT(
3123 req[jss::tx_json].isMember(jss::Fee) &&
3124 req[jss::tx_json][jss::Fee] == env.current()->fees().increment.jsonClipped());
3125 }
3126 }
3127
3128 void
3130 {
3131 testcase("autofill escalated fees");
3132 using namespace test::jtx;
3133 Env env{*this, envconfig([](std::unique_ptr<Config> cfg) {
3134 cfg->loadFromString(std::string("[") + Sections::kSigningSupport + "]\ntrue");
3135 cfg->section(Sections::kTransactionQueue)
3137 return cfg;
3138 })};
3139 LoadFeeTrack const& feeTrackOuter = env.app().getFeeTrack();
3140
3141 {
3142 // high mult, no tx
3143 json::Value req;
3145 R"({
3146 "fee_mult_max" : 1000,
3147 "tx_json" : { }
3148 })",
3149 req);
3150 json::Value const result = checkFee(
3151 req,
3153 true,
3154 env.app().config(),
3155 feeTrackOuter,
3156 env.app().getTxQ(),
3157 env.app());
3158
3159 BEAST_EXPECT(!rpc::containsError(result));
3160 BEAST_EXPECT(req[jss::tx_json].isMember(jss::Fee) && req[jss::tx_json][jss::Fee] == 10);
3161 }
3162
3163 {
3164 // low mult, no tx
3165 json::Value req;
3167 R"({
3168 "fee_mult_max" : 5,
3169 "tx_json" : { }
3170 })",
3171 req);
3172 json::Value const result = checkFee(
3173 req,
3175 true,
3176 env.app().config(),
3177 feeTrackOuter,
3178 env.app().getTxQ(),
3179 env.app());
3180
3181 BEAST_EXPECT(!rpc::containsError(result));
3182 BEAST_EXPECT(req[jss::tx_json].isMember(jss::Fee) && req[jss::tx_json][jss::Fee] == 10);
3183 }
3184
3185 // put 4 transactions into the open ledger
3186 for (auto i = 0; i < 4; ++i)
3187 {
3188 env(noop(env.master));
3189 }
3190
3191 {
3192 // high mult, 4 txs
3193 json::Value req;
3195 R"({
3196 "fee_mult_max" : 1000,
3197 "tx_json" : { }
3198 })",
3199 req);
3200 json::Value const result = checkFee(
3201 req,
3203 true,
3204 env.app().config(),
3205 feeTrackOuter,
3206 env.app().getTxQ(),
3207 env.app());
3208
3209 BEAST_EXPECT(!rpc::containsError(result));
3210 BEAST_EXPECT(
3211 req[jss::tx_json].isMember(jss::Fee) && req[jss::tx_json][jss::Fee] == 8889);
3212 }
3213
3214 {
3215 // low mult, 4 tx
3216 json::Value req;
3218 R"({
3219 "fee_mult_max" : 5,
3220 "tx_json" : { }
3221 })",
3222 req);
3223 json::Value const result = checkFee(
3224 req,
3226 true,
3227 env.app().config(),
3228 feeTrackOuter,
3229 env.app().getTxQ(),
3230 env.app());
3231
3232 BEAST_EXPECT(result[jss::error] == "highFee");
3233 BEAST_EXPECT(result[jss::error_code] == RpcHighFee);
3234 BEAST_EXPECT(
3235 result[jss::error_message] == "Fee of 8889 exceeds the requested tx limit of 50");
3236 BEAST_EXPECT(!req[jss::tx_json].isMember(jss::Fee));
3237 }
3238
3239 {
3240 // different low mult, 4 tx
3241 json::Value req;
3243 R"({
3244 "fee_mult_max" : 1000,
3245 "fee_div_max" : 3,
3246 "tx_json" : { }
3247 })",
3248 req);
3249 json::Value const result = checkFee(
3250 req,
3252 true,
3253 env.app().config(),
3254 feeTrackOuter,
3255 env.app().getTxQ(),
3256 env.app());
3257
3258 BEAST_EXPECT(result[jss::error] == "highFee");
3259 BEAST_EXPECT(result[jss::error_code] == RpcHighFee);
3260 BEAST_EXPECT(
3261 result[jss::error_message] == "Fee of 8889 exceeds the requested tx limit of 3333");
3262 BEAST_EXPECT(!req[jss::tx_json].isMember(jss::Fee));
3263 }
3264
3265 {
3266 // high mult, 4 tx
3267 json::Value req;
3269 R"({
3270 "fee_mult_max" : 8000,
3271 "fee_div_max" : 3,
3272 "tx_json" : { }
3273 })",
3274 req);
3275 json::Value const result = checkFee(
3276 req,
3278 true,
3279 env.app().config(),
3280 feeTrackOuter,
3281 env.app().getTxQ(),
3282 env.app());
3283
3284 BEAST_EXPECT(!rpc::containsError(result));
3285 BEAST_EXPECT(
3286 req[jss::tx_json].isMember(jss::Fee) && req[jss::tx_json][jss::Fee] == 8889);
3287 }
3288
3289 {
3290 // negative mult
3291 json::Value req;
3293 R"({
3294 "fee_mult_max" : -5,
3295 "tx_json" : { }
3296 })",
3297 req);
3298 json::Value const result = checkFee(
3299 req,
3301 true,
3302 env.app().config(),
3303 feeTrackOuter,
3304 env.app().getTxQ(),
3305 env.app());
3306
3307 BEAST_EXPECT(result[jss::error] == "invalidParams");
3308 BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
3309 BEAST_EXPECT(
3310 result[jss::error_message] ==
3311 "Invalid field 'fee_mult_max', not a positive integer.");
3312 }
3313
3314 {
3315 // negative div
3316 json::Value req;
3318 R"({
3319 "fee_div_max" : -2,
3320 "tx_json" : { }
3321 })",
3322 req);
3323 json::Value const result = checkFee(
3324 req,
3326 true,
3327 env.app().config(),
3328 feeTrackOuter,
3329 env.app().getTxQ(),
3330 env.app());
3331
3332 BEAST_EXPECT(result[jss::error] == "invalidParams");
3333 BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
3334 BEAST_EXPECT(
3335 result[jss::error_message] ==
3336 "Invalid field 'fee_div_max', not a positive integer.");
3337 }
3338
3339 {
3340 // negative mult & div
3341 json::Value req;
3343 R"({
3344 "fee_mult_max" : -2,
3345 "fee_div_max" : -3,
3346 "tx_json" : { }
3347 })",
3348 req);
3349 json::Value const result = checkFee(
3350 req,
3352 true,
3353 env.app().config(),
3354 feeTrackOuter,
3355 env.app().getTxQ(),
3356 env.app());
3357
3358 BEAST_EXPECT(result[jss::error] == "invalidParams");
3359 BEAST_EXPECT(result[jss::error_code] == RpcInvalidParams);
3360 BEAST_EXPECT(
3361 result[jss::error_message] ==
3362 "Invalid field 'fee_mult_max', not a positive integer.");
3363 }
3364
3365 env.close();
3366
3367 {
3368 // Call "sign" with nothing in the open ledger
3369 json::Value toSign;
3370 toSign[jss::tx_json] = noop(env.master);
3371 toSign[jss::secret] = "masterpassphrase";
3372 auto rpcResult = env.rpc("json", "sign", to_string(toSign));
3373 auto result = rpcResult[jss::result];
3374
3375 BEAST_EXPECT(!rpc::containsError(result));
3376 BEAST_EXPECT(
3377 result[jss::tx_json].isMember(jss::Fee) && result[jss::tx_json][jss::Fee] == "10");
3378 BEAST_EXPECT(
3379 result[jss::tx_json].isMember(jss::Sequence) &&
3380 result[jss::tx_json][jss::Sequence].isConvertibleTo(json::ValueType::UInt));
3381 }
3382
3383 {
3384 // Call "sign" with enough transactions in the open ledger
3385 // to escalate the fee.
3386 for (;;)
3387 {
3388 auto const metrics = env.app().getTxQ().getMetrics(*env.current());
3389 if (metrics.openLedgerFeeLevel > metrics.minProcessingFeeLevel)
3390 break;
3391 env(noop(env.master));
3392 }
3393
3394 json::Value toSign;
3395 toSign[jss::tx_json] = noop(env.master);
3396 toSign[jss::secret] = "masterpassphrase";
3397 toSign[jss::fee_mult_max] = 900;
3398 auto rpcResult = env.rpc("json", "sign", to_string(toSign));
3399 auto result = rpcResult[jss::result];
3400
3401 BEAST_EXPECT(!rpc::containsError(result));
3402 BEAST_EXPECT(
3403 result[jss::tx_json].isMember(jss::Fee) &&
3404 result[jss::tx_json][jss::Fee] == "7813");
3405 BEAST_EXPECT(
3406 result[jss::tx_json].isMember(jss::Sequence) &&
3407 result[jss::tx_json][jss::Sequence].isConvertibleTo(json::ValueType::UInt));
3408
3409 env.close();
3410 }
3411
3412 {
3413 // Call "sign" with higher server load
3414 {
3415 auto& feeTrack = env.app().getFeeTrack();
3416 BEAST_EXPECT(feeTrack.getLoadFactor() == 256);
3417 for (int i = 0; i < 8; ++i)
3418 feeTrack.raiseLocalFee();
3419 BEAST_EXPECT(feeTrack.getLoadFactor() == 1220);
3420 }
3421
3422 json::Value toSign;
3423 toSign[jss::tx_json] = noop(env.master);
3424 toSign[jss::secret] = "masterpassphrase";
3425 auto rpcResult = env.rpc("json", "sign", to_string(toSign));
3426 auto result = rpcResult[jss::result];
3427
3428 BEAST_EXPECT(!rpc::containsError(result));
3429 BEAST_EXPECT(
3430 result[jss::tx_json].isMember(jss::Fee) && result[jss::tx_json][jss::Fee] == "47");
3431 BEAST_EXPECT(
3432 result[jss::tx_json].isMember(jss::Sequence) &&
3433 result[jss::tx_json][jss::Sequence].isConvertibleTo(json::ValueType::UInt));
3434 }
3435
3436 {
3437 // Call "sign" with higher server load and
3438 // enough transactions to escalate the fee
3439 BEAST_EXPECT(feeTrackOuter.getLoadFactor() == 1220);
3441 for (;;)
3442 {
3443 auto const metrics = env.app().getTxQ().getMetrics(*env.current());
3444 if (metrics.openLedgerFeeLevel > metrics.minProcessingFeeLevel)
3445 break;
3446 env(noop(env.master), Fee(47));
3447 }
3448
3449 EnvSs const envs(env);
3450
3451 json::Value toSign;
3452 toSign[jss::tx_json] = noop(env.master);
3453 toSign[jss::secret] = "masterpassphrase";
3454 // Max fee = 7000 drops
3455 toSign[jss::fee_mult_max] = 700;
3456 auto rpcResult = env.rpc("json", "sign", to_string(toSign));
3457 auto result = rpcResult[jss::result];
3458
3459 BEAST_EXPECT(!rpc::containsError(result));
3460 BEAST_EXPECT(
3461 result[jss::tx_json].isMember(jss::Fee) &&
3462 result[jss::tx_json][jss::Fee] == "6806");
3463 BEAST_EXPECT(
3464 result[jss::tx_json].isMember(jss::Sequence) &&
3465 result[jss::tx_json][jss::Sequence].isConvertibleTo(json::ValueType::UInt));
3466 }
3468
3469 void
3471 {
3472 testcase("autofill NetworkID");
3473 using namespace test::jtx;
3474 Env env{*this, envconfig([&](std::unique_ptr<Config> cfg) {
3475 cfg->networkId = 1025;
3476 return cfg;
3477 })};
3478
3479 {
3480 json::Value toSign;
3481 toSign[jss::tx_json] = noop(env.master);
3482
3483 BEAST_EXPECT(!toSign[jss::tx_json].isMember(jss::NetworkID));
3484 toSign[jss::secret] = "masterpassphrase";
3485 auto rpcResult = env.rpc("json", "sign", to_string(toSign));
3486 auto result = rpcResult[jss::result];
3487
3488 BEAST_EXPECT(!rpc::containsError(result));
3489 BEAST_EXPECT(
3490 result[jss::tx_json].isMember(jss::NetworkID) &&
3491 result[jss::tx_json][jss::NetworkID] == 1025);
3492 }
3493 }
3494
3495 // A function that can be called as though it would process a transaction.
3496 static void
3498 {
3499 ;
3500 }
3501
3502 void
3504 {
3505 testcase("sign/submit RPCs");
3506 using namespace std::chrono_literals;
3507 using namespace test::jtx;
3508 // Use jtx to set up a ledger so the tests will do the right thing.
3509 Account const a{"a"}; // rnUy2SHTrB9DubsPmkJZUXTf5FcNDGrYEA
3510 Account const g{"g"}; // rLPwWB1itaUGMV8kbMLLysjGkEpTM2Soy4
3511 auto const usd = g["USD"];
3512
3513 // Account: rJrxi4Wxev4bnAGVNP9YCdKPdAoKfAmcsi
3514 // seed: sh1yJfwoi98zCygwijUzuHmJDeVKd
3515 Account const ed{"ed", KeyType::Ed25519};
3516 // master is rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh.
3517 // "b" (not in the ledger) is rDg53Haik2475DJx8bjMDSDPj4VX7htaMd.
3518 // "c" (phantom signer) is rPcNzota6B8YBokhYtcTNqQVCngtbnWfux.
3519
3520 Env env(*this, envconfig([](std::unique_ptr<Config> cfg) {
3521 cfg->fees.referenceFee = 10;
3522 return cfg;
3523 }));
3524 env.fund(XRP(100000), a, ed, g);
3525 env.close();
3526
3527 env(trust(a, usd(1000)));
3528 env(trust(env.master, usd(1000)));
3529 env(pay(g, a, usd(50)));
3530 env(pay(g, env.master, usd(50)));
3531 env.close();
3532
3534
3535 // A list of all the functions we want to test.
3536 using SignFunc = json::Value (*)(
3537 json::Value params,
3538 unsigned int apiVersion,
3539 NetworkOPs::FailHard failType,
3540 Role role,
3541 std::chrono::seconds validatedLedgerAge,
3542 Application& app);
3543
3544 using SubmitFunc = json::Value (*)(
3545 json::Value params,
3546 unsigned int apiVersion,
3547 NetworkOPs::FailHard failType,
3548 Role role,
3549 std::chrono::seconds validatedLedgerAge,
3550 Application& app,
3551 ProcessTransactionFn const& processTransaction);
3552
3553 using TestStuff = std::tuple<SignFunc, SubmitFunc, char const*, unsigned int>;
3554
3555 static TestStuff const kTestFuncs[] = {
3556 TestStuff{transactionSign, nullptr, "sign", 0},
3557 TestStuff{nullptr, transactionSubmit, "submit", 1},
3558 TestStuff{transactionSignFor, nullptr, "sign_for", 2},
3559 TestStuff{nullptr, transactionSubmitMultiSigned, "submit_multisigned", 3},
3560 };
3561
3562 for (auto testFunc : kTestFuncs)
3563 {
3564 // For each JSON test.
3565 for (auto const& txnTest : kTxnTestArray)
3566 {
3567 json::Value req;
3568 json::Reader().parse(txnTest.json, req);
3569 if (rpc::containsError(req))
3570 Throw<std::runtime_error>("Internal JSONRPC_test error. Bad test JSON.");
3571
3572 static Role const kTestedRoles[] = {
3574 Role::USER,
3577 };
3578
3579 for (Role const testRole : kTestedRoles)
3580 {
3581 json::Value result;
3582 auto const signFn = get<0>(testFunc);
3583 if (signFn != nullptr)
3584 {
3585 assert(get<1>(testFunc) == nullptr);
3586 result = signFn(req, 1, NetworkOPs::FailHard::Yes, testRole, 1s, env.app());
3587 }
3588 else
3589 {
3590 auto const submitFn = get<1>(testFunc);
3591 assert(submitFn != nullptr);
3592 result = submitFn(
3593 req, 1, NetworkOPs::FailHard::Yes, testRole, 1s, env.app(), processTxn);
3594 }
3595
3596 std::string errToken;
3597 int errCode = RpcSuccess;
3598 std::string errStr;
3599 if (rpc::containsError(result))
3600 {
3601 errToken = result[jss::error].asString();
3602 errCode = result[jss::error_code].asInt();
3603 errStr = result["error_message"].asString();
3604 }
3605
3606 auto const& expected = txnTest.expected[get<3>(testFunc)];
3607 if (errToken == expected.token && errCode == expected.code &&
3608 errStr == expected.message)
3609 {
3610 pass();
3611 }
3612 else
3613 {
3614 std::ostringstream description;
3615 description << txnTest.description << " Called " << get<2>(testFunc)
3616 << "(). Got \'" << errToken << "\' (" << errCode << ") \'"
3617 << errStr << "\'";
3618 fail(description.str(), __FILE__, txnTest.line);
3619 }
3620 }
3621 }
3622 }
3623 }
3624
3625 void
3626 run() override
3627 {
3634 }
3635};
3636
3638
3639} // namespace xrpl::rpc
A testsuite class.
Definition suite.h:52
void pass()
Record a successful test condition.
Definition suite.h:532
void fail(String const &reason, char const *file, int line)
Record a failure.
Definition suite.h:554
TestcaseT testcase
Memberspace for declaring test cases.
Definition suite.h:155
Unserialize a JSON document into a Value.
Definition json_reader.h:20
bool parse(std::string const &document, Value &root)
Read a Value from a JSON document.
Represents a JSON value.
Definition json_value.h:121
UInt size() const
Number of values in array or object.
std::string asString() const
Returns the unquoted string value.
Int asInt() const
Manages the current fee schedule.
std::uint32_t getLoadFactor() const
void run() override
Runs the suite.
static void fakeProcessTransaction(std::shared_ptr< Transaction > &, bool, bool, NetworkOPs::FailHard)
Immutable cryptographic account descriptor.
Definition jtx/Account.h:21
std::string const & human() const
Returns the human readable public key.
A transaction testing environment.
Definition Env.h:161
json::Value rpc(unsigned apiVersion, std::unordered_map< std::string, std::string > const &headers, std::string const &cmd, Args &&... args)
Execute an RPC command.
Definition Env.h:1058
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
Definition Env.h:377
JSON (JavaScript Object Notation).
Definition json_errors.h:5
@ UInt
unsigned integer value
Definition json_value.h:28
The api_version numbers this server serves.
Definition ApiVersion.h:26
bool containsError(json::Value const &json)
Returns true if the json contains an rpc error specification.
json::Value transactionSubmit(json::Value jvRequest, unsigned apiVersion, NetworkOPs::FailHard failType, Role role, std::chrono::seconds validatedLedgerAge, Application &app, ProcessTransactionFn const &processTransaction)
Returns a json::ValueType::Object.
std::function< void( std::shared_ptr< Transaction > &transaction, bool bUnlimited, bool bLocal, NetworkOPs::FailHard failType)> ProcessTransactionFn
json::Value transactionSignFor(json::Value jvRequest, unsigned apiVersion, NetworkOPs::FailHard failType, Role role, std::chrono::seconds validatedLedgerAge, Application &app)
Returns a json::ValueType::Object.
BEAST_DEFINE_TESTSUITE(AccountLines, rpc, xrpl)
json::Value transactionSubmitMultiSigned(json::Value jvRequest, unsigned apiVersion, NetworkOPs::FailHard failType, Role role, std::chrono::seconds validatedLedgerAge, Application &app, ProcessTransactionFn const &processTransaction)
Returns a json::ValueType::Object.
static constexpr TxnTestData kTxnTestArray[]
json::Value transactionSign(json::Value jvRequest, unsigned apiVersion, NetworkOPs::FailHard failType, Role role, std::chrono::seconds validatedLedgerAge, Application &app)
Returns a json::ValueType::Object.
json::Value checkFee(json::Value &request, Role const role, bool doAutoFill, Config const &config, LoadFeeTrack const &feeTrack, TxQ const &txQ, Application const &app)
Fill in the fee on behalf of the client.
json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
Definition pay.cpp:14
XrpT const XRP
Converts to XRP Issue or STAmount.
Definition amount.cpp:92
json::Value acctdelete(Account const &account, Account const &dest)
Delete account.
std::unique_ptr< Config > envconfig()
creates and initializes a default configuration for jtx::Env
Definition envconfig.h:38
json::Value trust(Account const &account, STAmount const &amount, std::uint32_t flags)
Modify a trust line.
Definition trust.cpp:18
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
ErrorCodeI
Definition ErrorCodes.h:23
@ RpcBadSecret
Definition ErrorCodes.h:81
@ RpcInternal
Definition ErrorCodes.h:113
@ RpcDelegateActNotFound
Definition ErrorCodes.h:106
@ RpcSrcActMalformed
Definition ErrorCodes.h:103
@ RpcAlreadySingleSig
Definition ErrorCodes.h:75
@ RpcSigningMalformed
Definition ErrorCodes.h:101
@ RpcSuccess
Definition ErrorCodes.h:27
@ RpcHighFee
Definition ErrorCodes.h:41
@ RpcDomainMalformed
Definition ErrorCodes.h:141
@ RpcSrcActMissing
Definition ErrorCodes.h:104
@ RpcInvalidParams
Definition ErrorCodes.h:67
@ RpcBadSeed
Definition ErrorCodes.h:82
@ RpcUnknownCommand
Definition ErrorCodes.h:68
@ RpcAlreadyMultisig
Definition ErrorCodes.h:74
@ RpcSrcActNotFound
Definition ErrorCodes.h:105
T get(Section const &section, std::string const &name, T const &defaultValue=T{})
Retrieve a key/value pair from a section.
std::string to_string(BaseUInt< Bits, Tag > const &a)
Definition base_uint.h:658
Role
Indicates the level of administrative permission to grant.
Definition Role.h:27
@ USER
Definition Role.h:27
@ GUEST
Definition Role.h:27
@ ADMIN
Definition Role.h:27
@ FORBID
Definition Role.h:27
XRPL_NO_SANITIZE_ADDRESS void Throw(Args &&... args)
Definition contract.h:52
T str(T... args)
static constexpr auto kMinimumTxnInLedgerStandalone
Definition Constants.h:137
static constexpr auto kSigningSupport
Definition Constants.h:58
static constexpr auto kTransactionQueue
Definition Constants.h:66
constexpr ExpectedResult(char const *token, ErrorCodeI code, char const *message)
constexpr ExpectedResult()=default
char const *const description
TxnTestData & operator=(TxnTestData &&)=delete
TxnTestData(TxnTestData const &)=delete
TxnTestData & operator=(TxnTestData const &)=delete
std::array< ExpectedResult, 4 > const expected
constexpr TxnTestData(char const *description, int line, char const *json, std::array< ExpectedResult, 4 > const &expected)
TxnTestData(TxnTestData &&)=delete