stellar / js-stellar-base

The lowest-level stellar helper library. It consists of classes to read, write, hash, and sign Stellar xdr
https://stellar.github.io/js-stellar-base/
Apache License 2.0
107 stars 137 forks source link

Add signatures to transaction builder #109

Closed bartekn closed 5 years ago

bartekn commented 7 years ago

Add a method to TransactionBuilder that will add existing signatures to the transaction. This will be helpful for multi-signature transactions, so one of the parties can provide a signature to be injected in a different session. Thanks @brahman81 for suggesting it.

morleyzhi commented 5 years ago

@bartekn @brahman81 Is there a reason people can't just call TransactionObject.sign()? I could be wrong but from looking at the code, the signatures have to include a hashed version of the transaction, which includes the min/max times. It seems unlikely that a dev would have access to that beforehand. And in that case, it seems easier for a person to use TransactionObject.sign() than to try to recreate all the signing logic themselves.

morleyzhi commented 5 years ago

I just can't see how pre-formed signatures will work with the new system of transaction timebounds, so I'm going to close this issue until a solution presents itself. Feel free to re-open!

bartekn commented 5 years ago

This is for multisignature accounts specifically. Imagine that there is a second signer that generated a signature for a single transaction. Then the signer sends it to you. You should be able to append a new signature to the transaction.

You can't use sign() in this case because a second signer would need to send you their secret key.

morleyzhi commented 5 years ago

Cool, that makes sense!