@@ -1097,59 +1097,32 @@ func processCoordinationResult(node *node, result *coordinationResult) {
1097
1097
1098
1098
// archiveClosedWallets archives closed or terminated wallets.
1099
1099
func (n * node ) archiveClosedWallets () error {
1100
- getClosedWallets := func (walletPublicKeyHashes [][20 ]byte ) (
1101
- closedWallets [][20 ]byte ,
1102
- ) {
1103
- for _ , walletPublicKeyHash := range walletPublicKeyHashes {
1104
- walletChainData , err := n .chain .GetWallet (walletPublicKeyHash )
1105
- if err != nil {
1106
- // Continue if there was an error getting wallet data. Try to
1107
- // get as many closed wallets as possible.
1108
- logger .Errorf (
1109
- "could not get wallet data for wallet [0x%x]: [%v]" ,
1110
- walletPublicKeyHash ,
1111
- err ,
1112
- )
1113
- continue
1114
- }
1115
-
1116
- if walletChainData .State == StateClosed ||
1117
- walletChainData .State == StateTerminated {
1118
- closedWallets = append (closedWallets , walletPublicKeyHash )
1119
- }
1120
- }
1121
-
1122
- return
1123
- }
1124
-
1125
1100
// Get all the wallets controlled by the node.
1126
1101
walletPublicKeys := n .walletRegistry .getWalletsPublicKeys ()
1127
1102
1128
- walletPublicKeyHashes := [][20 ]byte {}
1129
1103
for _ , walletPublicKey := range walletPublicKeys {
1130
- walletPublicKeyHashes = append (
1131
- walletPublicKeyHashes ,
1132
- bitcoin .PublicKeyHash (walletPublicKey ),
1133
- )
1134
- }
1135
-
1136
- // Find the wallets that are closed.
1137
- closedWallets := getClosedWallets (walletPublicKeyHashes )
1138
- if len (closedWallets ) == 0 {
1139
- logger .Infof ("there are no closed wallets to archive" )
1140
- return nil
1141
- }
1104
+ walletPublicKeyHash := bitcoin .PublicKeyHash (walletPublicKey )
1142
1105
1143
- // Archive the closed wallets.
1144
- for _ , walletPublicKeyHash := range closedWallets {
1145
- err := n .walletRegistry .archiveWallet (walletPublicKeyHash )
1106
+ walletChainData , err := n .chain .GetWallet (walletPublicKeyHash )
1146
1107
if err != nil {
1147
1108
return fmt .Errorf (
1148
- "could not archive wallet with public key hash [0x%x]: [%v]" ,
1109
+ "could not get wallet data for wallet [0x%x]: [%v]" ,
1149
1110
walletPublicKeyHash ,
1150
1111
err ,
1151
1112
)
1152
- } else {
1113
+ }
1114
+
1115
+ if walletChainData .State == StateClosed ||
1116
+ walletChainData .State == StateTerminated {
1117
+ err := n .walletRegistry .archiveWallet (walletPublicKeyHash )
1118
+ if err != nil {
1119
+ return fmt .Errorf (
1120
+ "could not archive wallet with public key hash [0x%x]: [%v]" ,
1121
+ walletPublicKeyHash ,
1122
+ err ,
1123
+ )
1124
+ }
1125
+
1153
1126
logger .Infof (
1154
1127
"successfully archived wallet with public key hash [0x%x]" ,
1155
1128
walletPublicKeyHash ,
0 commit comments