-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcapture.go
More file actions
39 lines (32 loc) · 968 Bytes
/
capture.go
File metadata and controls
39 lines (32 loc) · 968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package tap
import (
"encoding/json"
"fmt"
didcomm "github.com/Notabene-id/go-didcomm"
"github.com/google/uuid"
)
// CaptureBody represents the body of a TAP Capture message (TAIP-17).
type CaptureBody struct {
Context string `json:"@context"`
Type string `json:"@type"`
Amount string `json:"amount,omitempty"`
SettlementAddress string `json:"settlementAddress,omitempty"`
}
func (b *CaptureBody) TAPType() string { return TypeCapture }
// NewCaptureMessage creates a new DIDComm message with a Capture body.
func NewCaptureMessage(from string, to []string, thid string, body *CaptureBody) (*didcomm.Message, error) {
body.Context = TAPContext
body.Type = TypeCapture
rawBody, err := json.Marshal(body)
if err != nil {
return nil, fmt.Errorf("marshal body: %w", err)
}
return &didcomm.Message{
ID: uuid.New().String(),
Type: TypeCapture,
From: from,
To: to,
Thid: thid,
Body: rawBody,
}, nil
}