xrpl-ruby 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +82 -0
- data/README.md +57 -3
- data/lib/binary-codec/binary_codec.rb +22 -1
- data/lib/binary-codec/enums/definitions.json +84 -288
- data/lib/binary-codec/enums/definitions.rb +38 -1
- data/lib/binary-codec/types/uint.rb +32 -39
- data/lib/wallet/wallet.rb +32 -0
- data/lib/xrpl/client.rb +30 -6
- data/lib/xrpl/fee.rb +82 -0
- data/lib/xrpl/ledger_entry.rb +53 -0
- data/lib/xrpl/model.rb +239 -0
- data/lib/xrpl/transaction.rb +14 -163
- data/lib/xrpl/version.rb +1 -1
- data/lib/xrpl-ruby.rb +3 -0
- metadata +5 -2
|
@@ -148,46 +148,6 @@
|
|
|
148
148
|
"type": "UInt16"
|
|
149
149
|
}
|
|
150
150
|
],
|
|
151
|
-
[
|
|
152
|
-
"HookStateChangeCount",
|
|
153
|
-
{
|
|
154
|
-
"isSerialized": true,
|
|
155
|
-
"isSigningField": true,
|
|
156
|
-
"isVLEncoded": false,
|
|
157
|
-
"nth": 17,
|
|
158
|
-
"type": "UInt16"
|
|
159
|
-
}
|
|
160
|
-
],
|
|
161
|
-
[
|
|
162
|
-
"HookEmitCount",
|
|
163
|
-
{
|
|
164
|
-
"isSerialized": true,
|
|
165
|
-
"isSigningField": true,
|
|
166
|
-
"isVLEncoded": false,
|
|
167
|
-
"nth": 18,
|
|
168
|
-
"type": "UInt16"
|
|
169
|
-
}
|
|
170
|
-
],
|
|
171
|
-
[
|
|
172
|
-
"HookExecutionIndex",
|
|
173
|
-
{
|
|
174
|
-
"isSerialized": true,
|
|
175
|
-
"isSigningField": true,
|
|
176
|
-
"isVLEncoded": false,
|
|
177
|
-
"nth": 19,
|
|
178
|
-
"type": "UInt16"
|
|
179
|
-
}
|
|
180
|
-
],
|
|
181
|
-
[
|
|
182
|
-
"HookApiVersion",
|
|
183
|
-
{
|
|
184
|
-
"isSerialized": true,
|
|
185
|
-
"isSigningField": true,
|
|
186
|
-
"isVLEncoded": false,
|
|
187
|
-
"nth": 20,
|
|
188
|
-
"type": "UInt16"
|
|
189
|
-
}
|
|
190
|
-
],
|
|
191
151
|
[
|
|
192
152
|
"LedgerFixType",
|
|
193
153
|
{
|
|
@@ -648,26 +608,6 @@
|
|
|
648
608
|
"type": "UInt32"
|
|
649
609
|
}
|
|
650
610
|
],
|
|
651
|
-
[
|
|
652
|
-
"HookStateCount",
|
|
653
|
-
{
|
|
654
|
-
"isSerialized": true,
|
|
655
|
-
"isSigningField": true,
|
|
656
|
-
"isVLEncoded": false,
|
|
657
|
-
"nth": 45,
|
|
658
|
-
"type": "UInt32"
|
|
659
|
-
}
|
|
660
|
-
],
|
|
661
|
-
[
|
|
662
|
-
"EmitGeneration",
|
|
663
|
-
{
|
|
664
|
-
"isSerialized": true,
|
|
665
|
-
"isSigningField": true,
|
|
666
|
-
"isVLEncoded": false,
|
|
667
|
-
"nth": 46,
|
|
668
|
-
"type": "UInt32"
|
|
669
|
-
}
|
|
670
|
-
],
|
|
671
611
|
[
|
|
672
612
|
"VoteWeight",
|
|
673
613
|
{
|
|
@@ -928,6 +868,26 @@
|
|
|
928
868
|
"type": "UInt32"
|
|
929
869
|
}
|
|
930
870
|
],
|
|
871
|
+
[
|
|
872
|
+
"SubscriptionDate",
|
|
873
|
+
{
|
|
874
|
+
"isSerialized": true,
|
|
875
|
+
"isSigningField": true,
|
|
876
|
+
"isVLEncoded": false,
|
|
877
|
+
"nth": 75,
|
|
878
|
+
"type": "UInt32"
|
|
879
|
+
}
|
|
880
|
+
],
|
|
881
|
+
[
|
|
882
|
+
"RedemptionDate",
|
|
883
|
+
{
|
|
884
|
+
"isSerialized": true,
|
|
885
|
+
"isSigningField": true,
|
|
886
|
+
"isVLEncoded": false,
|
|
887
|
+
"nth": 76,
|
|
888
|
+
"type": "UInt32"
|
|
889
|
+
}
|
|
890
|
+
],
|
|
931
891
|
[
|
|
932
892
|
"IndexNext",
|
|
933
893
|
{
|
|
@@ -1058,36 +1018,6 @@
|
|
|
1058
1018
|
"type": "UInt64"
|
|
1059
1019
|
}
|
|
1060
1020
|
],
|
|
1061
|
-
[
|
|
1062
|
-
"HookOn",
|
|
1063
|
-
{
|
|
1064
|
-
"isSerialized": true,
|
|
1065
|
-
"isSigningField": true,
|
|
1066
|
-
"isVLEncoded": false,
|
|
1067
|
-
"nth": 16,
|
|
1068
|
-
"type": "UInt64"
|
|
1069
|
-
}
|
|
1070
|
-
],
|
|
1071
|
-
[
|
|
1072
|
-
"HookInstructionCount",
|
|
1073
|
-
{
|
|
1074
|
-
"isSerialized": true,
|
|
1075
|
-
"isSigningField": true,
|
|
1076
|
-
"isVLEncoded": false,
|
|
1077
|
-
"nth": 17,
|
|
1078
|
-
"type": "UInt64"
|
|
1079
|
-
}
|
|
1080
|
-
],
|
|
1081
|
-
[
|
|
1082
|
-
"HookReturnCode",
|
|
1083
|
-
{
|
|
1084
|
-
"isSerialized": true,
|
|
1085
|
-
"isSigningField": true,
|
|
1086
|
-
"isVLEncoded": false,
|
|
1087
|
-
"nth": 18,
|
|
1088
|
-
"type": "UInt64"
|
|
1089
|
-
}
|
|
1090
|
-
],
|
|
1091
1021
|
[
|
|
1092
1022
|
"ReferenceCount",
|
|
1093
1023
|
{
|
|
@@ -1518,46 +1448,6 @@
|
|
|
1518
1448
|
"type": "Hash256"
|
|
1519
1449
|
}
|
|
1520
1450
|
],
|
|
1521
|
-
[
|
|
1522
|
-
"HookStateKey",
|
|
1523
|
-
{
|
|
1524
|
-
"isSerialized": true,
|
|
1525
|
-
"isSigningField": true,
|
|
1526
|
-
"isVLEncoded": false,
|
|
1527
|
-
"nth": 30,
|
|
1528
|
-
"type": "Hash256"
|
|
1529
|
-
}
|
|
1530
|
-
],
|
|
1531
|
-
[
|
|
1532
|
-
"HookHash",
|
|
1533
|
-
{
|
|
1534
|
-
"isSerialized": true,
|
|
1535
|
-
"isSigningField": true,
|
|
1536
|
-
"isVLEncoded": false,
|
|
1537
|
-
"nth": 31,
|
|
1538
|
-
"type": "Hash256"
|
|
1539
|
-
}
|
|
1540
|
-
],
|
|
1541
|
-
[
|
|
1542
|
-
"HookNamespace",
|
|
1543
|
-
{
|
|
1544
|
-
"isSerialized": true,
|
|
1545
|
-
"isSigningField": true,
|
|
1546
|
-
"isVLEncoded": false,
|
|
1547
|
-
"nth": 32,
|
|
1548
|
-
"type": "Hash256"
|
|
1549
|
-
}
|
|
1550
|
-
],
|
|
1551
|
-
[
|
|
1552
|
-
"HookSetTxnID",
|
|
1553
|
-
{
|
|
1554
|
-
"isSerialized": true,
|
|
1555
|
-
"isSigningField": true,
|
|
1556
|
-
"isVLEncoded": false,
|
|
1557
|
-
"nth": 33,
|
|
1558
|
-
"type": "Hash256"
|
|
1559
|
-
}
|
|
1560
|
-
],
|
|
1561
1451
|
[
|
|
1562
1452
|
"DomainID",
|
|
1563
1453
|
{
|
|
@@ -2158,46 +2048,6 @@
|
|
|
2158
2048
|
"type": "Blob"
|
|
2159
2049
|
}
|
|
2160
2050
|
],
|
|
2161
|
-
[
|
|
2162
|
-
"HookStateData",
|
|
2163
|
-
{
|
|
2164
|
-
"isSerialized": true,
|
|
2165
|
-
"isSigningField": true,
|
|
2166
|
-
"isVLEncoded": true,
|
|
2167
|
-
"nth": 22,
|
|
2168
|
-
"type": "Blob"
|
|
2169
|
-
}
|
|
2170
|
-
],
|
|
2171
|
-
[
|
|
2172
|
-
"HookReturnString",
|
|
2173
|
-
{
|
|
2174
|
-
"isSerialized": true,
|
|
2175
|
-
"isSigningField": true,
|
|
2176
|
-
"isVLEncoded": true,
|
|
2177
|
-
"nth": 23,
|
|
2178
|
-
"type": "Blob"
|
|
2179
|
-
}
|
|
2180
|
-
],
|
|
2181
|
-
[
|
|
2182
|
-
"HookParameterName",
|
|
2183
|
-
{
|
|
2184
|
-
"isSerialized": true,
|
|
2185
|
-
"isSigningField": true,
|
|
2186
|
-
"isVLEncoded": true,
|
|
2187
|
-
"nth": 24,
|
|
2188
|
-
"type": "Blob"
|
|
2189
|
-
}
|
|
2190
|
-
],
|
|
2191
|
-
[
|
|
2192
|
-
"HookParameterValue",
|
|
2193
|
-
{
|
|
2194
|
-
"isSerialized": true,
|
|
2195
|
-
"isSigningField": true,
|
|
2196
|
-
"isVLEncoded": true,
|
|
2197
|
-
"nth": 25,
|
|
2198
|
-
"type": "Blob"
|
|
2199
|
-
}
|
|
2200
|
-
],
|
|
2201
2051
|
[
|
|
2202
2052
|
"DIDDocument",
|
|
2203
2053
|
{
|
|
@@ -2518,16 +2368,6 @@
|
|
|
2518
2368
|
"type": "AccountID"
|
|
2519
2369
|
}
|
|
2520
2370
|
],
|
|
2521
|
-
[
|
|
2522
|
-
"HookAccount",
|
|
2523
|
-
{
|
|
2524
|
-
"isSerialized": true,
|
|
2525
|
-
"isSigningField": true,
|
|
2526
|
-
"isVLEncoded": true,
|
|
2527
|
-
"nth": 16,
|
|
2528
|
-
"type": "AccountID"
|
|
2529
|
-
}
|
|
2530
|
-
],
|
|
2531
2371
|
[
|
|
2532
2372
|
"OtherChainSource",
|
|
2533
2373
|
{
|
|
@@ -2978,16 +2818,6 @@
|
|
|
2978
2818
|
"type": "STObject"
|
|
2979
2819
|
}
|
|
2980
2820
|
],
|
|
2981
|
-
[
|
|
2982
|
-
"Hook",
|
|
2983
|
-
{
|
|
2984
|
-
"isSerialized": true,
|
|
2985
|
-
"isSigningField": true,
|
|
2986
|
-
"isVLEncoded": false,
|
|
2987
|
-
"nth": 14,
|
|
2988
|
-
"type": "STObject"
|
|
2989
|
-
}
|
|
2990
|
-
],
|
|
2991
2821
|
[
|
|
2992
2822
|
"Permission",
|
|
2993
2823
|
{
|
|
@@ -3028,56 +2858,6 @@
|
|
|
3028
2858
|
"type": "STObject"
|
|
3029
2859
|
}
|
|
3030
2860
|
],
|
|
3031
|
-
[
|
|
3032
|
-
"EmittedTxn",
|
|
3033
|
-
{
|
|
3034
|
-
"isSerialized": true,
|
|
3035
|
-
"isSigningField": true,
|
|
3036
|
-
"isVLEncoded": false,
|
|
3037
|
-
"nth": 20,
|
|
3038
|
-
"type": "STObject"
|
|
3039
|
-
}
|
|
3040
|
-
],
|
|
3041
|
-
[
|
|
3042
|
-
"HookExecution",
|
|
3043
|
-
{
|
|
3044
|
-
"isSerialized": true,
|
|
3045
|
-
"isSigningField": true,
|
|
3046
|
-
"isVLEncoded": false,
|
|
3047
|
-
"nth": 21,
|
|
3048
|
-
"type": "STObject"
|
|
3049
|
-
}
|
|
3050
|
-
],
|
|
3051
|
-
[
|
|
3052
|
-
"HookDefinition",
|
|
3053
|
-
{
|
|
3054
|
-
"isSerialized": true,
|
|
3055
|
-
"isSigningField": true,
|
|
3056
|
-
"isVLEncoded": false,
|
|
3057
|
-
"nth": 22,
|
|
3058
|
-
"type": "STObject"
|
|
3059
|
-
}
|
|
3060
|
-
],
|
|
3061
|
-
[
|
|
3062
|
-
"HookParameter",
|
|
3063
|
-
{
|
|
3064
|
-
"isSerialized": true,
|
|
3065
|
-
"isSigningField": true,
|
|
3066
|
-
"isVLEncoded": false,
|
|
3067
|
-
"nth": 23,
|
|
3068
|
-
"type": "STObject"
|
|
3069
|
-
}
|
|
3070
|
-
],
|
|
3071
|
-
[
|
|
3072
|
-
"HookGrant",
|
|
3073
|
-
{
|
|
3074
|
-
"isSerialized": true,
|
|
3075
|
-
"isSigningField": true,
|
|
3076
|
-
"isVLEncoded": false,
|
|
3077
|
-
"nth": 24,
|
|
3078
|
-
"type": "STObject"
|
|
3079
|
-
}
|
|
3080
|
-
],
|
|
3081
2861
|
[
|
|
3082
2862
|
"VoteEntry",
|
|
3083
2863
|
{
|
|
@@ -3298,16 +3078,6 @@
|
|
|
3298
3078
|
"type": "STArray"
|
|
3299
3079
|
}
|
|
3300
3080
|
],
|
|
3301
|
-
[
|
|
3302
|
-
"Hooks",
|
|
3303
|
-
{
|
|
3304
|
-
"isSerialized": true,
|
|
3305
|
-
"isSigningField": true,
|
|
3306
|
-
"isVLEncoded": false,
|
|
3307
|
-
"nth": 11,
|
|
3308
|
-
"type": "STArray"
|
|
3309
|
-
}
|
|
3310
|
-
],
|
|
3311
3081
|
[
|
|
3312
3082
|
"VoteSlots",
|
|
3313
3083
|
{
|
|
@@ -3348,36 +3118,6 @@
|
|
|
3348
3118
|
"type": "STArray"
|
|
3349
3119
|
}
|
|
3350
3120
|
],
|
|
3351
|
-
[
|
|
3352
|
-
"HookExecutions",
|
|
3353
|
-
{
|
|
3354
|
-
"isSerialized": true,
|
|
3355
|
-
"isSigningField": true,
|
|
3356
|
-
"isVLEncoded": false,
|
|
3357
|
-
"nth": 18,
|
|
3358
|
-
"type": "STArray"
|
|
3359
|
-
}
|
|
3360
|
-
],
|
|
3361
|
-
[
|
|
3362
|
-
"HookParameters",
|
|
3363
|
-
{
|
|
3364
|
-
"isSerialized": true,
|
|
3365
|
-
"isSigningField": true,
|
|
3366
|
-
"isVLEncoded": false,
|
|
3367
|
-
"nth": 19,
|
|
3368
|
-
"type": "STArray"
|
|
3369
|
-
}
|
|
3370
|
-
],
|
|
3371
|
-
[
|
|
3372
|
-
"HookGrants",
|
|
3373
|
-
{
|
|
3374
|
-
"isSerialized": true,
|
|
3375
|
-
"isSigningField": true,
|
|
3376
|
-
"isVLEncoded": false,
|
|
3377
|
-
"nth": 20,
|
|
3378
|
-
"type": "STArray"
|
|
3379
|
-
}
|
|
3380
|
-
],
|
|
3381
3121
|
[
|
|
3382
3122
|
"XChainClaimAttestations",
|
|
3383
3123
|
{
|
|
@@ -3529,32 +3269,32 @@
|
|
|
3529
3269
|
}
|
|
3530
3270
|
],
|
|
3531
3271
|
[
|
|
3532
|
-
"
|
|
3272
|
+
"LEVersion",
|
|
3533
3273
|
{
|
|
3534
3274
|
"isSerialized": true,
|
|
3535
3275
|
"isSigningField": true,
|
|
3536
3276
|
"isVLEncoded": false,
|
|
3537
|
-
"nth":
|
|
3277
|
+
"nth": 6,
|
|
3538
3278
|
"type": "UInt8"
|
|
3539
3279
|
}
|
|
3540
3280
|
],
|
|
3541
3281
|
[
|
|
3542
|
-
"
|
|
3282
|
+
"TickSize",
|
|
3543
3283
|
{
|
|
3544
3284
|
"isSerialized": true,
|
|
3545
3285
|
"isSigningField": true,
|
|
3546
3286
|
"isVLEncoded": false,
|
|
3547
|
-
"nth":
|
|
3287
|
+
"nth": 16,
|
|
3548
3288
|
"type": "UInt8"
|
|
3549
3289
|
}
|
|
3550
3290
|
],
|
|
3551
3291
|
[
|
|
3552
|
-
"
|
|
3292
|
+
"UNLModifyDisabling",
|
|
3553
3293
|
{
|
|
3554
3294
|
"isSerialized": true,
|
|
3555
3295
|
"isSigningField": true,
|
|
3556
3296
|
"isVLEncoded": false,
|
|
3557
|
-
"nth":
|
|
3297
|
+
"nth": 17,
|
|
3558
3298
|
"type": "UInt8"
|
|
3559
3299
|
}
|
|
3560
3300
|
],
|
|
@@ -3578,6 +3318,26 @@
|
|
|
3578
3318
|
"type": "UInt8"
|
|
3579
3319
|
}
|
|
3580
3320
|
],
|
|
3321
|
+
[
|
|
3322
|
+
"ContractResult",
|
|
3323
|
+
{
|
|
3324
|
+
"isSerialized": true,
|
|
3325
|
+
"isSigningField": true,
|
|
3326
|
+
"isVLEncoded": false,
|
|
3327
|
+
"nth": 21,
|
|
3328
|
+
"type": "UInt8"
|
|
3329
|
+
}
|
|
3330
|
+
],
|
|
3331
|
+
[
|
|
3332
|
+
"VaultKind",
|
|
3333
|
+
{
|
|
3334
|
+
"isSerialized": true,
|
|
3335
|
+
"isSigningField": true,
|
|
3336
|
+
"isVLEncoded": false,
|
|
3337
|
+
"nth": 22,
|
|
3338
|
+
"type": "UInt8"
|
|
3339
|
+
}
|
|
3340
|
+
],
|
|
3581
3341
|
[
|
|
3582
3342
|
"TakerPaysCurrency",
|
|
3583
3343
|
{
|
|
@@ -5239,6 +4999,22 @@
|
|
|
5239
4999
|
{
|
|
5240
5000
|
"name": "Scale",
|
|
5241
5001
|
"optionality": 2
|
|
5002
|
+
},
|
|
5003
|
+
{
|
|
5004
|
+
"name": "LEVersion",
|
|
5005
|
+
"optionality": 2
|
|
5006
|
+
},
|
|
5007
|
+
{
|
|
5008
|
+
"name": "VaultKind",
|
|
5009
|
+
"optionality": 2
|
|
5010
|
+
},
|
|
5011
|
+
{
|
|
5012
|
+
"name": "SubscriptionDate",
|
|
5013
|
+
"optionality": 1
|
|
5014
|
+
},
|
|
5015
|
+
{
|
|
5016
|
+
"name": "RedemptionDate",
|
|
5017
|
+
"optionality": 1
|
|
5242
5018
|
}
|
|
5243
5019
|
],
|
|
5244
5020
|
"XChainOwnedClaimID": [
|
|
@@ -6090,6 +5866,10 @@
|
|
|
6090
5866
|
{
|
|
6091
5867
|
"name": "DestinationTag",
|
|
6092
5868
|
"optionality": 1
|
|
5869
|
+
},
|
|
5870
|
+
{
|
|
5871
|
+
"name": "CredentialIDs",
|
|
5872
|
+
"optionality": 1
|
|
6093
5873
|
}
|
|
6094
5874
|
],
|
|
6095
5875
|
"LoanBrokerDelete": [
|
|
@@ -6730,6 +6510,18 @@
|
|
|
6730
6510
|
{
|
|
6731
6511
|
"name": "Scale",
|
|
6732
6512
|
"optionality": 1
|
|
6513
|
+
},
|
|
6514
|
+
{
|
|
6515
|
+
"name": "VaultKind",
|
|
6516
|
+
"optionality": 1
|
|
6517
|
+
},
|
|
6518
|
+
{
|
|
6519
|
+
"name": "SubscriptionDate",
|
|
6520
|
+
"optionality": 1
|
|
6521
|
+
},
|
|
6522
|
+
{
|
|
6523
|
+
"name": "RedemptionDate",
|
|
6524
|
+
"optionality": 1
|
|
6733
6525
|
}
|
|
6734
6526
|
],
|
|
6735
6527
|
"VaultDelete": [
|
|
@@ -6786,6 +6578,10 @@
|
|
|
6786
6578
|
{
|
|
6787
6579
|
"name": "DestinationTag",
|
|
6788
6580
|
"optionality": 1
|
|
6581
|
+
},
|
|
6582
|
+
{
|
|
6583
|
+
"name": "CredentialIDs",
|
|
6584
|
+
"optionality": 1
|
|
6789
6585
|
}
|
|
6790
6586
|
],
|
|
6791
6587
|
"XChainAccountCreateCommit": [
|
|
@@ -7374,5 +7170,5 @@
|
|
|
7374
7170
|
"Vector256": 19,
|
|
7375
7171
|
"XChainBridge": 25
|
|
7376
7172
|
},
|
|
7377
|
-
"hash": "
|
|
7378
|
-
}
|
|
7173
|
+
"hash": "1EA05B0FC11101F7C500BD0DAC794A8BC746A7FBA6250B75489603EB820E0FF5"
|
|
7174
|
+
}
|
|
@@ -8,6 +8,26 @@ module BinaryCodec
|
|
|
8
8
|
|
|
9
9
|
@@instance = nil
|
|
10
10
|
|
|
11
|
+
# The permissions a DelegateSet can grant that are narrower than a whole
|
|
12
|
+
# transaction type. rippled numbers them from 65537 upwards, above the
|
|
13
|
+
# range the transaction types occupy. The table is not part of
|
|
14
|
+
# definitions.json - xrpl.js carries it in code as well
|
|
15
|
+
# (XrplDefinitionsBase#granularPermissions) - so it lives here.
|
|
16
|
+
GRANULAR_PERMISSIONS = {
|
|
17
|
+
'TrustlineAuthorize' => 65_537,
|
|
18
|
+
'TrustlineFreeze' => 65_538,
|
|
19
|
+
'TrustlineUnfreeze' => 65_539,
|
|
20
|
+
'AccountDomainSet' => 65_540,
|
|
21
|
+
'AccountEmailHashSet' => 65_541,
|
|
22
|
+
'AccountMessageKeySet' => 65_542,
|
|
23
|
+
'AccountTransferRateSet' => 65_543,
|
|
24
|
+
'AccountTickSizeSet' => 65_544,
|
|
25
|
+
'PaymentMint' => 65_545,
|
|
26
|
+
'PaymentBurn' => 65_546,
|
|
27
|
+
'MPTokenIssuanceLock' => 65_547,
|
|
28
|
+
'MPTokenIssuanceUnlock' => 65_548
|
|
29
|
+
}.freeze
|
|
30
|
+
|
|
11
31
|
def initialize
|
|
12
32
|
file_path = File.join(__dir__, 'definitions.json') #
|
|
13
33
|
contents = File.read(file_path)
|
|
@@ -18,6 +38,15 @@ module BinaryCodec
|
|
|
18
38
|
@transaction_results = @definitions['TRANSACTION_RESULTS']
|
|
19
39
|
@transaction_types = @definitions['TRANSACTION_TYPES']
|
|
20
40
|
|
|
41
|
+
# PermissionValue names a delegatable permission. A whole transaction
|
|
42
|
+
# type is its type code plus one, so that Payment (type 0) is not
|
|
43
|
+
# confused with "no permission"; the granular permissions follow above.
|
|
44
|
+
@delegatable_permissions = @transaction_types
|
|
45
|
+
.reject { |_, code| code.negative? }
|
|
46
|
+
.transform_values { |code| code + 1 }
|
|
47
|
+
.merge(GRANULAR_PERMISSIONS)
|
|
48
|
+
.freeze
|
|
49
|
+
|
|
21
50
|
@field_info_map = {}
|
|
22
51
|
@field_id_name_map = {}
|
|
23
52
|
@field_header_map = {}
|
|
@@ -55,6 +84,11 @@ module BinaryCodec
|
|
|
55
84
|
attr_reader :definitions
|
|
56
85
|
alias raw definitions
|
|
57
86
|
|
|
87
|
+
# Name -> code tables, for the types that render as names in JSON.
|
|
88
|
+
# @return [Hash{String => Integer}]
|
|
89
|
+
attr_reader :transaction_types, :ledger_entry_types, :transaction_results,
|
|
90
|
+
:delegatable_permissions
|
|
91
|
+
|
|
58
92
|
# Returns the singleton instance of the Definitions class.
|
|
59
93
|
# @return [Definitions] The singleton instance.
|
|
60
94
|
def self.instance
|
|
@@ -77,9 +111,12 @@ module BinaryCodec
|
|
|
77
111
|
|
|
78
112
|
# Returns a FieldInstance for a given field name.
|
|
79
113
|
# @param field_name [String] The name of the field.
|
|
80
|
-
# @return [FieldInstance] The field instance
|
|
114
|
+
# @return [FieldInstance, nil] The field instance, nil for a name the
|
|
115
|
+
# definitions do not know
|
|
81
116
|
def get_field_instance(field_name)
|
|
82
117
|
field_info = @field_info_map[field_name]
|
|
118
|
+
return nil if field_info.nil?
|
|
119
|
+
|
|
83
120
|
field_header = get_field_header_from_name(field_name)
|
|
84
121
|
|
|
85
122
|
FieldInstance.new(
|
|
@@ -10,6 +10,7 @@ module BinaryCodec
|
|
|
10
10
|
OutstandingAmount
|
|
11
11
|
MPTAmount
|
|
12
12
|
LockedAmount
|
|
13
|
+
ConfidentialOutstandingAmount
|
|
13
14
|
].freeze
|
|
14
15
|
|
|
15
16
|
# Returns the width of the Uint type in bytes.
|
|
@@ -29,22 +30,14 @@ module BinaryCodec
|
|
|
29
30
|
return value if value.is_a?(self)
|
|
30
31
|
|
|
31
32
|
if value.is_a?(String)
|
|
32
|
-
#
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return new(int_to_bytes(ledger_entry_types[value], width))
|
|
41
|
-
end
|
|
42
|
-
elsif self == Uint8
|
|
43
|
-
transaction_results = Definitions.instance.instance_variable_get(:@transaction_results)
|
|
44
|
-
if transaction_results&.key?(value)
|
|
45
|
-
return new(int_to_bytes(transaction_results[value], width))
|
|
46
|
-
end
|
|
47
|
-
end
|
|
33
|
+
# Names for the fields that carry one: TransactionType and
|
|
34
|
+
# LedgerEntryType (UInt16), TransactionResult (UInt8) and the
|
|
35
|
+
# PermissionValue of a DelegateSet (UInt32). A name is never a valid
|
|
36
|
+
# number, so the lookup cannot capture a numeric string.
|
|
37
|
+
code = NAMED_VALUES.fetch(self, [])
|
|
38
|
+
.filter_map { |table| Definitions.instance.public_send(table)[value] }
|
|
39
|
+
.first
|
|
40
|
+
return new(int_to_bytes(code, width)) if code
|
|
48
41
|
|
|
49
42
|
# Handle hex strings or numeric strings
|
|
50
43
|
if valid_hex?(value) && value.length == self.width * 2
|
|
@@ -77,29 +70,12 @@ module BinaryCodec
|
|
|
77
70
|
# Returns the JSON representation of the Uint.
|
|
78
71
|
# @return [Integer, String] The value.
|
|
79
72
|
def to_json(_definitions = nil, _field_name = nil)
|
|
80
|
-
#
|
|
81
|
-
#
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if
|
|
86
|
-
name = transaction_types.key(val)
|
|
87
|
-
return name if name
|
|
88
|
-
end
|
|
89
|
-
elsif _field_name == 'LedgerEntryType'
|
|
90
|
-
val = value_of
|
|
91
|
-
ledger_entry_types = Definitions.instance.instance_variable_get(:@ledger_entry_types)
|
|
92
|
-
if ledger_entry_types
|
|
93
|
-
name = ledger_entry_types.key(val)
|
|
94
|
-
return name if name
|
|
95
|
-
end
|
|
96
|
-
elsif _field_name == 'TransactionResult'
|
|
97
|
-
val = value_of
|
|
98
|
-
transaction_results = Definitions.instance.instance_variable_get(:@transaction_results)
|
|
99
|
-
if transaction_results
|
|
100
|
-
name = transaction_results.key(val)
|
|
101
|
-
return name if name
|
|
102
|
-
end
|
|
73
|
+
# The fields that carry a name render it, the way rippled does. A code
|
|
74
|
+
# without a name falls through and renders as the number.
|
|
75
|
+
table = NAMED_FIELDS[_field_name]
|
|
76
|
+
if table
|
|
77
|
+
name = Definitions.instance.public_send(table).key(value_of)
|
|
78
|
+
return name if name
|
|
103
79
|
end
|
|
104
80
|
|
|
105
81
|
# rippled renders the narrow unsigned integers as JSON numbers and UInt64
|
|
@@ -231,4 +207,21 @@ module BinaryCodec
|
|
|
231
207
|
end
|
|
232
208
|
end
|
|
233
209
|
|
|
210
|
+
class Uint
|
|
211
|
+
# Which name tables a width accepts on the way in ...
|
|
212
|
+
NAMED_VALUES = {
|
|
213
|
+
Uint16 => %i[transaction_types ledger_entry_types],
|
|
214
|
+
Uint8 => %i[transaction_results],
|
|
215
|
+
Uint32 => %i[delegatable_permissions]
|
|
216
|
+
}.freeze
|
|
217
|
+
|
|
218
|
+
# ... and which field renders its value by name on the way out.
|
|
219
|
+
NAMED_FIELDS = {
|
|
220
|
+
'TransactionType' => :transaction_types,
|
|
221
|
+
'LedgerEntryType' => :ledger_entry_types,
|
|
222
|
+
'TransactionResult' => :transaction_results,
|
|
223
|
+
'PermissionValue' => :delegatable_permissions
|
|
224
|
+
}.freeze
|
|
225
|
+
end
|
|
226
|
+
|
|
234
227
|
end
|
data/lib/wallet/wallet.rb
CHANGED
|
@@ -162,6 +162,38 @@ module Wallet
|
|
|
162
162
|
@key_pairs.verify(bytes_to_hex(signing_data), signature, @public_key)
|
|
163
163
|
end
|
|
164
164
|
|
|
165
|
+
# Signs a payment channel claim: the promise that +amount+ drops of the
|
|
166
|
+
# channel's funds may be claimed. The signature goes into a
|
|
167
|
+
# PaymentChannelClaim transaction as its Signature.
|
|
168
|
+
#
|
|
169
|
+
# @param channel [String] the channel ID, 64 hex characters
|
|
170
|
+
# @param amount [String, Integer] the amount in drops
|
|
171
|
+
# @return [String] the signature as hex
|
|
172
|
+
def sign_payment_channel_claim(channel, amount)
|
|
173
|
+
data = BinaryCodec.signing_claim_data(channel: channel, amount: amount)
|
|
174
|
+
@key_pairs.sign(bytes_to_hex(data), @private_key, @algorithm)
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
# Verifies a payment channel claim against this wallet's public key.
|
|
178
|
+
#
|
|
179
|
+
# @param channel [String] the channel ID, 64 hex characters
|
|
180
|
+
# @param amount [String, Integer] the amount in drops
|
|
181
|
+
# @param signature [String] the signature as hex
|
|
182
|
+
# @return [Boolean] whether the claim was signed by this wallet
|
|
183
|
+
def verify_payment_channel_claim(channel, amount, signature)
|
|
184
|
+
self.class.verify_payment_channel_claim(channel, amount, signature, @public_key)
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
# Verifies a payment channel claim against any public key - the channel's
|
|
188
|
+
# PublicKey, as the receiving side has it.
|
|
189
|
+
#
|
|
190
|
+
# @param public_key [String] the public key as hex
|
|
191
|
+
# @return [Boolean] whether the claim was signed with that key
|
|
192
|
+
def self.verify_payment_channel_claim(channel, amount, signature, public_key)
|
|
193
|
+
data = BinaryCodec.signing_claim_data(channel: channel, amount: amount)
|
|
194
|
+
KeyPairs::KeyPairs.new.verify(bytes_to_hex(data), signature, public_key)
|
|
195
|
+
end
|
|
196
|
+
|
|
165
197
|
# Derives the X-address for this wallet.
|
|
166
198
|
# @param tag [Integer, false, nil] The destination tag.
|
|
167
199
|
# @param test_network [Boolean] Whether the address is for a test network.
|