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

SC-8140 Add fields to pending payload #110

Merged
merged 1 commit into from
Aug 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
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