Skip to content

Commit 8d84756

Browse files
committed
[ETCM-1096] Transaction Signer skeleton
1 parent a85727d commit 8d84756

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package io.iohk.ethereum.signer
2+
3+
import akka.util.ByteString
4+
5+
import io.iohk.ethereum.crypto.ECDSASignature
6+
import io.iohk.ethereum.domain.Address
7+
import io.iohk.ethereum.domain.LegacyTransaction
8+
import io.iohk.ethereum.domain.SignedTransaction
9+
import io.iohk.ethereum.domain.Transaction
10+
11+
class HomesteadLegacyTransactionSigner extends TransactionSigner[LegacyTransaction] {
12+
override def chainId: BigInt = ???
13+
14+
override def signatureFromBytes(bytes65: ByteString): Option[ECDSASignature] = ???
15+
16+
override def getRAWSignature(signedTransaction: SignedTransaction): Either[SignerError, ECDSASignature] = ???
17+
18+
override def payloadToSign(tx: LegacyTransaction): Either[SignerError, Array[Byte]] = ???
19+
20+
override def calculateSender(signedTransaction: SignedTransaction): Option[Address] = ???
21+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package io.iohk.ethereum.signer
2+
3+
import akka.util.ByteString
4+
5+
import io.iohk.ethereum.crypto.ECDSASignature
6+
import io.iohk.ethereum.domain.Address
7+
import io.iohk.ethereum.domain.SignedTransaction
8+
import io.iohk.ethereum.domain.Transaction
9+
import io.iohk.ethereum.utils.BlockchainConfig
10+
11+
trait TransactionSigner[T <: Transaction] {
12+
def chainId: BigInt
13+
def signatureFromBytes(bytes65: ByteString): Option[ECDSASignature]
14+
def getRAWSignature(signedTransaction: SignedTransaction): Either[SignerError, ECDSASignature]
15+
def payloadToSign(transaction: T): Either[SignerError, Array[Byte]]
16+
def calculateSender(signedTransaction: SignedTransaction): Option[Address]
17+
}
18+
19+
object TransactionSigner {
20+
21+
/** @param blockchainConfig
22+
* @param blockNumber
23+
* @return the proper signer corresponding to the block number
24+
*/
25+
def get(blockchainConfig: BlockchainConfig, blockNumber: BigInt): Signer =
26+
// TODO should we explicitely handle berlin fork ?
27+
if (blockNumber >= blockchainConfig.forkBlockNumbers.magnetoBlockNumber) {
28+
new EIP2930Signer(blockchainConfig.chainId)
29+
} else if (blockNumber >= blockchainConfig.forkBlockNumbers.eip155BlockNumber) {
30+
new EIP155Signer(blockchainConfig.chainId)
31+
} else {
32+
new HomesteadSigner
33+
}
34+
35+
}

0 commit comments

Comments
 (0)