Created
February 12, 2022 07:16
-
-
Save dimitardanailov/e9f44a5e6335202106d577c5b3811e8f to your computer and use it in GitHub Desktop.
Algorand sign transaction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
signTxn(sk: Uint8Array) { | |
// construct signed message | |
const sTxn: EncodedSignedTransaction = { | |
sig: this.rawSignTxn(sk), | |
txn: this.get_obj_for_encoding(), | |
}; | |
// add AuthAddr if signing with a different key than From indicates | |
const keypair = nacl.keyPairFromSecretKey(sk); | |
const pubKeyFromSk = keypair.publicKey; | |
if ( | |
address.encodeAddress(pubKeyFromSk) !== | |
address.encodeAddress(this.from.publicKey) | |
) { | |
sTxn.sgnr = Buffer.from(pubKeyFromSk); | |
} | |
return new Uint8Array(encoding.encode(sTxn)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment