File tree Expand file tree Collapse file tree 2 files changed +4
-1
lines changed
Expand file tree Collapse file tree 2 files changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -258,6 +258,9 @@ export class Indexer {
258258 if ( ! block . transactions || block . transactions . length === 0 ) {
259259 return null ;
260260 }
261+ // NOTE: The `merkletreejs` library expects its input leaves to be in big-endian format.
262+ // However, `tx.getHash()` from `bitcoinjs-lib` returns the little-endian format used by the Bitcoin protocol.
263+ // We must reverse each hash to convert it to big-endian before creating the tree.
261264 const leaves = block . transactions . map ( ( tx ) => Buffer . from ( tx . getHash ( ) ) . reverse ( ) ) ;
262265 return new MerkleTree ( leaves , SHA256 , { isBitcoinTree : true } ) ;
263266 }
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ export class SuiClient {
4343 const target = `${ this . nbtcPkg } ::${ this . nbtcModule } ::mint` as const ;
4444 const serializedTx = serializeBtcTx ( transaction ) ;
4545
46- // NOTE: the contract is expecting the proofs to be in big -endian format, while the bitcon-js lib operates internally on little -endian.
46+ // NOTE: the contract is expecting the proofs to be in little -endian format, while the merkletreejs lib operates internally on big -endian.
4747 const proofBigEndian = proof . proofPath . map ( ( p ) => Array . from ( Buffer . from ( p ) . reverse ( ) ) ) ;
4848
4949 tx . moveCall ( {
You can’t perform that action at this time.
0 commit comments