supertestnet / swap-service

An orderbook for performing submarine swaps over nostr
https://supertestnet.github.io/swap-service/
Creative Commons Zero v1.0 Universal
46 stars 8 forks source link

Update Usage of bitcoinjs.crypto.sha256 to Accommodate API Change in bitcoinjs-lib #4

Closed dicklarsson closed 5 months ago

dicklarsson commented 5 months ago

Summary This pull request updates the usage of the bitcoinjs.crypto.sha256 function in Swap-Service getSignedEvent to align with the latest API changes in bitcoinjs-lib. The bitcoinjs-lib has altered the expected input type for bitcoinjs.crypto.sha256, leading to issues when a string is passed instead of a Buffer.

Background An issue was identified where the behavior of the bitcoinjs.crypto.sha256 function in bitcoinjs-lib has changed. As documented in bitcoinjs-lib issue #2015, the function now expects a Buffer. The changed happend in bitcoinjs-lib 6.1 The previous implementation in our library, which passed a string to this function, resulted in incorrect outputs.

Changes Modified getSignedEvent function to to use Buffer.from before sending eventData (string) to bitcoinjs.crypto.sha256.

This change should work with the latest version if bitcoinjs-lib as well as with older versions.