Skip to content

Commit 077faba

Browse files
committed
wallet: remove PSBT legacy credit helper
Remove the PSBT legacy credit helper after every PSBT credit and parent lookup has moved to the store-backed path.
1 parent ea2a531 commit 077faba

3 files changed

Lines changed: 0 additions & 125 deletions

File tree

wallet/psbt_manager.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"github.com/btcsuite/btcwallet/waddrmgr"
2222
"github.com/btcsuite/btcwallet/wallet/internal/db"
2323
"github.com/btcsuite/btcwallet/wallet/txauthor"
24-
"github.com/btcsuite/btcwallet/wtxmgr"
2524
)
2625

2726
var (
@@ -568,20 +567,6 @@ func validatePsbtParentOutput(outPoint wire.OutPoint,
568567
return utxo, nil
569568
}
570569

571-
// findCredit determines whether a transaction's details contain a credit for a
572-
// specific output index.
573-
func findCredit(txDetail *wtxmgr.TxDetails,
574-
outputIndex uint32) *wtxmgr.CreditRecord {
575-
576-
for i := range txDetail.Credits {
577-
if txDetail.Credits[i].Index == outputIndex {
578-
return &txDetail.Credits[i]
579-
}
580-
}
581-
582-
return nil
583-
}
584-
585570
// FundPsbt performs coin selection and funds the PSBT.
586571
//
587572
// It executes the funding logic by:

wallet/psbt_manager_test.go

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"github.com/btcsuite/btcwallet/waddrmgr"
2525
"github.com/btcsuite/btcwallet/wallet/internal/db"
2626
"github.com/btcsuite/btcwallet/wallet/txauthor"
27-
"github.com/btcsuite/btcwallet/wtxmgr"
2827
"github.com/stretchr/testify/mock"
2928
"github.com/stretchr/testify/require"
3029
)
@@ -56,67 +55,6 @@ func testStoreUtxoInfo(outPoint wire.OutPoint,
5655
}
5756
}
5857

59-
// TestFindCredit tests that the findCredit helper returns true if a credit
60-
// exists at the specified index, and false otherwise.
61-
func TestFindCredit(t *testing.T) {
62-
t.Parallel()
63-
64-
// Arrange: Create TxDetails with credits at indices 0 and 2.
65-
txDetails := &wtxmgr.TxDetails{
66-
Credits: []wtxmgr.CreditRecord{
67-
{Index: 0},
68-
{Index: 2},
69-
},
70-
}
71-
72-
// Arrange: Define test cases to check for credits at various indices.
73-
testCases := []struct {
74-
name string
75-
index uint32
76-
expectedFound bool
77-
}{
78-
{
79-
name: "credit exists at index 0",
80-
index: 0,
81-
expectedFound: true,
82-
},
83-
{
84-
name: "credit exists at index 2",
85-
index: 2,
86-
expectedFound: true,
87-
},
88-
{
89-
name: "credit does not exist at index 1",
90-
index: 1,
91-
expectedFound: false,
92-
},
93-
{
94-
name: "credit does not exist at index 3",
95-
index: 3,
96-
expectedFound: false,
97-
},
98-
}
99-
100-
for _, tc := range testCases {
101-
t.Run(tc.name, func(t *testing.T) {
102-
t.Parallel()
103-
104-
// Act: Call findCredit with the configured TxDetails
105-
// and index.
106-
cred := findCredit(txDetails, tc.index)
107-
108-
// Assert: Verify that the returned credit record
109-
// matches the expected outcome.
110-
if tc.expectedFound {
111-
require.NotNil(t, cred)
112-
require.Equal(t, tc.index, cred.Index)
113-
} else {
114-
require.Nil(t, cred)
115-
}
116-
})
117-
}
118-
}
119-
12058
// TestFetchAndValidateUtxoSuccess tests that fetchAndValidateUtxo correctly
12159
// retrieves wallet-owned UTXO and transaction details.
12260
func TestFetchAndValidateUtxoSuccess(t *testing.T) {

wallet/txdetails_legacy.go

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)