fix redeem code so it sends back message instead of being signed

pull/37/head
James Sangalli 7 years ago
parent ccab806d23
commit 10b7d36dbd
  1. 16
      Trust/Redeem/CreateRedeem.swift
  2. 4
      TrustTests/Redeem/CreateRedeemTests.swift

@ -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] {

@ -15,7 +15,9 @@ class CreateRedeemTests: XCTestCase {
indices.append(2)
let account = keyStore.createAccount(password: "test")
XCTAssertNoThrow(CreateRedeem.init().generateRedeem(
ticketIndices: indices, account: account))
ticketIndices: indices))
let data = CreateRedeem.init().generateRedeem(ticketIndices: indices)
print(try! keyStore.signMessageData(data, for: account).dematerialize().hexString)
}
}
Loading…
Cancel
Save