-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API for directly adding signatures to transactions #161
Conversation
* Add a signature to the transaction. Useful when a party wants to pre-sign | ||
* a transaction but doesn't want to give access to their secret keys. | ||
* @param {string} publicKey The public key of the signer | ||
* @param {string} signature The base64 value of the signature XDR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it doesn't work with base64 encoded signatures. Tests seem to add byte arrays instead of b64 encoded strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, should be fixed now!
src/transaction.js
Outdated
|
||
try { | ||
hint = Keypair.fromPublicKey(publicKey).signatureHint(); | ||
console.log('calculated hint: ', hint); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove console.log
.
@bartekn Now that I think about this... I'm not sure the method I employed is going to work because the pre-signer would need to guess the user's next sequence number. The docs mention a different strategy for pre-signing a transaction: I'm guessing that's already implemented in the JS SDK, if Stellar Lab already implements it? If that's the case, can we close this PR without merging since the use case we're trying to solve already has a solution? |
Preauthorized transaction signer is a different thing. It's basically a transaction that unlocks the account. For example, you can design bonds using preauthorized transactions:
What we want to do in this PR is something like: You and me have a shared account, I sign a transaction and send it to you, you sign it and send a signature back, I add a signature using the method in this PR. I agree that this is kind of redundant, because instead of sending me a signature you could send me a full transaction that I can later import and use |
@bartekn So does it seem like this PR will accomplish the use case you described? The documentation (898096d#diff-42d8d2088a96641b563b25ad908b0c0f) should describe how end-users can use this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bartekn this looks good to me. Any more thoughts before Morley merges it in?
Hi I see you work with adding signatures to an existing XDR. I have a special interest to let a third party sign the transaction without passing the transaction as XDR. I heard it should be possible just to hand over the transaction-hash, let this get signed and add the signature to the XDR. What is your view on this is this possible? If yes, an example would be awesome. Thanks. |
Hi, the following should do it
Once you get back the signature, you can append it to the transaction
Also, https://stellar.stackexchange.com/ might be a better place for this kind of questions. |
Transaction.prototype.addSignature(publicKey: string, signature: string)
andTransaction.prototype.getKeypairSIgnature(keypair: Keypair)
to allow, for example, parties to pre-sign their part of multi-signature transactions (fixes Add signatures to transaction builder #109)