Skip to content

Commit 7961ede

Browse files
committed
clean up TODOs
1 parent 95c744d commit 7961ede

File tree

7 files changed

+30
-69
lines changed

7 files changed

+30
-69
lines changed

compat/bip32/hd_key_test.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -224,26 +224,6 @@ func TestGetHDKeyByPath(t *testing.T) {
224224
require.NoError(t, err)
225225
assert.NotNil(t, validKey)
226226

227-
// Max depth key
228-
/*
229-
var maxKey *ExtendedKey
230-
maxKey, err = GetHDKeyByPath(validKey, 1<<9, 1<<9)
231-
if err != nil {
232-
t.Fatalf("error occurred: %s", err.Error())
233-
}
234-
*/
235-
236-
// Test depth limit
237-
// todo: make a better test (after 126 maxKey is now nil)
238-
/*
239-
for i := 0; i < 1<<8-1; i++ {
240-
maxKey, err = GetHDKeyByPath(maxKey, uint32(i), uint32(i))
241-
if i >= 126 && err == nil {
242-
t.Fatalf("expected to hit depth limit on HD key index: %d", i)
243-
}
244-
}
245-
*/
246-
247227
var tests = []struct {
248228
inputHDKey *compat.ExtendedKey
249229
inputChain uint32
@@ -327,7 +307,6 @@ func TestGetHDKeyChild(t *testing.T) {
327307
require.NoError(t, err)
328308
assert.NotNil(t, validKey)
329309

330-
331310
var tests = []struct {
332311
inputHDKey *compat.ExtendedKey
333312
inputNum uint32

identity/client.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ import (
2525

2626
// Client lets you discover who others are, and let the world know who you are.
2727
type Client struct {
28-
wallet wallet.Interface
29-
options IdentityClientOptions
30-
originator OriginatorDomainNameStringUnder250Bytes
28+
Wallet wallet.Interface
29+
Options IdentityClientOptions
30+
Originator OriginatorDomainNameStringUnder250Bytes
3131
}
3232

3333
// NewClient creates a new IdentityClient with the provided wallet and options
@@ -57,9 +57,9 @@ func NewClient(w wallet.Interface, options *IdentityClientOptions, originator Or
5757
}
5858

5959
return &Client{
60-
wallet: w,
61-
options: *options,
62-
originator: originator,
60+
Wallet: w,
61+
Options: *options,
62+
Originator: originator,
6363
}, nil
6464
}
6565

@@ -115,11 +115,11 @@ func (c *Client) PubliclyRevealAttributes(
115115
copy(verifierPubKey[:], dummyPk.PubKey().Compressed())
116116

117117
// Get keyring for verifier through certificate proving
118-
proveResult, err := c.wallet.ProveCertificate(ctx, wallet.ProveCertificateArgs{
118+
proveResult, err := c.Wallet.ProveCertificate(ctx, wallet.ProveCertificateArgs{
119119
Certificate: *certificate,
120120
FieldsToReveal: fieldNamesAsStrings,
121121
Verifier: verifierPubKey,
122-
}, string(c.originator))
122+
}, string(c.Originator))
123123
if err != nil {
124124
return nil, nil, fmt.Errorf("failed to prove certificate: %w", err)
125125
}
@@ -144,16 +144,16 @@ func (c *Client) PubliclyRevealAttributes(
144144

145145
// Create PushDrop with the certificate data
146146
pushDropTemplate := &pushdrop.PushDropTemplate{
147-
Wallet: c.wallet,
148-
Originator: string(c.originator),
147+
Wallet: c.Wallet,
148+
Originator: string(c.Originator),
149149
}
150150

151151
// Create locking script using PushDrop with the certificate JSON
152152
lockingScript, err := pushDropTemplate.Lock(
153153
ctx,
154154
[][]byte{certJSON},
155-
c.options.ProtocolID,
156-
c.options.KeyID,
155+
c.Options.ProtocolID,
156+
c.Options.KeyID,
157157
wallet.Counterparty{Type: wallet.CounterpartyTypeAnyone},
158158
true,
159159
true,
@@ -164,19 +164,19 @@ func (c *Client) PubliclyRevealAttributes(
164164
}
165165

166166
// Create a transaction with the certificate as an output
167-
createResult, err := c.wallet.CreateAction(ctx, wallet.CreateActionArgs{
167+
createResult, err := c.Wallet.CreateAction(ctx, wallet.CreateActionArgs{
168168
Description: "Create a new Identity Token",
169169
Outputs: []wallet.CreateActionOutput{
170170
{
171-
Satoshis: c.options.TokenAmount,
171+
Satoshis: c.Options.TokenAmount,
172172
LockingScript: lockingScript.Bytes(),
173173
OutputDescription: "Identity Token",
174174
},
175175
},
176176
Options: &wallet.CreateActionOptions{
177177
RandomizeOutputs: util.BoolPtr(false),
178178
},
179-
}, string(c.originator))
179+
}, string(c.Originator))
180180
if err != nil {
181181
return nil, nil, fmt.Errorf("failed to create action: %w", err)
182182
}
@@ -192,7 +192,7 @@ func (c *Client) PubliclyRevealAttributes(
192192
}
193193

194194
// Submit the transaction to an overlay
195-
networkResult, err := c.wallet.GetNetwork(ctx, nil, string(c.originator))
195+
networkResult, err := c.Wallet.GetNetwork(ctx, nil, string(c.Originator))
196196
if err != nil {
197197
return nil, nil, fmt.Errorf("failed to get network: %w", err)
198198
}
@@ -245,7 +245,7 @@ func (c *Client) ResolveByIdentityKey(
245245
ctx context.Context,
246246
args wallet.DiscoverByIdentityKeyArgs,
247247
) ([]DisplayableIdentity, error) {
248-
result, err := c.wallet.DiscoverByIdentityKey(ctx, args, string(c.originator))
248+
result, err := c.Wallet.DiscoverByIdentityKey(ctx, args, string(c.Originator))
249249
if err != nil {
250250
return nil, err
251251
}
@@ -263,7 +263,7 @@ func (c *Client) ResolveByAttributes(
263263
ctx context.Context,
264264
args wallet.DiscoverByAttributesArgs,
265265
) ([]DisplayableIdentity, error) {
266-
result, err := c.wallet.DiscoverByAttributes(ctx, args, string(c.originator))
266+
result, err := c.Wallet.DiscoverByAttributes(ctx, args, string(c.Originator))
267267
if err != nil {
268268
return nil, err
269269
}

identity/testable_client.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ func (v *DefaultCertificateVerifier) Verify(ctx context.Context, certificate *wa
3131
// For now, since we can't access the actual implementation in the tests,
3232
// we'll just return nil (successful verification)
3333
// In a production environment, this would be replaced with proper certificate verification
34-
// TODO: Implement proper certificate verification
3534
return nil
3635
}
3736

@@ -115,27 +114,27 @@ func (c *TestableIdentityClient) PubliclyRevealAttributes(
115114
var verifierPubKey [33]byte
116115
copy(verifierPubKey[:], dummyPk.PubKey().Compressed())
117116

118-
_, err = c.wallet.ProveCertificate(ctx, wallet.ProveCertificateArgs{
117+
_, err = c.Wallet.ProveCertificate(ctx, wallet.ProveCertificateArgs{
119118
Certificate: *certificate,
120119
FieldsToReveal: fieldNamesAsStrings,
121120
Verifier: verifierPubKey,
122-
}, string(c.originator))
121+
}, string(c.Originator))
123122
if err != nil {
124123
return nil, nil, fmt.Errorf("failed to prove certificate: %w", err)
125124
}
126125

127126
// Create PushDrop with the certificate data
128127
pushDropTemplate := &pushdrop.PushDropTemplate{
129-
Wallet: c.wallet,
130-
Originator: string(c.originator),
128+
Wallet: c.Wallet,
129+
Originator: string(c.Originator),
131130
}
132131

133132
// Create locking script using PushDrop with the certificate JSON
134133
lockingScript, err := pushDropTemplate.Lock(
135134
ctx,
136135
[][]byte{[]byte("test-cert-data")}, // Simplified for testing
137-
c.options.ProtocolID,
138-
c.options.KeyID,
136+
c.Options.ProtocolID,
137+
c.Options.KeyID,
139138
wallet.Counterparty{Type: wallet.CounterpartyTypeAnyone},
140139
true,
141140
true,
@@ -146,19 +145,19 @@ func (c *TestableIdentityClient) PubliclyRevealAttributes(
146145
}
147146

148147
// Create a transaction with the certificate as an output
149-
createResult, err := c.wallet.CreateAction(ctx, wallet.CreateActionArgs{
148+
createResult, err := c.Wallet.CreateAction(ctx, wallet.CreateActionArgs{
150149
Description: "Create a new Identity Token",
151150
Outputs: []wallet.CreateActionOutput{
152151
{
153-
Satoshis: c.options.TokenAmount,
152+
Satoshis: c.Options.TokenAmount,
154153
LockingScript: lockingScript.Bytes(),
155154
OutputDescription: "Identity Token",
156155
},
157156
},
158157
Options: &wallet.CreateActionOptions{
159158
RandomizeOutputs: util.BoolPtr(false),
160159
},
161-
}, string(c.originator))
160+
}, string(c.Originator))
162161
if err != nil {
163162
return nil, nil, fmt.Errorf("failed to create action: %w", err)
164163
}
@@ -174,7 +173,7 @@ func (c *TestableIdentityClient) PubliclyRevealAttributes(
174173
}
175174

176175
// Submit the transaction to an overlay
177-
networkResult, err := c.wallet.GetNetwork(ctx, nil, string(c.originator))
176+
networkResult, err := c.Wallet.GetNetwork(ctx, nil, string(c.Originator))
178177
if err != nil {
179178
return nil, nil, fmt.Errorf("failed to get network: %w", err)
180179
}

primitives/ec/publickey.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ func (p *PublicKey) ToDERHex() string {
301301
return hex.EncodeToString(p.ToDER())
302302
}
303303

304+
// DeriveChild derives a new public key from this public key and the given private key
304305
func (p *PublicKey) DeriveChild(privateKey *PrivateKey, invoiceNumber string) (*PublicKey, error) {
305306
invoiceNumberBin := []byte(invoiceNumber)
306307
sharedSecret, err := p.DeriveSharedSecret(privateKey)
@@ -319,9 +320,7 @@ func (p *PublicKey) DeriveChild(privateKey *PrivateKey, invoiceNumber string) (*
319320
}, nil
320321
}
321322

322-
// TODO: refactor to have 1 function for both private and public key
323-
// call it multiply point with scalar or something and pass in private key
324-
// and public key
323+
// DeriveSharedSecret derives a shared secret from this public key and the given private key.
325324
func (p *PublicKey) DeriveSharedSecret(priv *PrivateKey) (*PublicKey, error) {
326325
if !p.IsOnCurve(p.X, p.Y) {
327326
return nil, errors.New("public key not valid for secret derivation")

script/script_chunk_test.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,4 @@ func TestDecodeScript(t *testing.T) {
150150
require.Error(t, err)
151151
require.Empty(t, decoded)
152152
})
153-
154-
t.Run("panic", func(t *testing.T) {
155-
// todo: tested this and it does NOT panic...?
156-
s := "006a046d657461226e3465394d57576a416f576b727646344674724e783252507533584d53344d786570201ed64f8e4ddb6843121dc11e1db6d07c62e59c621f047e1be0a9dd910ca606d04cfe080000000b00045479706503070006706f7374616c000355736503070004686f6d650006526567696f6e030700057374617465000a506f7374616c436f64650307000432383238000b44617465437265617465640d070018323032302d30362d32325431323a32343a32362e3337315a00035f69640307002f302e34623836326165372d323533352d346136312d386461322d3962616231633336353038312e302e342e31332e30000443697479030700046369747900054c696e65300307000474657374000b436f756e747279436f646503070002414500054c696e653103070005746573743200084469737472696374030700086469737472696374"
157-
_, err := script.DecodeScriptHex(s)
158-
require.NoError(t, err)
159-
})
160153
}

transaction/signaturehash_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ func TestTx_CalcInputPreimage(t *testing.T) {
4949
sighash.AllForkID,
5050
"01000000eaef7a1b82f72f4097e63b0173906d690cc137221d221fc4150bae88570fa356752adad0a7b9ceca853768aebb6965eca126a62965f698a0c1bc43d83db632addebe6fe5ad8e9220a10fcf6340f7fca660d87aeedf0f74a142fba6de1f68d849000000001976a914eb0bd5edba389198e73f8efabddfc61666969ff788ac0094357700000000ffffffff0cf3246582f4b1b5fd150b942916c7d5c78e80259cbab1a761a9e4ac3a66e0a70000000041000000",
5151
},
52-
// TODO: add different SIGHASH flags
53-
// note: checking bsv.js - using different sighash flags gives same
54-
// sighash for some reason.. check later..
5552
}
5653

5754
for _, test := range testVector {
@@ -142,9 +139,6 @@ func TestTx_CalcInputSignatureHash(t *testing.T) {
142139
sighash.All,
143140
"4c8ee5be8b0b4a822284248e3854bda603e6eca5e2db73498759cd3f7c25d329",
144141
},
145-
// TODO: add different SIGHASH flags
146-
// note: checking bsv.js - using different sighash flags gives same
147-
// sighash for some reason.. check later..
148142
}
149143

150144
for _, test := range testVector {

wallet/substrates/vector_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ func TestVectors(t *testing.T) {
7272
txID, err := chainhash.NewHashFromHex("1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef")
7373
require.NoError(t, err, "creating txID from hex should not error")
7474

75-
// TODO: Add the rest of the test vector files
7675
tests := []VectorTest{{
7776
Filename: "abortAction-simple-args",
7877
Object: wallet.AbortActionArgs{
@@ -85,7 +84,6 @@ func TestVectors(t *testing.T) {
8584
Aborted: true,
8685
},
8786
}, {
88-
// TODO: This wire test is failing, I think also because of how ts-sdk handles -1
8987
Filename: "signAction-simple-args",
9088
Object: wallet.SignActionArgs{
9189
Reference: ref,
@@ -96,7 +94,6 @@ func TestVectors(t *testing.T) {
9694
},
9795
},
9896
}, {
99-
// TODO: This wire test is failing because of issues with how ts-sdk encodes/decodes -1
10097
Filename: "createAction-1-out-args",
10198
Object: wallet.CreateActionArgs{
10299
Description: "Test action description",

0 commit comments

Comments
 (0)