Skip to content

Commit 279145e

Browse files
committed
move outpoint to transaction package
1 parent 7271ed0 commit 279145e

21 files changed

+69
-58
lines changed

auth/certificates/certificate.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"errors"
1111
"fmt"
1212
ec "github.com/bsv-blockchain/go-sdk/primitives/ec"
13+
"github.com/bsv-blockchain/go-sdk/transaction"
1314
"github.com/bsv-blockchain/go-sdk/wallet"
1415
"github.com/bsv-blockchain/go-sdk/wallet/serializer"
1516
)
@@ -36,7 +37,7 @@ type Certificate struct {
3637
Certifier ec.PublicKey `json:"certifier"`
3738

3839
// The outpoint used to confirm that the certificate has not been revoked
39-
RevocationOutpoint *wallet.Outpoint `json:"revocationOutpoint"`
40+
RevocationOutpoint *transaction.Outpoint `json:"revocationOutpoint"`
4041

4142
// All the fields present in the certificate, with field names as keys and encrypted field values as strings
4243
Fields map[wallet.CertificateFieldNameUnder50Bytes]wallet.StringBase64 `json:"fields"`
@@ -51,7 +52,7 @@ func NewCertificate(
5152
serialNumber wallet.StringBase64,
5253
subject ec.PublicKey,
5354
certifier ec.PublicKey,
54-
revocationOutpoint *wallet.Outpoint,
55+
revocationOutpoint *transaction.Outpoint,
5556
fields map[wallet.CertificateFieldNameUnder50Bytes]wallet.StringBase64,
5657
signature []byte,
5758
) *Certificate {

auth/certificates/certificate_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"testing"
66

77
ec "github.com/bsv-blockchain/go-sdk/primitives/ec"
8+
"github.com/bsv-blockchain/go-sdk/transaction"
89
tu "github.com/bsv-blockchain/go-sdk/util/test_util"
910
"github.com/bsv-blockchain/go-sdk/wallet"
1011
"github.com/stretchr/testify/assert"
@@ -30,7 +31,7 @@ func TestCertificate(t *testing.T) {
3031

3132
// Create a revocation outpoint
3233
txid := make([]byte, 32)
33-
var outpoint wallet.Outpoint
34+
var outpoint transaction.Outpoint
3435
copy(outpoint.Txid[:], txid)
3536
outpoint.Index = 1
3637
sampleRevocationOutpoint := &outpoint
@@ -457,10 +458,7 @@ func TestCertificate(t *testing.T) {
457458
SerialNumber: serialBytes,
458459
Subject: sampleSubjectPubKey,
459460
Certifier: sampleCertifierPubKey,
460-
RevocationOutpoint: &wallet.Outpoint{
461-
Txid: sampleRevocationOutpoint.Txid,
462-
Index: sampleRevocationOutpoint.Index,
463-
},
461+
RevocationOutpoint: sampleRevocationOutpoint,
464462
Fields: map[string]string{
465463
"name": "Alice",
466464
"email": "alice@example.com",

auth/certificates/master.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"fmt"
99

1010
ec "github.com/bsv-blockchain/go-sdk/primitives/ec"
11+
"github.com/bsv-blockchain/go-sdk/transaction"
1112
"github.com/bsv-blockchain/go-sdk/wallet"
1213
)
1314

@@ -126,7 +127,7 @@ func IssueCertificateForSubject(
126127
subject wallet.Counterparty,
127128
plainFields map[string]string, // Plaintext fields
128129
certificateType string,
129-
getRevocationOutpoint func(string) (*wallet.Outpoint, error), // Optional func
130+
getRevocationOutpoint func(string) (*transaction.Outpoint, error), // Optional func
130131
serialNumberStr string, // Optional serial number as StringBase64
131132
) (*MasterCertificate, error) {
132133

@@ -172,15 +173,15 @@ func IssueCertificateForSubject(
172173
}
173174

174175
// 4. Get revocation outpoint
175-
var revocationOutpoint *wallet.Outpoint
176+
var revocationOutpoint *transaction.Outpoint
176177
if getRevocationOutpoint != nil {
177178
revocationOutpoint, err = getRevocationOutpoint(string(serialNumber))
178179
if err != nil {
179180
return nil, fmt.Errorf("failed to get revocation outpoint: %w", err)
180181
}
181182
} else {
182183
// Default to empty outpoint (matching TS behavior where undefined becomes empty string)
183-
revocationOutpoint = &wallet.Outpoint{} // Assuming empty TXID and index 0 is the placeholder
184+
revocationOutpoint = &transaction.Outpoint{} // Assuming empty TXID and index 0 is the placeholder
184185
}
185186

186187
// 5. Create the base Certificate struct

auth/certificates/master_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/bsv-blockchain/go-sdk/auth/utils"
1515
"github.com/bsv-blockchain/go-sdk/chainhash"
1616
ec "github.com/bsv-blockchain/go-sdk/primitives/ec"
17+
"github.com/bsv-blockchain/go-sdk/transaction"
1718
"github.com/bsv-blockchain/go-sdk/wallet"
1819
)
1920

@@ -22,7 +23,7 @@ func TestMasterCertificate(t *testing.T) {
2223
certifierPrivateKey, _ := ec.NewPrivateKey()
2324
ctx := t.Context()
2425

25-
mockRevocationOutpoint := &wallet.Outpoint{
26+
mockRevocationOutpoint := &transaction.Outpoint{
2627
Txid: chainhash.HashH([]byte("deadbeefdeadbeefdeadbeefdeadbeef00000000000000000000000000000000.1")),
2728
Index: 1,
2829
}
@@ -404,7 +405,7 @@ func TestMasterCertificate(t *testing.T) {
404405
}
405406

406407
revocationFuncCalled := false
407-
mockRevocationFunc := func(serial string) (*wallet.Outpoint, error) {
408+
mockRevocationFunc := func(serial string) (*transaction.Outpoint, error) {
408409
revocationFuncCalled = true
409410
return mockRevocationOutpoint, nil
410411
}

auth/certificates/verifiable_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/bsv-blockchain/go-sdk/chainhash"
1010
ec "github.com/bsv-blockchain/go-sdk/primitives/ec"
11+
"github.com/bsv-blockchain/go-sdk/transaction"
1112
"github.com/bsv-blockchain/go-sdk/wallet"
1213
"github.com/stretchr/testify/require"
1314
)
@@ -28,7 +29,7 @@ func TestVerifiableCertificate(t *testing.T) {
2829
// Sample data
2930
sampleType := wallet.StringBase64(base64.StdEncoding.EncodeToString(bytes.Repeat([]byte{1}, 32)))
3031
sampleSerialNumber := wallet.StringBase64(base64.StdEncoding.EncodeToString(bytes.Repeat([]byte{2}, 32)))
31-
sampleRevocationOutpoint := &wallet.Outpoint{
32+
sampleRevocationOutpoint := &transaction.Outpoint{
3233
Txid: chainhash.HashH([]byte("deadbeefdeadbeefdeadbeefdeadbeef00000000000000000000000000000000.1")),
3334
Index: 1,
3435
}

auth/utils/get_verifiable_certificates_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"testing"
99

1010
ec "github.com/bsv-blockchain/go-sdk/primitives/ec"
11+
"github.com/bsv-blockchain/go-sdk/transaction"
1112
tu "github.com/bsv-blockchain/go-sdk/util/test_util"
1213
"github.com/bsv-blockchain/go-sdk/wallet"
1314
"github.com/stretchr/testify/require"
@@ -57,7 +58,7 @@ func TestGetVerifiableCertificates(t *testing.T) {
5758
certifier, _ := ec.PublicKeyFromBytes([]byte{0x07, 0x08, 0x09})
5859

5960
// Mock wallet.ListCertificates response with base64-encoded values
60-
revocationOutpoint, _ := wallet.OutpointFromString("abcd1234:0")
61+
revocationOutpoint, _ := transaction.OutpointFromString("abcd1234:0")
6162
mockListResult := &wallet.ListCertificatesResult{
6263
Certificates: []wallet.CertificateResult{
6364
{

auth/validate_certificates_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/bsv-blockchain/go-sdk/auth/utils"
99
"github.com/bsv-blockchain/go-sdk/chainhash"
1010
ec "github.com/bsv-blockchain/go-sdk/primitives/ec"
11+
"github.com/bsv-blockchain/go-sdk/transaction"
1112
tu "github.com/bsv-blockchain/go-sdk/util/test_util"
1213
"github.com/bsv-blockchain/go-sdk/wallet"
1314
"github.com/stretchr/testify/assert"
@@ -78,7 +79,7 @@ func TestValidateCertificates(t *testing.T) {
7879
}
7980

8081
// Create revocation outpoint
81-
revocationOutpoint := &wallet.Outpoint{
82+
revocationOutpoint := &transaction.Outpoint{
8283
Txid: chainhash.HashH([]byte("test_txid_000000000000000000000000000000000000000000000000000000000000")),
8384
Index: 0,
8485
}
@@ -90,7 +91,7 @@ func TestValidateCertificates(t *testing.T) {
9091
subjectCounterparty,
9192
plaintextFields,
9293
string(utils.RandomBase64(32)), // certificate type
93-
func(serial string) (*wallet.Outpoint, error) {
94+
func(serial string) (*transaction.Outpoint, error) {
9495
return revocationOutpoint, nil
9596
},
9697
"", // auto-generate serial number

kvstore/local_kv_store.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (kv *LocalKVStore) getProtocol(key string) wallet.Protocol {
5555
// lookupValueResult holds the result of a key lookup operation
5656
type lookupValueResult struct {
5757
value string
58-
outpoints []wallet.Outpoint
58+
outpoints []transaction.Outpoint
5959
inputBeef []byte // The raw BEEF data containing all inputs for spending
6060
lor *wallet.ListOutputsResult
6161
valueExists bool
@@ -72,7 +72,7 @@ func (kv *LocalKVStore) lookupValue(ctx context.Context, key string, defaultValu
7272
if len(outputsResult.Outputs) == 0 {
7373
return &lookupValueResult{
7474
value: defaultValue,
75-
outpoints: []wallet.Outpoint{},
75+
outpoints: []transaction.Outpoint{},
7676
lor: outputsResult,
7777
valueExists: false,
7878
}, nil
@@ -156,7 +156,7 @@ func (kv *LocalKVStore) lookupValue(ctx context.Context, key string, defaultValu
156156
}
157157

158158
// Collect all outpoints for the key
159-
outpoints := make([]wallet.Outpoint, len(outputsResult.Outputs))
159+
outpoints := make([]transaction.Outpoint, len(outputsResult.Outputs))
160160
for i, output := range outputsResult.Outputs {
161161
outpoints[i] = output.Outpoint
162162
}
@@ -233,9 +233,9 @@ func (kv *LocalKVStore) Set(ctx context.Context, key string, value string) (stri
233233
}
234234
// Log other lookup errors but attempt to proceed with Set (overwrite)
235235
fmt.Printf("Warning: lookupValue failed during Set for key %s: %v\n", key, err)
236-
lookupResult = &lookupValueResult{valueExists: false, outpoints: []wallet.Outpoint{}, lor: &wallet.ListOutputsResult{}}
236+
lookupResult = &lookupValueResult{valueExists: false, outpoints: []transaction.Outpoint{}, lor: &wallet.ListOutputsResult{}}
237237
} else if err == nil && !lookupResult.valueExists { // Handle case where getOutputs was empty
238-
lookupResult = &lookupValueResult{valueExists: false, outpoints: []wallet.Outpoint{}, lor: &wallet.ListOutputsResult{}}
238+
lookupResult = &lookupValueResult{valueExists: false, outpoints: []transaction.Outpoint{}, lor: &wallet.ListOutputsResult{}}
239239
}
240240

241241
if lookupResult.valueExists && lookupResult.value == value && len(lookupResult.outpoints) > 0 {

overlay/lookup/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package lookup
22

33
import (
44
"encoding/json"
5-
"github.com/bsv-blockchain/go-sdk/wallet"
5+
"github.com/bsv-blockchain/go-sdk/transaction"
66
)
77

88
// AnswerType represents the type of answer returned by a lookup service
@@ -28,7 +28,7 @@ type LookupQuestion struct {
2828

2929
// LookupFormula represents a formula for computing lookup results
3030
type LookupFormula struct {
31-
Outpoint *wallet.Outpoint
31+
Outpoint *transaction.Outpoint
3232
History func(beef []byte, outputIndex uint32, currentDepth uint32) bool
3333
// HistoryDepth uint32
3434
}

overlay/overlay.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ package overlay
88

99
import (
1010
"github.com/bsv-blockchain/go-sdk/chainhash"
11-
"github.com/bsv-blockchain/go-sdk/wallet"
11+
"github.com/bsv-blockchain/go-sdk/transaction"
1212
)
1313

1414
// Protocol represents the overlay protocol type (SHIP or SLAP)
@@ -34,7 +34,7 @@ type AppliedTransaction struct {
3434
// TopicData represents data associated with an overlay topic including dependencies
3535
type TopicData struct {
3636
Data any
37-
Deps []*wallet.Outpoint
37+
Deps []*transaction.Outpoint
3838
}
3939

4040
// AdmittanceInstructions specify which outputs to admit and which coins to retain when submitting to overlay topics

0 commit comments

Comments
 (0)