|
|
|
@ -8,15 +8,9 @@ import TrustKeystore |
|
|
|
|
|
|
|
|
|
class CreateRedeem { |
|
|
|
|
|
|
|
|
|
//TODO make for decimal |
|
|
|
|
|
|
|
|
|
private let keyStore = try! EtherKeystore() |
|
|
|
|
|
|
|
|
|
func generateRedeem(ticketIndices: [UInt16], account: Account) -> [Data] { |
|
|
|
|
//TODO remove after testing |
|
|
|
|
let accountTest = keyStore.createAccount(password: "test") |
|
|
|
|
|
|
|
|
|
var messageAndSignature = [Data]() |
|
|
|
|
func generateRedeem(ticketIndices: [UInt16]) -> Data { |
|
|
|
|
var message = [UInt8]() |
|
|
|
|
var timestamp = generateTimeStamp() |
|
|
|
|
let ticketCount = ticketIndices.count * 2 |
|
|
|
@ -25,13 +19,7 @@ class CreateRedeem { |
|
|
|
|
for i in 0...timestamp.count - 1 { |
|
|
|
|
message.append(timestamp[i]) |
|
|
|
|
} |
|
|
|
|
let signature = keyStore.signMessageData(Data(bytes: message), for: accountTest) |
|
|
|
|
messageAndSignature.append(Data(bytes: message)) |
|
|
|
|
try! messageAndSignature.append(signature.dematerialize()) |
|
|
|
|
|
|
|
|
|
print(try! "signature: " + signature.dematerialize().hexString) |
|
|
|
|
|
|
|
|
|
return messageAndSignature |
|
|
|
|
return Data(bytes: message) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func generateTimeStamp() -> [UInt8] { |
|
|
|
|