Skip to content

Commit 1f7158b

Browse files
committed
Add ability to hash arbitrary transaction, maybe unsigned
1 parent 313c813 commit 1f7158b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/OfflineTool.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,17 @@ doDeserialize(std::string const& data)
132132
}
133133
}
134134

135+
int
136+
doHash(ripple::HashPrefix prefix, std::string const& data)
137+
{
138+
auto const obj = offline::make_stobject(data);
139+
140+
auto const result = obj.getHash(prefix);
141+
142+
std::cout << result << std::endl;
143+
return EXIT_SUCCESS;
144+
}
145+
135146
int
136147
doSign(
137148
std::string const& data,
@@ -312,6 +323,10 @@ runCommand(
312323
BOOST_ASSERT(input);
313324
return doDeserialize(*input);
314325
};
326+
auto const txhash = [](auto const& input, auto const&, auto const&) {
327+
BOOST_ASSERT(input);
328+
return doHash(ripple::HashPrefix::transactionID, *input);
329+
};
315330
auto const sign = [](auto const& input, auto const& keyFile, auto const&) {
316331
BOOST_ASSERT(input);
317332
return doSingleSign(*input, keyFile);
@@ -338,6 +353,7 @@ runCommand(
338353
{"sign", {false, sign}},
339354
{"multisign", {false, multisign}},
340355
{"asign", {false, asign}},
356+
{"txhash", {false, txhash}},
341357
{"createkeyfile", {true, createkeyfile}},
342358
};
343359

@@ -406,13 +422,17 @@ printHelp(
406422
Output is unserialized JSON.
407423
Arbitrary signing:
408424
asign <argument>|--stdin Sign arbitrary data.
425+
Hashing:
426+
txhash <argument>|--stdin Hash a transaction.
409427
Key Management:
410428
createkeyfile [<key>|--stdin] Create keyfile. A random
411429
seed will be used if no <key> is provided on the command line
412430
or from standard input using --stdin.
413431
414432
Default keyfile is: )"
415433
<< defaultKeyfile << "\n";
434+
// In progress:
435+
// hash <prefix> <argument>|--stdin Hash an XRPL object.
416436
}
417437

418438
InputType

0 commit comments

Comments
 (0)