Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed timestamp override bug #118

Merged
merged 2 commits into from
Feb 16, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions pkg/rvasp/trisa.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func NewTRISA(parent *Server) (svc *TRISA, err error) {
return svc, nil
}

// Serve initializes the GRPC server and returns any errors during intitialization, it
// Serve initializes the GRPC server and returns any errors during initialization, it
// then kicks off a go routine to handle requests. Not thread safe, should not be called
// multiple times.
func (s *TRISA) Serve() (err error) {
Expand Down Expand Up @@ -492,7 +492,9 @@ func (s *TRISA) respondTransfer(in *protocol.SecureEnvelope, peer *peers.Peer, i

// Update the transaction with beneficiary information
transaction.Beneficiary = account.WalletAddress
transaction.Timestamp = time.Now().Format(time.RFC3339)
if transaction.Timestamp == "" {
transaction.Timestamp = time.Now().Format(time.RFC3339)
}

var xferBytes []byte
if xferBytes, err = protojson.Marshal(identity); err != nil {
Expand All @@ -510,7 +512,7 @@ func (s *TRISA) respondTransfer(in *protocol.SecureEnvelope, peer *peers.Peer, i
return nil, protocol.Errorf(protocol.InternalError, "request could not be processed")
}

msg := fmt.Sprintf("ready for transaction %04d: %s transfering from %s to %s", xfer.ID, xfer.Amount, xfer.Originator.WalletAddress, xfer.Beneficiary.WalletAddress)
msg := fmt.Sprintf("ready for transaction %04d: %s transferring from %s to %s", xfer.ID, xfer.Amount, xfer.Originator.WalletAddress, xfer.Beneficiary.WalletAddress)
s.parent.updates.Broadcast(0, msg, pb.MessageCategory_BLOCKCHAIN)

// Encode and encrypt the payload information to return the secure envelope
Expand Down Expand Up @@ -791,7 +793,7 @@ func (s *TRISA) sendAsync(tx *db.Transaction) (err error) {
return fmt.Errorf("could not save beneficiary account: %s", err)
}

msg := fmt.Sprintf("ready for transaction %s: %.2f transfering from %s to %s", transaction.Txid, transaction.Amount, transaction.Originator, transaction.Beneficiary)
msg := fmt.Sprintf("ready for transaction %s: %.2f transferring from %s to %s", transaction.Txid, transaction.Amount, transaction.Originator, transaction.Beneficiary)
s.parent.updates.Broadcast(0, msg, pb.MessageCategory_BLOCKCHAIN)
tx.SetState(pb.TransactionState_COMPLETED)
default:
Expand Down Expand Up @@ -881,15 +883,15 @@ func (s *TRISA) KeyExchange(ctx context.Context, in *protocol.SigningKey) (out *

if err = peer.UpdateSigningKey(pub); err != nil {
log.Error().Err(err).Msg("could not update signing key")
return nil, protocol.Errorf(protocol.UnhandledAlgorithm, "unsuported signing algorithm")
return nil, protocol.Errorf(protocol.UnhandledAlgorithm, "unsupported signing algorithm")
}

// TODO: check not before and not after constraints

// TODO: Kick off a go routine to store the key in the database

// Return the public signing-key of the service
// TODO: use separate signing key insead of using public key of mTLS certs
// TODO: use separate signing key instead of using public key of mTLS certs
var key *x509.Certificate
if key, err = s.certs.GetLeafCertificate(); err != nil {
log.Warn().Err(err).Msg("could not extract leaf certificate")
Expand Down