refactor: rename hash functions (#1701)

- Rename hash functions to be shorter for easier use.
- Namespace hash functions into xrpl.hashes
This commit is contained in:
Omar Khan
2021-10-08 16:45:12 -04:00
committed by GitHub
parent cb55d2eacb
commit 9ad2b28172
19 changed files with 176 additions and 191 deletions

File diff suppressed because one or more lines are too long

View File

@@ -513,43 +513,43 @@
<a href="modules.html#ISOTimeToRippleTime" class="tsd-kind-icon">ISOTime<wbr>ToRipple<wbr>Time</a>
</li>
<li class=" tsd-kind-function">
<a href="modules.html#computeAccountRootIndex" class="tsd-kind-icon">compute<wbr>Account<wbr>Root<wbr>Index</a>
<a href="modules.html#hashAccountRoot" class="tsd-kind-icon">compute<wbr>Account<wbr>Root<wbr>Index</a>
</li>
<li class=" tsd-kind-function">
<a href="modules.html#computeBinaryTransactionHash" class="tsd-kind-icon">compute<wbr>Binary<wbr>Transaction<wbr>Hash</a>
</li>
<li class=" tsd-kind-function">
<a href="modules.html#computeBinaryTransactionSigningHash" class="tsd-kind-icon">compute<wbr>Binary<wbr>Transaction<wbr>Signing<wbr>Hash</a>
<a href="modules.html#hashTx" class="tsd-kind-icon">compute<wbr>Binary<wbr>Transaction<wbr>Signing<wbr>Hash</a>
</li>
<li class=" tsd-kind-function">
<a href="modules.html#computeEscrowHash" class="tsd-kind-icon">compute<wbr>Escrow<wbr>Hash</a>
<a href="modules.html#hashEscrow" class="tsd-kind-icon">compute<wbr>Escrow<wbr>Hash</a>
</li>
<li class=" tsd-kind-function">
<a href="modules.html#computeLedgerHash" class="tsd-kind-icon">compute<wbr>Ledger<wbr>Hash</a>
<a href="modules.html#hashLedger" class="tsd-kind-icon">compute<wbr>Ledger<wbr>Hash</a>
</li>
<li class=" tsd-kind-function">
<a href="modules.html#computeLedgerHeaderHash" class="tsd-kind-icon">compute<wbr>Ledger<wbr>Header<wbr>Hash</a>
<a href="modules.html#hashLedgerHeader" class="tsd-kind-icon">compute<wbr>Ledger<wbr>Header<wbr>Hash</a>
</li>
<li class=" tsd-kind-function">
<a href="modules.html#computeOfferIndex" class="tsd-kind-icon">compute<wbr>Offer<wbr>Index</a>
<a href="modules.html#hashOfferId" class="tsd-kind-icon">compute<wbr>Offer<wbr>Index</a>
</li>
<li class=" tsd-kind-function">
<a href="modules.html#computePaymentChannelHash" class="tsd-kind-icon">compute<wbr>Payment<wbr>Channel<wbr>Hash</a>
<a href="modules.html#hashPaymentChannel" class="tsd-kind-icon">compute<wbr>Payment<wbr>Channel<wbr>Hash</a>
</li>
<li class=" tsd-kind-function">
<a href="modules.html#computeSignerListIndex" class="tsd-kind-icon">compute<wbr>Signer<wbr>List<wbr>Index</a>
<a href="modules.html#hashSignerListId" class="tsd-kind-icon">compute<wbr>Signer<wbr>List<wbr>Index</a>
</li>
<li class=" tsd-kind-function">
<a href="modules.html#computeStateTreeHash" class="tsd-kind-icon">compute<wbr>State<wbr>Tree<wbr>Hash</a>
<a href="modules.html#hashStateTree" class="tsd-kind-icon">compute<wbr>State<wbr>Tree<wbr>Hash</a>
</li>
<li class=" tsd-kind-function">
<a href="modules.html#computeTransactionHash" class="tsd-kind-icon">compute<wbr>Transaction<wbr>Hash</a>
</li>
<li class=" tsd-kind-function">
<a href="modules.html#computeTransactionTreeHash" class="tsd-kind-icon">compute<wbr>Transaction<wbr>Tree<wbr>Hash</a>
<a href="modules.html#hashTxTree" class="tsd-kind-icon">compute<wbr>Transaction<wbr>Tree<wbr>Hash</a>
</li>
<li class=" tsd-kind-function">
<a href="modules.html#computeTrustlineHash" class="tsd-kind-icon">compute<wbr>Trustline<wbr>Hash</a>
<a href="modules.html#hashTrustline" class="tsd-kind-icon">compute<wbr>Trustline<wbr>Hash</a>
</li>
<li class=" tsd-kind-function">
<a href="modules.html#convertKeysFromSnakeCaseToCamelCase" class="tsd-kind-icon">convert<wbr>Keys<wbr>From<wbr>Snake<wbr>Case<wbr>ToCamel<wbr>Case</a>

View File

@@ -187,19 +187,19 @@
<h3>Functions</h3>
<ul class="tsd-index-list">
<li class="tsd-kind-function"><a href="modules.html#ISOTimeToRippleTime" class="tsd-kind-icon">ISOTime<wbr>ToRipple<wbr>Time</a></li>
<li class="tsd-kind-function"><a href="modules.html#computeAccountRootIndex" class="tsd-kind-icon">compute<wbr>Account<wbr>Root<wbr>Index</a></li>
<li class="tsd-kind-function"><a href="modules.html#hashAccountRoot" class="tsd-kind-icon">compute<wbr>Account<wbr>Root<wbr>Index</a></li>
<li class="tsd-kind-function"><a href="modules.html#computeBinaryTransactionHash" class="tsd-kind-icon">compute<wbr>Binary<wbr>Transaction<wbr>Hash</a></li>
<li class="tsd-kind-function"><a href="modules.html#computeBinaryTransactionSigningHash" class="tsd-kind-icon">compute<wbr>Binary<wbr>Transaction<wbr>Signing<wbr>Hash</a></li>
<li class="tsd-kind-function"><a href="modules.html#computeEscrowHash" class="tsd-kind-icon">compute<wbr>Escrow<wbr>Hash</a></li>
<li class="tsd-kind-function"><a href="modules.html#computeLedgerHash" class="tsd-kind-icon">compute<wbr>Ledger<wbr>Hash</a></li>
<li class="tsd-kind-function"><a href="modules.html#computeLedgerHeaderHash" class="tsd-kind-icon">compute<wbr>Ledger<wbr>Header<wbr>Hash</a></li>
<li class="tsd-kind-function"><a href="modules.html#computeOfferIndex" class="tsd-kind-icon">compute<wbr>Offer<wbr>Index</a></li>
<li class="tsd-kind-function"><a href="modules.html#computePaymentChannelHash" class="tsd-kind-icon">compute<wbr>Payment<wbr>Channel<wbr>Hash</a></li>
<li class="tsd-kind-function"><a href="modules.html#computeSignerListIndex" class="tsd-kind-icon">compute<wbr>Signer<wbr>List<wbr>Index</a></li>
<li class="tsd-kind-function"><a href="modules.html#computeStateTreeHash" class="tsd-kind-icon">compute<wbr>State<wbr>Tree<wbr>Hash</a></li>
<li class="tsd-kind-function"><a href="modules.html#hashTx" class="tsd-kind-icon">compute<wbr>Binary<wbr>Transaction<wbr>Signing<wbr>Hash</a></li>
<li class="tsd-kind-function"><a href="modules.html#hashEscrow" class="tsd-kind-icon">compute<wbr>Escrow<wbr>Hash</a></li>
<li class="tsd-kind-function"><a href="modules.html#hashLedger" class="tsd-kind-icon">compute<wbr>Ledger<wbr>Hash</a></li>
<li class="tsd-kind-function"><a href="modules.html#hashLedgerHeader" class="tsd-kind-icon">compute<wbr>Ledger<wbr>Header<wbr>Hash</a></li>
<li class="tsd-kind-function"><a href="modules.html#hashOfferId" class="tsd-kind-icon">compute<wbr>Offer<wbr>Index</a></li>
<li class="tsd-kind-function"><a href="modules.html#hashPaymentChannel" class="tsd-kind-icon">compute<wbr>Payment<wbr>Channel<wbr>Hash</a></li>
<li class="tsd-kind-function"><a href="modules.html#hashSignerListId" class="tsd-kind-icon">compute<wbr>Signer<wbr>List<wbr>Index</a></li>
<li class="tsd-kind-function"><a href="modules.html#hashStateTree" class="tsd-kind-icon">compute<wbr>State<wbr>Tree<wbr>Hash</a></li>
<li class="tsd-kind-function"><a href="modules.html#computeTransactionHash" class="tsd-kind-icon">compute<wbr>Transaction<wbr>Hash</a></li>
<li class="tsd-kind-function"><a href="modules.html#computeTransactionTreeHash" class="tsd-kind-icon">compute<wbr>Transaction<wbr>Tree<wbr>Hash</a></li>
<li class="tsd-kind-function"><a href="modules.html#computeTrustlineHash" class="tsd-kind-icon">compute<wbr>Trustline<wbr>Hash</a></li>
<li class="tsd-kind-function"><a href="modules.html#hashTxTree" class="tsd-kind-icon">compute<wbr>Transaction<wbr>Tree<wbr>Hash</a></li>
<li class="tsd-kind-function"><a href="modules.html#hashTrustline" class="tsd-kind-icon">compute<wbr>Trustline<wbr>Hash</a></li>
<li class="tsd-kind-function"><a href="modules.html#convertKeysFromSnakeCaseToCamelCase" class="tsd-kind-icon">convert<wbr>Keys<wbr>From<wbr>Snake<wbr>Case<wbr>ToCamel<wbr>Case</a></li>
<li class="tsd-kind-function"><a href="modules.html#dropsToXrp" class="tsd-kind-icon">drops<wbr>ToXrp</a></li>
<li class="tsd-kind-function"><a href="modules.html#generateXAddress" class="tsd-kind-icon">generateXAddress</a></li>
@@ -382,7 +382,7 @@
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-function">
<a name="computeAccountRootIndex" class="tsd-anchor"></a>
<a name="hashAccountRoot" class="tsd-anchor"></a>
<h3><span class="tsd-flag ts-flagConst">Const</span> compute<wbr>Account<wbr>Root<wbr>Index</h3>
<ul class="tsd-signatures tsd-kind-function">
<li class="tsd-signature tsd-kind-icon">compute<wbr>Account<wbr>Root<wbr>Index<span class="tsd-signature-symbol">(</span>address<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></li>
@@ -442,7 +442,7 @@
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-function">
<a name="computeBinaryTransactionSigningHash" class="tsd-anchor"></a>
<a name="hashTx" class="tsd-anchor"></a>
<h3><span class="tsd-flag ts-flagConst">Const</span> compute<wbr>Binary<wbr>Transaction<wbr>Signing<wbr>Hash</h3>
<ul class="tsd-signatures tsd-kind-function">
<li class="tsd-signature tsd-kind-icon">compute<wbr>Binary<wbr>Transaction<wbr>Signing<wbr>Hash<span class="tsd-signature-symbol">(</span>txBlobHex<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></li>
@@ -475,7 +475,7 @@
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-function">
<a name="computeEscrowHash" class="tsd-anchor"></a>
<a name="hashEscrow" class="tsd-anchor"></a>
<h3><span class="tsd-flag ts-flagConst">Const</span> compute<wbr>Escrow<wbr>Hash</h3>
<ul class="tsd-signatures tsd-kind-function">
<li class="tsd-signature tsd-kind-icon">compute<wbr>Escrow<wbr>Hash<span class="tsd-signature-symbol">(</span>address<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span>, sequence<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></li>
@@ -501,7 +501,7 @@
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-function">
<a name="computeLedgerHash" class="tsd-anchor"></a>
<a name="hashLedger" class="tsd-anchor"></a>
<h3><span class="tsd-flag ts-flagConst">Const</span> compute<wbr>Ledger<wbr>Hash</h3>
<ul class="tsd-signatures tsd-kind-function">
<li class="tsd-signature tsd-kind-icon">compute<wbr>Ledger<wbr>Hash<span class="tsd-signature-symbol">(</span>ledgerHeader<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></li>
@@ -524,10 +524,10 @@
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-function">
<a name="computeLedgerHeaderHash" class="tsd-anchor"></a>
<a name="hashLedgerHeader" class="tsd-anchor"></a>
<h3>compute<wbr>Ledger<wbr>Header<wbr>Hash</h3>
<ul class="tsd-signatures tsd-kind-function">
<li class="tsd-signature tsd-kind-icon">compute<wbr>Ledger<wbr>Header<wbr>Hash<span class="tsd-signature-symbol">(</span>ledger<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span>, options<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">ComputeLedgerHeaderHashOptions</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></li>
<li class="tsd-signature tsd-kind-icon">compute<wbr>Ledger<wbr>Header<wbr>Hash<span class="tsd-signature-symbol">(</span>ledger<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span>, options<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">hashLedgerHeaderOptions</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></li>
</ul>
<ul class="tsd-descriptions">
<li class="tsd-description">
@@ -542,7 +542,7 @@
<h5>ledger: <span class="tsd-signature-type">any</span></h5>
</li>
<li>
<h5>options: <span class="tsd-signature-type">ComputeLedgerHeaderHashOptions</span><span class="tsd-signature-symbol"> = {}</span></h5>
<h5>options: <span class="tsd-signature-type">hashLedgerHeaderOptions</span><span class="tsd-signature-symbol"> = {}</span></h5>
</li>
</ul>
<h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">string</span></h4>
@@ -550,7 +550,7 @@
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-function">
<a name="computeOfferIndex" class="tsd-anchor"></a>
<a name="hashOfferId" class="tsd-anchor"></a>
<h3><span class="tsd-flag ts-flagConst">Const</span> compute<wbr>Offer<wbr>Index</h3>
<ul class="tsd-signatures tsd-kind-function">
<li class="tsd-signature tsd-kind-icon">compute<wbr>Offer<wbr>Index<span class="tsd-signature-symbol">(</span>address<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, sequence<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></li>
@@ -592,7 +592,7 @@
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-function">
<a name="computePaymentChannelHash" class="tsd-anchor"></a>
<a name="hashPaymentChannel" class="tsd-anchor"></a>
<h3><span class="tsd-flag ts-flagConst">Const</span> compute<wbr>Payment<wbr>Channel<wbr>Hash</h3>
<ul class="tsd-signatures tsd-kind-function">
<li class="tsd-signature tsd-kind-icon">compute<wbr>Payment<wbr>Channel<wbr>Hash<span class="tsd-signature-symbol">(</span>address<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span>, dstAddress<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span>, sequence<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></li>
@@ -621,7 +621,7 @@
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-function">
<a name="computeSignerListIndex" class="tsd-anchor"></a>
<a name="hashSignerListId" class="tsd-anchor"></a>
<h3><span class="tsd-flag ts-flagConst">Const</span> compute<wbr>Signer<wbr>List<wbr>Index</h3>
<ul class="tsd-signatures tsd-kind-function">
<li class="tsd-signature tsd-kind-icon">compute<wbr>Signer<wbr>List<wbr>Index<span class="tsd-signature-symbol">(</span>address<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></li>
@@ -660,7 +660,7 @@
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-function">
<a name="computeStateTreeHash" class="tsd-anchor"></a>
<a name="hashStateTree" class="tsd-anchor"></a>
<h3><span class="tsd-flag ts-flagConst">Const</span> compute<wbr>State<wbr>Tree<wbr>Hash</h3>
<ul class="tsd-signatures tsd-kind-function">
<li class="tsd-signature tsd-kind-icon">compute<wbr>State<wbr>Tree<wbr>Hash<span class="tsd-signature-symbol">(</span>entries<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></li>
@@ -706,7 +706,7 @@
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-function">
<a name="computeTransactionTreeHash" class="tsd-anchor"></a>
<a name="hashTxTree" class="tsd-anchor"></a>
<h3><span class="tsd-flag ts-flagConst">Const</span> compute<wbr>Transaction<wbr>Tree<wbr>Hash</h3>
<ul class="tsd-signatures tsd-kind-function">
<li class="tsd-signature tsd-kind-icon">compute<wbr>Transaction<wbr>Tree<wbr>Hash<span class="tsd-signature-symbol">(</span>transactions<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></li>
@@ -729,7 +729,7 @@
</ul>
</section>
<section class="tsd-panel tsd-member tsd-kind-function">
<a name="computeTrustlineHash" class="tsd-anchor"></a>
<a name="hashTrustline" class="tsd-anchor"></a>
<h3><span class="tsd-flag ts-flagConst">Const</span> compute<wbr>Trustline<wbr>Hash</h3>
<ul class="tsd-signatures tsd-kind-function">
<li class="tsd-signature tsd-kind-icon">compute<wbr>Trustline<wbr>Hash<span class="tsd-signature-symbol">(</span>address1<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, address2<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, currency<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span></li>
@@ -1319,43 +1319,43 @@
<a href="modules.html#ISOTimeToRippleTime" class="tsd-kind-icon">ISOTime<wbr>ToRipple<wbr>Time</a>
</li>
<li class=" tsd-kind-function">
<a href="modules.html#computeAccountRootIndex" class="tsd-kind-icon">compute<wbr>Account<wbr>Root<wbr>Index</a>
<a href="modules.html#hashAccountRoot" class="tsd-kind-icon">compute<wbr>Account<wbr>Root<wbr>Index</a>
</li>
<li class=" tsd-kind-function">
<a href="modules.html#computeBinaryTransactionHash" class="tsd-kind-icon">compute<wbr>Binary<wbr>Transaction<wbr>Hash</a>
</li>
<li class=" tsd-kind-function">
<a href="modules.html#computeBinaryTransactionSigningHash" class="tsd-kind-icon">compute<wbr>Binary<wbr>Transaction<wbr>Signing<wbr>Hash</a>
<a href="modules.html#hashTx" class="tsd-kind-icon">compute<wbr>Binary<wbr>Transaction<wbr>Signing<wbr>Hash</a>
</li>
<li class=" tsd-kind-function">
<a href="modules.html#computeEscrowHash" class="tsd-kind-icon">compute<wbr>Escrow<wbr>Hash</a>
<a href="modules.html#hashEscrow" class="tsd-kind-icon">compute<wbr>Escrow<wbr>Hash</a>
</li>
<li class=" tsd-kind-function">
<a href="modules.html#computeLedgerHash" class="tsd-kind-icon">compute<wbr>Ledger<wbr>Hash</a>
<a href="modules.html#hashLedger" class="tsd-kind-icon">compute<wbr>Ledger<wbr>Hash</a>
</li>
<li class=" tsd-kind-function">
<a href="modules.html#computeLedgerHeaderHash" class="tsd-kind-icon">compute<wbr>Ledger<wbr>Header<wbr>Hash</a>
<a href="modules.html#hashLedgerHeader" class="tsd-kind-icon">compute<wbr>Ledger<wbr>Header<wbr>Hash</a>
</li>
<li class=" tsd-kind-function">
<a href="modules.html#computeOfferIndex" class="tsd-kind-icon">compute<wbr>Offer<wbr>Index</a>
<a href="modules.html#hashOfferId" class="tsd-kind-icon">compute<wbr>Offer<wbr>Index</a>
</li>
<li class=" tsd-kind-function">
<a href="modules.html#computePaymentChannelHash" class="tsd-kind-icon">compute<wbr>Payment<wbr>Channel<wbr>Hash</a>
<a href="modules.html#hashPaymentChannel" class="tsd-kind-icon">compute<wbr>Payment<wbr>Channel<wbr>Hash</a>
</li>
<li class=" tsd-kind-function">
<a href="modules.html#computeSignerListIndex" class="tsd-kind-icon">compute<wbr>Signer<wbr>List<wbr>Index</a>
<a href="modules.html#hashSignerListId" class="tsd-kind-icon">compute<wbr>Signer<wbr>List<wbr>Index</a>
</li>
<li class=" tsd-kind-function">
<a href="modules.html#computeStateTreeHash" class="tsd-kind-icon">compute<wbr>State<wbr>Tree<wbr>Hash</a>
<a href="modules.html#hashStateTree" class="tsd-kind-icon">compute<wbr>State<wbr>Tree<wbr>Hash</a>
</li>
<li class=" tsd-kind-function">
<a href="modules.html#computeTransactionHash" class="tsd-kind-icon">compute<wbr>Transaction<wbr>Hash</a>
</li>
<li class=" tsd-kind-function">
<a href="modules.html#computeTransactionTreeHash" class="tsd-kind-icon">compute<wbr>Transaction<wbr>Tree<wbr>Hash</a>
<a href="modules.html#hashTxTree" class="tsd-kind-icon">compute<wbr>Transaction<wbr>Tree<wbr>Hash</a>
</li>
<li class=" tsd-kind-function">
<a href="modules.html#computeTrustlineHash" class="tsd-kind-icon">compute<wbr>Trustline<wbr>Hash</a>
<a href="modules.html#hashTrustline" class="tsd-kind-icon">compute<wbr>Trustline<wbr>Hash</a>
</li>
<li class=" tsd-kind-function">
<a href="modules.html#convertKeysFromSnakeCaseToCamelCase" class="tsd-kind-icon">convert<wbr>Keys<wbr>From<wbr>Snake<wbr>Case<wbr>ToCamel<wbr>Case</a>

View File

@@ -4,7 +4,7 @@ import type { Client, SubmitRequest, SubmitResponse, Wallet } from '..'
import { ValidationError, XrplError } from '../errors'
import { TxResponse } from '../models/methods'
import { Transaction } from '../models/transactions'
import { computeSignedTransactionHash } from '../utils'
import { hashes } from '../utils'
import { sign } from '../wallet/signer'
// general time for a ledger to close, in milliseconds
@@ -115,7 +115,7 @@ async function submitSignedReliable(
typeof signedTransaction === 'string'
? signedTransaction
: encode(signedTransaction)
const txHash = computeSignedTransactionHash(signedTransaction)
const txHash = hashes.hashSignedTx(signedTransaction)
const request: SubmitRequest = {
command: 'submit',

View File

@@ -18,7 +18,7 @@ In many cases, the XRP Ledger prefixes an object's binary data with a 4-byte cod
Some types of hashes appear in API requests and responses. Others are only calculated as the first step of signing a certain type of data, or calculating a higher-level hash. Some of following methods internally use some of the 4-byte hash prefixes in order to calculate the appropriate hash.
### computeBinaryTransactionSigningHash = (txBlobHex: string): string
### hashTx = (txBlobHex: string): string
In order to single-sign a transaction, you must perform these steps:
@@ -26,11 +26,11 @@ In order to single-sign a transaction, you must perform these steps:
2. Hash the data with the appropriate prefix (`0x53545800` if single-signing, or `0x534D5400` if multi-signing).
3. After signing, you must re-serialize the transaction with the `TxnSignature` field included.
The `computeBinaryTransactionSigningHash` helps with step 2, automatically using the `0x53545800` prefix needed for single-signing a transaction.
The `hashTx` helps with step 2, automatically using the `0x53545800` prefix needed for single-signing a transaction.
For details, see [Serialization Format](https://xrpl.org/serialization.html).
_Removed:_ `computeTransactionSigningHash`, which took txJSON as a parameter. It was part of the deprecated ripple-hashes library. If you have txJSON, `encode` it with [ripple-binary-codec](https://github.com/ripple/ripple-binary-codec) first. Example: `return computeBinaryTransactionSigningHash(encode(txJSON))`
_Removed:_ `computeTransactionSigningHash`, which took txJSON as a parameter. It was part of the deprecated ripple-hashes library. If you have txJSON, `encode` it with [ripple-binary-codec](https://github.com/ripple/ripple-binary-codec) first. Example: `return hashTx(encode(txJSON))`
### computeAccountLedgerObjectID = (address: string): string
@@ -44,22 +44,22 @@ Compute the hash of an account's SignerList.
Compute the hash of an order, given the owner's classic address (starting with `r`) and the account sequence number of the `OfferCreate` order transaction.
### computeTrustlineHash = (address1: string, address2: string, currency: string): string
### hashTrustline = (address1: string, address2: string, currency: string): string
Compute the hash of a trustline, given the two parties' classic addresses (starting with `r`) and the currency code.
### computeTransactionTreeHash = (transactions: any[]): string
### hashTxTree = (transactions: any[]): string
### computeStateTreeHash = (entries: any[]): string
### hashStateTree = (entries: any[]): string
### computeLedgerHash = (ledgerHeader): string
### hashLedger = (ledgerHeader): string
Compute the hash of a ledger.
### computeEscrowHash = (address, sequence): string
### hashEscrow = (address, sequence): string
Compute the hash of an escrow, given the owner's classic address (starting with `r`) and the account sequence number of the `EscrowCreate` escrow transaction.
### computePaymentChannelHash = (address, dstAddress, sequence): string
### hashPaymentChannel = (address, dstAddress, sequence): string
Compute the hash of a payment channel, given the owner's classic address (starting with `r`), the classic address of the destination, and the account sequence number of the `PaymentChannelCreate` payment channel transaction.

View File

@@ -7,11 +7,11 @@ import BigNumber from 'bignumber.js'
import { decodeAccountID } from 'ripple-address-codec'
import HashPrefix from './hashPrefix'
import computeLedgerHash, {
computeLedgerHeaderHash,
computeSignedTransactionHash,
computeTransactionTreeHash,
computeStateTreeHash,
import hashLedger, {
hashLedgerHeader,
hashSignedTx,
hashTxTree,
hashStateTree,
} from './ledgerHash'
import ledgerSpaces from './ledgerSpaces'
import sha512Half from './sha512Half'
@@ -48,7 +48,7 @@ function currencyToHex(currency: string): string {
* @param txBlobHex - The binary transaction blob as a hexadecimal string.
* @returns The hash to sign.
*/
export function computeBinaryTransactionSigningHash(txBlobHex: string): string {
export function hashTx(txBlobHex: string): string {
const prefix = HashPrefix.TRANSACTION_SIGN.toString(HEX).toUpperCase()
return sha512Half(prefix + txBlobHex)
}
@@ -66,7 +66,7 @@ export function computeBinaryTransactionSigningHash(txBlobHex: string): string {
* @param address - The classic account address.
* @returns The Ledger Object Index for the account.
*/
export function computeAccountRootIndex(address: string): string {
export function hashAccountRoot(address: string): string {
return sha512Half(ledgerSpaceHex('account') + addressToHex(address))
}
@@ -83,7 +83,7 @@ export function computeAccountRootIndex(address: string): string {
* @param address - The classic account address of the SignerList owner (starting with r).
* @returns The Index of the account's SignerList object.
*/
export function computeSignerListIndex(address: string): string {
export function hashSignerListId(address: string): string {
return sha512Half(
`${ledgerSpaceHex('signerList') + addressToHex(address)}00000000`,
)
@@ -103,7 +103,7 @@ export function computeSignerListIndex(address: string): string {
* @param sequence - Sequence of the Offer.
* @returns The Index of the account's Offer object.
*/
export function computeOfferIndex(address: string, sequence: number): string {
export function hashOfferId(address: string, sequence: number): string {
const hexPrefix = ledgerSpaces.offer
.charCodeAt(0)
.toString(HEX)
@@ -121,7 +121,7 @@ export function computeOfferIndex(address: string, sequence: number): string {
* @param currency - Currency in the Trustline.
* @returns The hash of the Trustline.
*/
export function computeTrustlineHash(
export function hashTrustline(
address1: string,
address2: string,
currency: string,
@@ -148,7 +148,7 @@ export function computeTrustlineHash(
* @param sequence - OfferSequence of the Escrow.
* @returns The hash of the Escrow LedgerEntry.
*/
export function computeEscrowHash(address: string, sequence: number): string {
export function hashEscrow(address: string, sequence: number): string {
return sha512Half(
ledgerSpaceHex('escrow') +
addressToHex(address) +
@@ -164,7 +164,7 @@ export function computeEscrowHash(address: string, sequence: number): string {
* @param sequence - Sequence number of the Transaction that created the Payment Channel.
* @returns Hash of the Payment Channel.
*/
export function computePaymentChannelHash(
export function hashPaymentChannel(
address: string,
dstAddress: string,
sequence: number,
@@ -177,10 +177,4 @@ export function computePaymentChannelHash(
)
}
export {
computeLedgerHeaderHash,
computeSignedTransactionHash,
computeLedgerHash,
computeStateTreeHash,
computeTransactionTreeHash,
}
export { hashLedgerHeader, hashSignedTx, hashLedger, hashStateTree, hashTxTree }

View File

@@ -18,7 +18,7 @@ import SHAMap, { NodeType } from './shaMap'
const HEX = 16
interface ComputeLedgerHeaderHashOptions {
interface HashLedgerHeaderOptions {
computeTreeHashes?: boolean
}
@@ -71,7 +71,7 @@ function addLengthPrefix(hex: string): string {
* @returns A hash of tx.
* @throws ValidationError if the Transaction is unsigned.
*/
export function computeSignedTransactionHash(tx: Transaction | string): string {
export function hashSignedTx(tx: Transaction | string): string {
let txBlob: string
let txObject: Transaction
if (typeof tx === 'string') {
@@ -98,7 +98,7 @@ export function computeSignedTransactionHash(tx: Transaction | string): string {
* @param ledgerHeader - Ledger to compute the hash of.
* @returns The hash of the ledger.
*/
export function computeLedgerHeaderHash(ledgerHeader: Ledger): string {
export function hashLedgerHeader(ledgerHeader: Ledger): string {
const prefix = HashPrefix.LEDGER.toString(HEX).toUpperCase()
const ledger =
@@ -122,14 +122,14 @@ export function computeLedgerHeaderHash(ledgerHeader: Ledger): string {
* @param transactions - List of Transactions.
* @returns The root hash of the SHAMap.
*/
export function computeTransactionTreeHash(
export function hashTxTree(
transactions: Array<Transaction & { metaData?: Metadata }>,
): string {
const shamap = new SHAMap()
for (const txJSON of transactions) {
const txBlobHex = encode(txJSON)
const metaHex = encode(txJSON.metaData ?? {})
const txHash = computeSignedTransactionHash(txBlobHex)
const txHash = hashSignedTx(txBlobHex)
const data = addLengthPrefix(txBlobHex) + addLengthPrefix(metaHex)
shamap.addItem(txHash, data, NodeType.TRANSACTION_METADATA)
}
@@ -143,7 +143,7 @@ export function computeTransactionTreeHash(
* @param entries - List of LedgerEntries.
* @returns Hash of SHAMap that consists of all entries.
*/
export function computeStateTreeHash(entries: LedgerEntry[]): string {
export function hashStateTree(entries: LedgerEntry[]): string {
const shamap = new SHAMap()
entries.forEach((ledgerEntry) => {
@@ -156,7 +156,7 @@ export function computeStateTreeHash(entries: LedgerEntry[]): string {
function computeTransactionHash(
ledger: Ledger,
options: ComputeLedgerHeaderHashOptions,
options: HashLedgerHeaderOptions,
): string {
const { transaction_hash } = ledger
@@ -168,7 +168,7 @@ function computeTransactionHash(
throw new ValidationError('transactions is missing from the ledger')
}
const transactionHash = computeTransactionTreeHash(ledger.transactions)
const transactionHash = hashTxTree(ledger.transactions)
if (transaction_hash !== transactionHash) {
throw new ValidationError(
@@ -186,7 +186,7 @@ function computeTransactionHash(
function computeStateHash(
ledger: Ledger,
options: ComputeLedgerHeaderHashOptions,
options: HashLedgerHeaderOptions,
): string {
const { account_hash } = ledger
@@ -198,7 +198,7 @@ function computeStateHash(
throw new ValidationError('accountState is missing from the ledger')
}
const stateHash = computeStateTreeHash(ledger.accountState)
const stateHash = hashStateTree(ledger.accountState)
if (account_hash !== stateHash) {
throw new ValidationError(
@@ -216,15 +216,15 @@ function computeStateHash(
* @param options - Allow client to recompute Transaction and State Hashes.
* @returns The has of ledger.
*/
function computeLedgerHash(
function hashLedger(
ledger: Ledger,
options: ComputeLedgerHeaderHashOptions = {},
options: HashLedgerHeaderOptions = {},
): string {
const subhashes = {
transaction_hash: computeTransactionHash(ledger, options),
account_hash: computeStateHash(ledger, options),
}
return computeLedgerHeaderHash({ ...ledger, ...subhashes })
return hashLedgerHeader({ ...ledger, ...subhashes })
}
export default computeLedgerHash
export default hashLedger

View File

@@ -19,18 +19,18 @@ import getBalanceChanges from './balanceChanges'
import { deriveKeypair, deriveXAddress } from './derive'
import { generateXAddress } from './generateAddress'
import {
computeSignedTransactionHash,
computeBinaryTransactionSigningHash,
computeAccountRootIndex,
computeSignerListIndex,
computeOfferIndex,
computeTrustlineHash,
computeTransactionTreeHash,
computeStateTreeHash,
computeLedgerHash,
computeLedgerHeaderHash,
computeEscrowHash,
computePaymentChannelHash,
hashSignedTx,
hashTx,
hashAccountRoot,
hashSignerListId,
hashOfferId,
hashTrustline,
hashTxTree,
hashStateTree,
hashLedger,
hashLedgerHeader,
hashEscrow,
hashPaymentChannel,
} from './hashes'
import signPaymentChannelClaim from './signPaymentChannelClaim'
import {
@@ -97,6 +97,21 @@ function convertStringToHex(string: string): string {
return Buffer.from(string, 'utf8').toString('hex').toUpperCase()
}
const hashes = {
hashSignedTx,
hashTx,
hashAccountRoot,
hashSignerListId,
hashOfferId,
hashTrustline,
hashTxTree,
hashStateTree,
hashLedger,
hashLedgerHeader,
hashEscrow,
hashPaymentChannel,
}
export {
getBalanceChanges,
dropsToXrp,
@@ -108,18 +123,7 @@ export {
unixTimeToRippleTime,
isValidSecret,
isValidAddress,
computeSignedTransactionHash,
computeBinaryTransactionSigningHash,
computeAccountRootIndex,
computeSignerListIndex,
computeOfferIndex,
computeTrustlineHash,
computeTransactionTreeHash,
computeStateTreeHash,
computeLedgerHash,
computeLedgerHeaderHash,
computeEscrowHash,
computePaymentChannelHash,
hashes,
generateXAddress,
deriveKeypair,
deriveXAddress,

View File

@@ -1,6 +1,4 @@
import setDomain from './combine.json'
import header from './computeLedgerHash.json'
import transactions from './computeLedgerHashTransactions.json'
import normalOrderBook from './getOrderbook.json'
import withXRPOrderBook from './getOrderbookWithXrp.json'
import invalid from './getpaths/invalid.json'
@@ -14,6 +12,8 @@ import sendAll from './getpaths/sendAll.json'
import UsdToUsd from './getpaths/usd2usd.json'
import XrpToXrp from './getpaths/xrp2xrp.json'
import XrpToXrpNotEnough from './getpaths/xrp2xrpNotEnough.json'
import header from './hashLedger.json'
import transactions from './hashLedgerTransactions.json'
import normalCheckCancel from './prepareCheckCancel.json'
import amountCheckCash from './prepareCheckCashAmount.json'
import deliverMinCheckCash from './prepareCheckCashDelivermin.json'
@@ -177,7 +177,7 @@ const getOrderbook = {
withXRP: withXRPOrderBook,
}
const computeLedgerHash = {
const hashLedger = {
header,
transactions,
}
@@ -188,7 +188,7 @@ const combine = {
const requests = {
combine,
computeLedgerHash,
hashLedger,
getOrderbook,
getPaths,
prepareCheckCash,

View File

@@ -6,7 +6,7 @@ import {
AccountSet,
SubmitRequest,
SubmitResponse,
computeSignedTransactionHash,
hashes,
Transaction,
} from 'xrpl-local'
import { convertStringToHex } from 'xrpl-local/utils'
@@ -17,6 +17,7 @@ import { ledgerAccept, verifySubmittedTransaction } from '../utils'
// how long before each test case times out
const TIMEOUT = 20000
const { hashSignedTx } = hashes
describe('submit', function () {
this.timeout(TIMEOUT)
@@ -54,7 +55,7 @@ describe('submit', function () {
tx_blob: signedTx,
tx_json: {
...(decode(signedTx) as unknown as Transaction),
hash: computeSignedTransactionHash(signedTx),
hash: hashSignedTx(signedTx),
},
accepted: true,
account_sequence_available:

View File

@@ -9,7 +9,7 @@ import {
SubmitMultisignedRequest,
Transaction,
SubmitMultisignedResponse,
computeSignedTransactionHash,
hashes,
} from 'xrpl-local'
import { convertStringToHex } from 'xrpl-local/utils'
import { multisign, sign } from 'xrpl-local/wallet/signer'
@@ -25,6 +25,7 @@ import {
// how long before each test case times out
const TIMEOUT = 20000
const { hashSignedTx } = hashes
describe('submit_multisigned', function () {
this.timeout(TIMEOUT)
@@ -90,7 +91,7 @@ describe('submit_multisigned', function () {
tx_blob: multisigned,
tx_json: {
...(decode(multisigned) as unknown as Transaction),
hash: computeSignedTransactionHash(multisigned),
hash: hashSignedTx(multisigned),
},
},
}

View File

@@ -1,12 +1,7 @@
import { assert } from 'chai'
import _ from 'lodash'
import {
AccountSet,
computeSignedTransactionHash,
SubmitResponse,
TxResponse,
} from 'xrpl-local'
import { AccountSet, hashes, SubmitResponse, TxResponse } from 'xrpl-local'
import { convertStringToHex } from 'xrpl-local/utils'
import serverUrl from '../serverUrl'
@@ -14,6 +9,7 @@ import { setupClient, suiteClientSetup, teardownClient } from '../setup'
// how long before each test case times out
const TIMEOUT = 20000
const { hashSignedTx } = hashes
describe('tx', function () {
this.timeout(TIMEOUT)
@@ -35,7 +31,7 @@ describe('tx', function () {
accountSet,
)
const hash = computeSignedTransactionHash(response.result.tx_blob)
const hash = hashSignedTx(response.result.tx_blob)
const txResponse = await this.client.request({
command: 'tx',
transaction: hash,
@@ -52,7 +48,7 @@ describe('tx', function () {
Sequence: txResponse.result.Sequence,
SigningPubKey: this.wallet.publicKey,
TxnSignature: txResponse.result.TxnSignature,
hash: computeSignedTransactionHash(response.result.tx_blob),
hash: hashSignedTx(response.result.tx_blob),
validated: false,
},
}

View File

@@ -1,10 +1,6 @@
import _ from 'lodash'
import {
PaymentChannelCreate,
computePaymentChannelHash,
PaymentChannelClaim,
} from 'xrpl-local'
import { PaymentChannelCreate, hashes, PaymentChannelClaim } from 'xrpl-local'
import serverUrl from '../serverUrl'
import { setupClient, suiteClientSetup, teardownClient } from '../setup'
@@ -12,6 +8,7 @@ import { generateFundedWallet, testTransaction } from '../utils'
// how long before each test case times out
const TIMEOUT = 20000
const { hashPaymentChannel } = hashes
describe('PaymentChannelClaim', function () {
this.timeout(TIMEOUT)
@@ -41,7 +38,7 @@ describe('PaymentChannelClaim', function () {
const paymentChannelClaim: PaymentChannelClaim = {
Account: this.wallet.getClassicAddress(),
TransactionType: 'PaymentChannelClaim',
Channel: computePaymentChannelHash(
Channel: hashPaymentChannel(
this.wallet.getClassicAddress(),
wallet2.getClassicAddress(),
paymentChannelResponse.result.tx_json.Sequence ?? 0,

View File

@@ -1,10 +1,6 @@
import _ from 'lodash'
import {
PaymentChannelCreate,
computePaymentChannelHash,
PaymentChannelFund,
} from 'xrpl-local'
import { PaymentChannelCreate, hashes, PaymentChannelFund } from 'xrpl-local'
import serverUrl from '../serverUrl'
import { setupClient, suiteClientSetup, teardownClient } from '../setup'
@@ -12,6 +8,7 @@ import { generateFundedWallet, testTransaction } from '../utils'
// how long before each test case times out
const TIMEOUT = 20000
const { hashPaymentChannel } = hashes
describe('PaymentChannelFund', function () {
this.timeout(TIMEOUT)
@@ -40,7 +37,7 @@ describe('PaymentChannelFund', function () {
const paymentChannelFund: PaymentChannelFund = {
Account: this.wallet.getClassicAddress(),
TransactionType: 'PaymentChannelFund',
Channel: computePaymentChannelHash(
Channel: hashPaymentChannel(
this.wallet.getClassicAddress(),
wallet2.getClassicAddress(),
paymentChannelResponse.result.tx_json.Sequence ?? 0,

View File

@@ -4,7 +4,7 @@ import { decode } from 'ripple-binary-codec'
import { Client, Wallet, AccountInfoRequest } from 'xrpl-local'
import { Payment, Transaction } from 'xrpl-local/models/transactions'
import { computeSignedTransactionHash } from 'xrpl-local/utils/hashes'
import { hashSignedTx } from 'xrpl-local/utils/hashes'
const masterAccount = 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh'
const masterSecret = 'snoPBrXtMeMyMHUVTgbuqAfg1SUTb'
@@ -45,7 +45,7 @@ export async function verifySubmittedTransaction(
client: Client,
tx: Transaction | string,
): Promise<void> {
const hash = computeSignedTransactionHash(tx)
const hash = hashSignedTx(tx)
const data = await client.request({
command: 'tx',
transaction: hash,

View File

@@ -2,13 +2,14 @@ import { assert } from 'chai'
import { ValidationError, XrplError } from 'xrpl-local'
import { computeLedgerHash } from '../../src/utils'
import { hashes } from '../../src/utils'
import requests from '../fixtures/requests'
import responses from '../fixtures/responses'
const { computeLedgerHash: REQUEST_FIXTURES } = requests
const { hashLedger } = hashes
const { hashLedger: REQUEST_FIXTURES } = requests
describe('computeLedgerHash', function () {
describe('hashLedger', function () {
let ledger
beforeEach(function () {
ledger = JSON.parse(JSON.stringify(responses.getLedger.full))
@@ -26,7 +27,7 @@ describe('computeLedgerHash', function () {
ledger.parent_close_time = ledger.close_time
let hash: string
try {
hash = computeLedgerHash(ledger, { computeTreeHashes: true })
hash = hashLedger(ledger, { computeTreeHashes: true })
} catch (error) {
if (!(error instanceof XrplError)) {
throw error
@@ -58,7 +59,7 @@ describe('computeLedgerHash', function () {
ledger.parentCloseTime = ledger.closeTime
assert.throws(
() => computeLedgerHash(ledger, { computeTreeHashes: true }),
() => hashLedger(ledger, { computeTreeHashes: true }),
ValidationError,
'transactions is missing from the ledger',
)
@@ -72,7 +73,7 @@ describe('computeLedgerHash', function () {
ledger.parent_close_time = ledger.close_time
function testCompute(ledgerToTest, expectedError): void {
const hash = computeLedgerHash(ledgerToTest)
const hash = hashLedger(ledgerToTest)
assert.strictEqual(
hash,
'E6DB7365949BF9814D76BCC730B01818EB9136A89DB224F3F9F5AAE4569D758E',
@@ -80,7 +81,7 @@ describe('computeLedgerHash', function () {
// fail if required to compute tree hashes
assert.throws(
() => computeLedgerHash(ledgerToTest, { computeTreeHashes: true }),
() => hashLedger(ledgerToTest, { computeTreeHashes: true }),
ValidationError,
expectedError,
)
@@ -105,16 +106,16 @@ describe('computeLedgerHash', function () {
assert.throws(
() => {
computeLedgerHash(newLedger, { computeTreeHashes: true })
hashLedger(newLedger, { computeTreeHashes: true })
},
ValidationError,
'does not match computed hash of state',
)
})
it('computeLedgerHash', function () {
it('hashLedger', function () {
const header = REQUEST_FIXTURES.header
const ledgerHash = computeLedgerHash(header)
const ledgerHash = hashLedger(header)
assert.strictEqual(
ledgerHash,
@@ -122,20 +123,20 @@ describe('computeLedgerHash', function () {
)
})
it('computeLedgerHash - with transactions', function () {
it('hashLedger - with transactions', function () {
const header = {
...REQUEST_FIXTURES.header,
transactionHash: undefined,
rawTransactions: REQUEST_FIXTURES.transactions,
}
const ledgerHash = computeLedgerHash(header)
const ledgerHash = hashLedger(header)
assert.strictEqual(
ledgerHash,
'F4D865D83EB88C1A1911B9E90641919A1314F36E1B099F8E95FE3B7C77BE3349',
)
})
it('computeLedgerHash - incorrect transaction_hash', function () {
it('hashLedger - incorrect transaction_hash', function () {
const header = {
...REQUEST_FIXTURES.header,
transaction_hash:
@@ -145,7 +146,7 @@ describe('computeLedgerHash', function () {
}
assert.throws(
() => computeLedgerHash(header, { computeTreeHashes: true }),
() => hashLedger(header, { computeTreeHashes: true }),
ValidationError,
'transactionHash in header does not match computed hash of transactions',
)

View File

@@ -7,15 +7,15 @@ import { encode } from 'ripple-binary-codec'
import { OfferCreate, Transaction, ValidationError } from 'xrpl-local'
import {
computeStateTreeHash,
computeTransactionTreeHash,
computeTrustlineHash,
computeEscrowHash,
computePaymentChannelHash,
computeSignedTransactionHash,
computeAccountRootIndex,
computeOfferIndex,
computeSignerListIndex,
hashStateTree,
hashTxTree,
hashTrustline,
hashEscrow,
hashPaymentChannel,
hashSignedTx,
hashAccountRoot,
hashOfferId,
hashSignerListId,
} from '../../src/utils/hashes'
import fixtures from '../fixtures/rippled'
import { assertResultMatch } from '../testUtils'
@@ -46,7 +46,7 @@ function createLedgerTest(ledgerIndex: number): void {
it(`has account_hash of ${ledgerJSON.account_hash}`, function () {
assert.equal(
ledgerJSON.account_hash,
computeStateTreeHash(ledgerJSON.accountState),
hashStateTree(ledgerJSON.accountState),
)
})
}
@@ -54,7 +54,7 @@ function createLedgerTest(ledgerIndex: number): void {
it(`has transaction_hash of ${ledgerJSON.transaction_hash}`, function () {
assert.equal(
ledgerJSON.transaction_hash,
computeTransactionTreeHash(ledgerJSON.transactions),
hashTxTree(ledgerJSON.transactions),
)
})
})
@@ -75,7 +75,7 @@ describe('Hashes', function () {
const account = 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh'
const expectedEntryHash =
'2B6AC232AA4C4BE41BF49D2459FA4A0347E1B543A4C92FCEE0821C0201E2E9A8'
const actualEntryHash = computeAccountRootIndex(account)
const actualEntryHash = hashAccountRoot(account)
assert.equal(actualEntryHash, expectedEntryHash)
})
@@ -87,8 +87,8 @@ describe('Hashes', function () {
const expectedEntryHash =
'C683B5BB928F025F1E860D9D69D6C554C2202DE0D45877ADB3077DA4CB9E125C'
const actualEntryHash1 = computeTrustlineHash(account1, account2, currency)
const actualEntryHash2 = computeTrustlineHash(account2, account1, currency)
const actualEntryHash1 = hashTrustline(account1, account2, currency)
const actualEntryHash2 = hashTrustline(account2, account1, currency)
assert.equal(actualEntryHash1, expectedEntryHash)
assert.equal(actualEntryHash2, expectedEntryHash)
@@ -101,8 +101,8 @@ describe('Hashes', function () {
const expectedEntryHash =
'AE9ADDC584358E5847ADFC971834E471436FC3E9DE6EA1773DF49F419DC0F65E'
const actualEntryHash1 = computeTrustlineHash(account1, account2, currency)
const actualEntryHash2 = computeTrustlineHash(account2, account1, currency)
const actualEntryHash1 = hashTrustline(account1, account2, currency)
const actualEntryHash2 = hashTrustline(account2, account1, currency)
assert.equal(actualEntryHash1, expectedEntryHash)
assert.equal(actualEntryHash2, expectedEntryHash)
@@ -113,16 +113,16 @@ describe('Hashes', function () {
const sequence = 137
const expectedEntryHash =
'03F0AED09DEEE74CEF85CD57A0429D6113507CF759C597BABB4ADB752F734CE3'
const actualEntryHash = computeOfferIndex(account, sequence)
const actualEntryHash = hashOfferId(account, sequence)
assert.equal(actualEntryHash, expectedEntryHash)
})
it('computeSignerListIndex', function () {
it('hashSignerListId', function () {
const account = 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh'
const expectedEntryHash =
'778365D5180F5DF3016817D1F318527AD7410D83F8636CF48C43E8AF72AB49BF'
const actualEntryHash = computeSignerListIndex(account)
const actualEntryHash = hashSignerListId(account)
assert.equal(actualEntryHash, expectedEntryHash)
})
@@ -131,7 +131,7 @@ describe('Hashes', function () {
const sequence = 84
const expectedEntryHash =
'61E8E8ED53FA2CEBE192B23897071E9A75217BF5A410E9CB5B45AAB7AECA567A'
const actualEntryHash = computeEscrowHash(account, sequence)
const actualEntryHash = hashEscrow(account, sequence)
assert.equal(actualEntryHash, expectedEntryHash)
})
@@ -142,11 +142,7 @@ describe('Hashes', function () {
const sequence = 82
const expectedEntryHash =
'E35708503B3C3143FB522D749AAFCC296E8060F0FB371A9A56FAE0B1ED127366'
const actualEntryHash = computePaymentChannelHash(
account,
dstAccount,
sequence,
)
const actualEntryHash = hashPaymentChannel(account, dstAccount, sequence)
assert.equal(actualEntryHash, expectedEntryHash)
})
@@ -156,9 +152,7 @@ describe('Hashes', function () {
'458101D51051230B1D56E9ACAFAA34451BF65FA000F95DF6F0FF5B3A62D83FC2'
assertResultMatch(
computeSignedTransactionHash(
fixtures.tx.OfferCreateSell.result as Transaction,
),
hashSignedTx(fixtures.tx.OfferCreateSell.result as Transaction),
expected_hash,
)
})
@@ -168,7 +162,7 @@ describe('Hashes', function () {
'458101D51051230B1D56E9ACAFAA34451BF65FA000F95DF6F0FF5B3A62D83FC2'
assertResultMatch(
computeSignedTransactionHash(encode(fixtures.tx.OfferCreateSell.result)),
hashSignedTx(encode(fixtures.tx.OfferCreateSell.result)),
expected_hash,
)
})
@@ -180,7 +174,7 @@ describe('Hashes', function () {
}
assert.throws(
() => computeSignedTransactionHash(offerCreateWithNoSignature),
() => hashSignedTx(offerCreateWithNoSignature),
ValidationError,
)
})
@@ -192,7 +186,7 @@ describe('Hashes', function () {
})
assert.throws(
() => computeSignedTransactionHash(encodedOfferCreateWithNoSignature),
() => hashSignedTx(encodedOfferCreateWithNoSignature),
ValidationError,
)
})