Skip to content

Commit f0f37c8

Browse files
authored
Merge pull request #8264 from BitGo/cecho-333
feat(sdk-coin-tempo): add getSenderAddress to Tip20Transaction
2 parents e1378ac + 84062df commit f0f37c8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

modules/sdk-coin-tempo/src/lib/transaction.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,24 @@ export class Tip20Transaction extends BaseTransaction {
211211
return this._signature;
212212
}
213213

214+
/**
215+
* Recover the signer address from the transaction signature.
216+
* @returns Checksummed sender address, or undefined if unsigned
217+
*/
218+
getSenderAddress(): string | undefined {
219+
if (!this._signature) {
220+
return undefined;
221+
}
222+
223+
const unsignedHex = this.serializeTransaction();
224+
const msgHash = ethers.utils.keccak256(ethers.utils.arrayify(unsignedHex));
225+
return ethers.utils.recoverAddress(msgHash, {
226+
r: this._signature.r,
227+
s: this._signature.s,
228+
recoveryParam: this._signature.yParity,
229+
});
230+
}
231+
214232
toJson(): TxData {
215233
return {
216234
type: this.txRequest.type,

0 commit comments

Comments
 (0)