Skip to content

Commit

Permalink
fixed timestamp override bug (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Sollis authored Feb 16, 2023
1 parent b124712 commit 912e79e
Showing 1 changed file with 8 additions and 6 deletions.
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

0 comments on commit 912e79e

Please sign in to comment.