paulmillr / scure-btc-signer

Audited & minimal library for creating, signing & decoding Bitcoin transactions.
https://paulmillr.com/noble/#scure
MIT License
158 stars 41 forks source link

Sign unknown inputs #85

Closed Mister-EA closed 7 months ago

Mister-EA commented 7 months ago

When the script type is unknown the current version of the library does not try to sign the input. In this PR the input is signed by placing the signature and public key in the input script. This is the best attempt to sign. If the input is segwit then the signature will be placed in the final witness, and if it is P2SH the signature will be placed in the sigscript.

paulmillr commented 7 months ago

tests are failin

Mister-EA commented 7 months ago

@paulmillr pls can you check again?

paulmillr commented 7 months ago

I guess this superseeds it? https://github.com/paulmillr/scure-btc-signer/releases/tag/1.3.0

Mister-EA commented 6 months ago

I don't think the v.1.3.0 release implements this feature, as I don't see it making use of the input.partialSig[0][1] and input.partialSig[0][0]] values for unknown scripts in the finalizeIdx function.

paulmillr commented 6 months ago

It is exactly what it does, but for taproot only. You can now add script parser (see micro-ordinals), which will have finalizeTaproot for your custom script

Mister-EA commented 6 months ago

My use case is a wsh-unknown script , which is not currently supported. Any chance this script type might be supported as well?

paulmillr commented 6 months ago

Why should it follow your code and not some other logic? It can work in "any" way if i'm not mistaken

Mister-EA commented 6 months ago

Well, then there must be a way to support the redeeming witness creation based on the signature , public key and potentially other data. If the Bitcoin scripting language allows for arbitrary locking script creation, then shouldn't the library here also support arbitrary unlocking script creation?

If that's not so easy to implement at this stage, then the best attempt to unlock seems to be placing the signature and public key in front of the script.