babylonlabs-io / btc-staking-ts

Other
0 stars 3 forks source link

Combine scripts generation within transaction creation methods #11

Open jrwbabylonlab opened 3 weeks ago

jrwbabylonlab commented 3 weeks ago

Right now the lib very much like a functional programming where creating/signing a staking tx require u call a method to create scripts, then feed into another method for signing etc. This has its own downside as the important variables are being passed around which is less secure and prone to bugs with limited validations in place.

The scope of this issue is to have a think about the above problem and assess whether we need a new design for this lib

Recommendation:

jrwbabylonlab commented 3 weeks ago

Once the improvement is done, it would also resolve below issue out of the box:

Seems like (publicKeyNoCoord)[https://github.com/babylonlabs-io/btc-staking-ts/blob/dev/src/index.ts#L67] is the stakerkey
when using taproot mode of the wallet. There is no check that this key and key in provided scripts matches.

and

There is no check that the op_return (https://github.com/babylonlabs-io/btc-staking-ts/blob/dev/src/index.ts#L60),
is in fact op_return recognised by Babylon and contains the same data that in included in scripts.
jrwbabylonlab commented 3 weeks ago

also linking another issue which i believe will be addressed as part of this refactoring https://github.com/babylonlabs-io/btc-staking-ts/issues/9