mirror of
https://github.com/status-im/keycard-connect.git
synced 2025-01-10 02:55:58 +00:00
eip-155 signing
This commit is contained in:
parent
8981c705cf
commit
078c6bea16
@ -68,7 +68,7 @@ dependencies {
|
||||
implementation "com.github.komputing.kethereum:model:$kethereum_version"
|
||||
implementation "com.github.komputing.kethereum:functions:$kethereum_version"
|
||||
implementation "com.github.komputing.kethereum:rpc:$kethereum_version"
|
||||
implementation "com.github.komputing.kethereum:rlp:$kethereum_version"
|
||||
implementation "com.github.komputing.kethereum:keccak_shortcut:$kethereum_version"
|
||||
implementation 'com.github.komputing:khex:0.6'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||
|
@ -16,12 +16,11 @@ import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.launch
|
||||
import okhttp3.OkHttpClient
|
||||
import org.bouncycastle.jcajce.provider.digest.Keccak
|
||||
import org.kethereum.DEFAULT_GAS_LIMIT
|
||||
import org.kethereum.extensions.maybeHexToBigInteger
|
||||
import org.kethereum.extensions.toBigInteger
|
||||
import org.kethereum.functions.calculateHash
|
||||
import org.kethereum.functions.encodeRLP
|
||||
import org.kethereum.keccakshortcut.keccak
|
||||
import org.kethereum.model.*
|
||||
import org.walletconnect.Session
|
||||
import org.walletconnect.Session.Config.Companion.fromWCUri
|
||||
@ -120,8 +119,7 @@ class WalletConnect : ExportKeyCommand.Listener, SignCommand.Listener, Session.C
|
||||
|
||||
requestId = id
|
||||
uiAction = {
|
||||
val keccak256 = Keccak.Digest256()
|
||||
val hash = keccak256.digest(byteArrayOf(0x19) + "Ethereum Signed Message:\n${msg.size}".toByteArray() + msg)
|
||||
val hash = (byteArrayOf(0x19) + "Ethereum Signed Message:\n${msg.size}".toByteArray() + msg).keccak()
|
||||
Registry.scriptExecutor.runScript(scriptWithAuthentication().plus(SignCommand(Registry.walletConnect, hash)))
|
||||
}
|
||||
|
||||
@ -143,13 +141,13 @@ class WalletConnect : ExportKeyCommand.Listener, SignCommand.Listener, Session.C
|
||||
requestId = id
|
||||
|
||||
uiAction = {
|
||||
val hash = tx.calculateHash()
|
||||
val hash = tx.encodeRLP(SignatureData(v = chainID.toBigInteger())).keccak()
|
||||
Registry.scriptExecutor.runScript(scriptWithAuthentication().plus(SignCommand(Registry.walletConnect, hash)))
|
||||
}
|
||||
|
||||
signAction = {
|
||||
try {
|
||||
val signedTx = SignedTransaction(tx, SignatureData(it.r.toBigInteger(), it.s.toBigInteger(), (it.recId + 27).toBigInteger())).encodeRLP().toHexString()
|
||||
val signedTx = SignedTransaction(tx, SignatureData(it.r.toBigInteger(), it.s.toBigInteger(), (it.recId + (chainID * 2) + 35).toBigInteger())).encodeRLP().toHexString()
|
||||
val res = if (send) Registry.ethereumRPC.ethSendRawTransaction(signedTx) else signedTx
|
||||
session?.approveRequest(requestId, res)
|
||||
} catch(e: Exception) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user