Bitshala-Incubator / silent-pay

a TS library for silent payments
MIT License
8 stars 10 forks source link

Add `getPublicKeyFromOutput()` to `Transaction` class #12

Closed theanmolsharma closed 6 months ago

theanmolsharma commented 7 months ago

Add the following function to Transaction class

getPublicKeyFromOutput(index: number): Buffer | null {}

This function should extract the public key from the output script. The following output script types contain public key in script:

For all other script types, the function should return null.

rajarshimaitra commented 7 months ago

For all other script types, the function should throw an error.

This seems like an Option case than a Error case, as most other script types won't hold SPs. Is there a way to do Options in JS?

theanmolsharma commented 7 months ago

For all other script types, the function should throw an error.

This seems like an Option case than a Error case, as most other script types won't hold SPs. Is there a way to do Options in JS?

I think we can set the return type to Buffer | null