Skip to content

Commit

Permalink
Populate fields in pending payload (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdeziel authored Aug 12, 2022
1 parent a85fca6 commit dd7e6d6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/rvasp/rvasp.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ func (s *Server) sendTransfer(xfer *db.Transaction, beneficiary *db.Wallet, part

var beneficiaryAccount db.Account
if partial {
// If partial is specified then only populate the benefiiary address
// If partial is specified then only populate the beneficiary address
beneficiaryAccount = db.Account{
WalletAddress: beneficiary.Address,
}
Expand Down
10 changes: 7 additions & 3 deletions pkg/rvasp/trisa.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,11 +411,11 @@ func (s *TRISA) handleTransaction(ctx context.Context, peer *peers.Peer, in *pro
case db.AsyncRepair:
// Respond to the transfer request with a pending message and mark the
// transaction for later service. The beneficiary information is filled in.
out, transferError = s.respondPending(in, peer, identity, transaction, xfer, account)
out, transferError = s.respondPending(in, peer, identity, transaction, xfer, account, policy)
case db.AsyncReject:
// Respond to the transfer request with a pending message that will be later
// rejected.
out, transferError = s.respondPending(in, peer, identity, transaction, xfer, account)
out, transferError = s.respondPending(in, peer, identity, transaction, xfer, account, policy)
default:
return nil, protocol.Errorf(protocol.InternalError, "unknown policy '%s' for wallet '%s'", policy, account.WalletAddress)
}
Expand Down Expand Up @@ -552,7 +552,7 @@ func (s *TRISA) respondTransfer(in *protocol.SecureEnvelope, peer *peers.Peer, i

// respondPending responds to a transfer request from the originator by returning a
// pending message and saving the pending transaction in the database.
func (s *TRISA) respondPending(in *protocol.SecureEnvelope, peer *peers.Peer, identity *ivms101.IdentityPayload, transaction *generic.Transaction, xfer *db.Transaction, account db.Account) (out *protocol.SecureEnvelope, transferError *protocol.Error) {
func (s *TRISA) respondPending(in *protocol.SecureEnvelope, peer *peers.Peer, identity *ivms101.IdentityPayload, transaction *generic.Transaction, xfer *db.Transaction, account db.Account, policy db.PolicyType) (out *protocol.SecureEnvelope, transferError *protocol.Error) {
now := time.Now()

xfer.NotBefore = now.Add(s.parent.conf.AsyncNotBefore)
Expand Down Expand Up @@ -610,8 +610,12 @@ func (s *TRISA) respondPending(in *protocol.SecureEnvelope, peer *peers.Peer, id
// Create a pending protocol message with NotBefore and NotAfter timestamps
pending := &generic.Pending{
EnvelopeId: xfer.Envelope,
ReceivedBy: s.parent.vasp.Name + " (Robot VASP)",
ReceivedAt: time.Now().Format(time.RFC3339),
Message: fmt.Sprintf("You have initiated an asynchronous transfer with a robot VASP using the %s policy", policy),
ReplyNotBefore: xfer.NotBefore.Format(time.RFC3339),
ReplyNotAfter: xfer.NotAfter.Format(time.RFC3339),
Transaction: transaction,
}

var payload *protocol.Payload
Expand Down

0 comments on commit dd7e6d6

Please sign in to comment.