Skip to content

Commit 95c56bb

Browse files
committed
Used registry when checking the state of wallets
1 parent 88f3bf6 commit 95c56bb

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

pkg/tbtc/node.go

+16-4
Original file line numberDiff line numberDiff line change
@@ -1103,17 +1103,29 @@ func (n *node) archiveClosedWallets() error {
11031103
for _, walletPublicKey := range walletPublicKeys {
11041104
walletPublicKeyHash := bitcoin.PublicKeyHash(walletPublicKey)
11051105

1106-
walletChainData, err := n.chain.GetWallet(walletPublicKeyHash)
1106+
walletID, err := n.chain.CalculateWalletID(walletPublicKey)
11071107
if err != nil {
11081108
return fmt.Errorf(
1109-
"could not get wallet data for wallet [0x%x]: [%v]",
1109+
"could not calculate wallet ID for wallet with public key "+
1110+
"hash [0x%x]: [%v]",
11101111
walletPublicKeyHash,
11111112
err,
11121113
)
11131114
}
11141115

1115-
if walletChainData.State == StateClosed ||
1116-
walletChainData.State == StateTerminated {
1116+
isRegistered, err := n.chain.IsWalletRegistered(walletID)
1117+
if err != nil {
1118+
return fmt.Errorf(
1119+
"could not check if wallet is registered for wallet with ID "+
1120+
"[0x%x]: [%v]",
1121+
walletPublicKeyHash,
1122+
err,
1123+
)
1124+
}
1125+
1126+
if !isRegistered {
1127+
// If the wallet is no longer registered it means the wallet has
1128+
// been closed or terminated.
11171129
err := n.walletRegistry.archiveWallet(walletPublicKeyHash)
11181130
if err != nil {
11191131
return fmt.Errorf(

0 commit comments

Comments
 (0)