Skip to content

Commit 627e5ee

Browse files
Rename Asset to Instrument.
1 parent a48d2b4 commit 627e5ee

File tree

5 files changed

+46
-46
lines changed

5 files changed

+46
-46
lines changed

bsvalias/bsvalias.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ const (
3535
// capability.
3636
URLNameP2PTransactions = "5f1323cddf31"
3737

38-
// URLNameListTokenizedAssetAlias is the name used to identify the list Tokenized asset alias
38+
// URLNameListTokenizedInstrumentAlias is the name used to identify the list Tokenized instrument alias
3939
// URL and capability.
40-
URLNameListTokenizedAssetAlias = "e243785d1f17"
40+
URLNameListTokenizedInstrumentAlias = "e243785d1f17"
4141
)
4242

4343
var (
@@ -76,12 +76,12 @@ type Client interface {
7676
GetPaymentDestination(ctx context.Context, senderName, senderHandle, purpose string,
7777
amount uint64, senderKey *bitcoin.Key) (bitcoin.Script, error)
7878

79-
// GetPaymentRequest requests a payment request that can be used to send bitcoin or an asset.
79+
// GetPaymentRequest requests a payment request that can be used to send bitcoin or an instrument.
8080
// senderHandle is required.
81-
// assetID can be empty or "BSV" to request bitcoin.
81+
// instrumentID can be empty or "BSV" to request bitcoin.
8282
// If senderKey is not nil then it must be associated with senderHandle and will be used to add
8383
// a signature to the request.
84-
GetPaymentRequest(ctx context.Context, senderName, senderHandle, purpose, assetID string,
84+
GetPaymentRequest(ctx context.Context, senderName, senderHandle, purpose, instrumentID string,
8585
amount uint64, senderKey *bitcoin.Key) (*PaymentRequest, error)
8686

8787
// GetP2PPaymentDestination requests a peer to peer payment destination.
@@ -94,6 +94,6 @@ type Client interface {
9494
PostP2PTransaction(ctx context.Context, senderHandle, note, reference string,
9595
senderKey *bitcoin.Key, tx *wire.MsgTx) (string, error)
9696

97-
// ListTokenizedAssets returns the list of asset aliases for this paymail handle.
98-
ListTokenizedAssets(ctx context.Context) ([]AssetAlias, error)
97+
// ListTokenizedInstruments returns the list of instrument aliases for this paymail handle.
98+
ListTokenizedInstruments(ctx context.Context) ([]InstrumentAlias, error)
9999
}

bsvalias/bsvalias_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func TestPaymentRequest(t *testing.T) {
183183
}
184184
}
185185

186-
func TestAssetAlias(t *testing.T) {
186+
func TestInstrumentAlias(t *testing.T) {
187187
ctx := context.Background()
188188

189189
for _, handle := range handles {
@@ -192,7 +192,7 @@ func TestAssetAlias(t *testing.T) {
192192
t.Fatalf("Failed to get identity : %s", err)
193193
}
194194

195-
request, err := id.ListTokenizedAssets(ctx)
195+
request, err := id.ListTokenizedInstruments(ctx)
196196
if err != nil {
197197
if errors.Cause(err) == ErrNotCapable {
198198
t.Logf("Payment Request Not Supported")
@@ -201,8 +201,8 @@ func TestAssetAlias(t *testing.T) {
201201
t.Fatalf("Failed to get payment request : %s", err)
202202
}
203203

204-
for _, asset := range request {
205-
t.Logf("Asset alias %s : %s", asset.AssetAlias, asset.AssetID)
204+
for _, instrument := range request {
205+
t.Logf("Instrument alias %s : %s", instrument.InstrumentAlias, instrument.InstrumentID)
206206
}
207207
}
208208
}
@@ -232,7 +232,7 @@ func TestBRFCID(t *testing.T) {
232232
}
233233
t.Logf("Payment Request BRFC ID : %s", hash.String()[:12])
234234

235-
// Our payment request transaction BRFC ID
235+
// Our asset alias BRFC ID
236236
title = "List Tokenized Asset Alias"
237237
author = "Jonathan Vaage (Tokenized)"
238238
version = "1"
@@ -242,7 +242,7 @@ func TestBRFCID(t *testing.T) {
242242
if hash.String()[:12] != "e243785d1f17" {
243243
t.Fatalf("Invalid ID : got %s, want %s", hash.String()[:12], "e243785d1f17")
244244
}
245-
t.Logf("List Asset Alias BRFC ID : %s", hash.String()[:12])
245+
t.Logf("List Instrument Alias BRFC ID : %s", hash.String()[:12])
246246
}
247247

248248
func TestMessageSignature(t *testing.T) {

bsvalias/http.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,11 @@ func (c *HTTPClient) GetPaymentDestination(ctx context.Context, senderName, send
137137

138138
// GetPaymentRequest gets a payment request from the identity.
139139
// senderHandle is required.
140-
// assetID can be empty or "BSV" to request bitcoin.
140+
// instrumentID can be empty or "BSV" to request bitcoin.
141141
// If senderKey is not nil then it must be associated with senderHandle and will be used to add a
142142
// signature to the request.
143143
func (c *HTTPClient) GetPaymentRequest(ctx context.Context, senderName, senderHandle, purpose,
144-
assetID string, amount uint64, senderKey *bitcoin.Key) (*PaymentRequest, error) {
144+
instrumentID string, amount uint64, senderKey *bitcoin.Key) (*PaymentRequest, error) {
145145

146146
url, err := c.Site.Capabilities.GetURL(URLNamePaymentRequest)
147147
if err != nil {
@@ -152,13 +152,13 @@ func (c *HTTPClient) GetPaymentRequest(ctx context.Context, senderName, senderHa
152152
SenderName: senderName,
153153
SenderHandle: senderHandle,
154154
DateTime: time.Now().UTC().Format("2006-01-02T15:04:05.999Z"),
155-
AssetID: assetID,
155+
InstrumentID: instrumentID,
156156
Amount: amount,
157157
Purpose: purpose,
158158
}
159159

160160
if senderKey != nil {
161-
sigHash, err := SignatureHashForMessage(request.SenderHandle + request.AssetID +
161+
sigHash, err := SignatureHashForMessage(request.SenderHandle + request.InstrumentID +
162162
strconv.FormatUint(request.Amount, 10) + request.DateTime + request.Purpose)
163163
if err != nil {
164164
return nil, errors.Wrap(err, "signature hash")
@@ -297,22 +297,22 @@ func (c *HTTPClient) PostP2PTransaction(ctx context.Context, senderHandle, note,
297297
return response.Note, nil
298298
}
299299

300-
// ListTokenizedAssets returns the list of asset aliases for this paymail handle.
301-
func (c *HTTPClient) ListTokenizedAssets(ctx context.Context) ([]AssetAlias, error) {
302-
url, err := c.Site.Capabilities.GetURL(URLNameListTokenizedAssetAlias)
300+
// ListTokenizedInstruments returns the list of instrument aliases for this paymail handle.
301+
func (c *HTTPClient) ListTokenizedInstruments(ctx context.Context) ([]InstrumentAlias, error) {
302+
url, err := c.Site.Capabilities.GetURL(URLNameListTokenizedInstrumentAlias)
303303
if err != nil {
304304
return nil, errors.Wrap(err, "capability url")
305305
}
306306

307307
url = strings.ReplaceAll(url, "{alias}", c.Alias)
308308
url = strings.ReplaceAll(url, "{domain.tld}", c.Hostname)
309309

310-
var response AssetAliasListResponse
310+
var response InstrumentAliasListResponse
311311
if err := get(ctx, url, &response); err != nil {
312312
return nil, errors.Wrap(err, "http get")
313313
}
314314

315-
return response.AssetAliases, nil
315+
return response.InstrumentAliases, nil
316316
}
317317

318318
// post sends a request to the HTTP server using the POST method.

bsvalias/models.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,15 @@ type PaymentRequestRequest struct {
166166
SenderName string `json:"senderName"`
167167
SenderHandle string `json:"senderHandle"`
168168
DateTime string `json:"dt"`
169-
AssetID string `json:"assetID"`
169+
InstrumentID string `json:"instrumentID"`
170170
Amount uint64 `json:"amount"`
171171
Purpose string `json:"purpose"`
172172
Signature string `json:"signature"`
173173
}
174174

175175
// Sign adds a signature to the request. The key should correspond to the sender handle's PKI.
176176
func (r *PaymentRequestRequest) Sign(key bitcoin.Key) error {
177-
sigHash, err := SignatureHashForMessage(r.SenderHandle + r.AssetID +
177+
sigHash, err := SignatureHashForMessage(r.SenderHandle + r.InstrumentID +
178178
strconv.FormatUint(r.Amount, 10) + r.DateTime + r.Purpose)
179179
if err != nil {
180180
return errors.Wrap(err, "signature hash")
@@ -190,7 +190,7 @@ func (r *PaymentRequestRequest) Sign(key bitcoin.Key) error {
190190
}
191191

192192
func (r PaymentRequestRequest) CheckSignature(publicKey bitcoin.PublicKey) error {
193-
sigHash, err := SignatureHashForMessage(r.SenderHandle + r.AssetID +
193+
sigHash, err := SignatureHashForMessage(r.SenderHandle + r.InstrumentID +
194194
strconv.FormatUint(r.Amount, 10) + r.DateTime + r.Purpose)
195195
if err != nil {
196196
return errors.Wrap(err, "signature hash")
@@ -220,11 +220,11 @@ type PaymentRequest struct {
220220
Outputs []*wire.TxOut
221221
}
222222

223-
type AssetAliasListResponse struct {
224-
AssetAliases []AssetAlias `json:"asset_aliases"`
223+
type InstrumentAliasListResponse struct {
224+
InstrumentAliases []InstrumentAlias `json:"instrument_aliases"`
225225
}
226226

227-
type AssetAlias struct {
228-
AssetAlias string `json:"asset_alias"`
229-
AssetID string `json:"asset_id"`
227+
type InstrumentAlias struct {
228+
InstrumentAlias string `json:"instrument_alias"`
229+
InstrumentID string `json:"instrument_id"`
230230
}

bsvalias/test_helpers.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ func (f *MockFactory) NewClient(ctx context.Context, handle string) (Client, err
3737

3838
// mockUser is a mock user for testing systems that use paymail.
3939
type mockUser struct {
40-
handle string
41-
identityKey bitcoin.Key
42-
addressKey bitcoin.Key
43-
p2pTxs map[string][]*wire.MsgTx
44-
assetAliases []AssetAlias
40+
handle string
41+
identityKey bitcoin.Key
42+
addressKey bitcoin.Key
43+
p2pTxs map[string][]*wire.MsgTx
44+
instrumentAliases []InstrumentAlias
4545
}
4646

4747
// AddMockUser adds a new mock user.
@@ -55,15 +55,15 @@ func (f *MockFactory) AddMockUser(handle string, identityKey, addressKey bitcoin
5555
}
5656

5757
// AddMockUser adds a new mock user.
58-
func (f *MockFactory) AddMockAsset(handle string, assetAlias, assetID string) {
58+
func (f *MockFactory) AddMockInstrument(handle string, instrumentAlias, instrumentID string) {
5959
for _, user := range f.users {
6060
if user.handle != handle {
6161
continue
6262
}
6363

64-
user.assetAliases = append(user.assetAliases, AssetAlias{
65-
AssetAlias: assetAlias,
66-
AssetID: assetID,
64+
user.instrumentAliases = append(user.instrumentAliases, InstrumentAlias{
65+
InstrumentAlias: instrumentAlias,
66+
InstrumentID: instrumentID,
6767
})
6868
return
6969
}
@@ -126,11 +126,11 @@ func (c *MockClient) GetPaymentDestination(ctx context.Context, senderName, send
126126

127127
// GetPaymentRequest gets a payment request from the identity.
128128
// senderHandle is required.
129-
// assetID can be empty or "BSV" to request bitcoin.
129+
// instrumentID can be empty or "BSV" to request bitcoin.
130130
// If senderKey is not nil then it must be associated with senderHandle and will be used to add
131131
// a signature to the request.
132132
func (c *MockClient) GetPaymentRequest(ctx context.Context, senderName, senderHandle, purpose,
133-
assetID string, amount uint64, senderKey *bitcoin.Key) (*PaymentRequest, error) {
133+
instrumentID string, amount uint64, senderKey *bitcoin.Key) (*PaymentRequest, error) {
134134

135135
ra, err := c.user.addressKey.RawAddress()
136136
if err != nil {
@@ -144,10 +144,10 @@ func (c *MockClient) GetPaymentRequest(ctx context.Context, senderName, senderHa
144144

145145
tx := wire.NewMsgTx(1)
146146

147-
if assetID == "BSV" {
147+
if instrumentID == "BSV" {
148148
tx.AddTxOut(wire.NewTxOut(amount, script))
149149
} else {
150-
// Note: requires contract address of asset and possibly access to mock identity oracle
150+
// Note: requires contract address of instrument and possibly access to mock identity oracle
151151
// client.
152152
return nil, errors.Wrap(ErrNotCapable, "not implemented in mock client")
153153
}
@@ -214,7 +214,7 @@ func (c *MockClient) CheckP2PTx(txid bitcoin.Hash32) error {
214214
return errors.New("Not posted")
215215
}
216216

217-
// ListTokenizedAssets returns the list of asset aliases for this paymail handle.
218-
func (c *MockClient) ListTokenizedAssets(ctx context.Context) ([]AssetAlias, error) {
219-
return c.user.assetAliases, nil
217+
// ListTokenizedInstruments returns the list of instrument aliases for this paymail handle.
218+
func (c *MockClient) ListTokenizedInstruments(ctx context.Context) ([]InstrumentAlias, error) {
219+
return c.user.instrumentAliases, nil
220220
}

0 commit comments

Comments
 (0)