bitcoinjs / bitcoinjs-lib

A javascript Bitcoin library for node.js and browsers.
MIT License
5.6k stars 2.08k forks source link

PSBT file refactoring #1993

Open jasonandjay opened 8 months ago

jasonandjay commented 8 months ago

Background: The PSBT file contains over 2200 lines of code, too many for readers or maintainers. I think it's necessary to refactor it. Do we have plans to separate bip371 from bitcoinjs-lib? Maybe deep dependencies with the taproot are not easily detachable. Another way to handle this situation is to simply split psbt into psbt_interface, psbt_helper and psbt_transaction under the ts_src/psbt folder.

I prefer the last solution, other suggestions are welcome.

junderw commented 8 months ago
  1. I feel like we have a lot of things that aren't publicly exposed that are almost necessary to use taproot. A big smell in that area is the fact that we use a lot of submodule imports in the taproot integration test... In theory integration tests should only use public facing API of the library, but we break that rule often. So some of these functions should be made public. Not sure if that warrants a separate library, but definitely a separate module.
  2. Psbt split into multiple files seems OK. Whatever makes sense. Getting it fully documented is higher priority though, but if refactoring makes that easier then by all means.
jasonandjay commented 8 months ago

I agree, so we can make a TODO