Skip to content

Commit

Permalink
feat: support rekeyed signing with kmd (#121)
Browse files Browse the repository at this point in the history
* feat: support rekeyed signing with kmd

* chore: remove console.log
  • Loading branch information
drichar authored Nov 29, 2023
1 parent f0b2b0a commit e09b7b5
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/clients/kmd/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,29 @@ class KMDWalletClient extends BaseClient {
return
}
// Not to be signed by our signer, skip it
else if (!connectedAccounts.includes(this.algosdk.encodeAddress(dtxn.snd))) {
return
else {
const senderAddress = this.algosdk.encodeAddress(dtxn.snd)
const rekeyAddress = dtxn.rekey ? this.algosdk.encodeAddress(dtxn.rekey) : null

const isSignerConnected = rekeyAddress
? connectedAccounts.includes(rekeyAddress) && connectedAccounts.includes(senderAddress)
: connectedAccounts.includes(senderAddress)

if (!isSignerConnected) {
return
}
}

// overwrite with an empty blob
signedTxns[idx] = new Uint8Array()

const txn = this.algosdk.Transaction.from_obj_for_encoding(dtxn)
signingPromises.push(this.#client.signTransaction(token, pw, txn) as Promise<Uint8Array>)

const promise = txn.reKeyTo
? this.#client.signTransactionWithSpecificPublicKey(token, pw, txn, txn.reKeyTo.publicKey)
: this.#client.signTransaction(token, pw, txn)

signingPromises.push(promise as Promise<Uint8Array>)
})

const signingResults = await Promise.all(signingPromises)
Expand Down

0 comments on commit e09b7b5

Please sign in to comment.